raghavNCI
commited on
Commit
·
c1ba890
1
Parent(s):
8e9fd43
changes to ask
Browse files- app.py +2 -0
- question.py +2 -2
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from routes import router # routes.py must be in same folder
|
|
|
3 |
from dotenv import load_dotenv
|
4 |
from cache_init import fetch_and_cache_articles
|
5 |
|
@@ -7,6 +8,7 @@ load_dotenv()
|
|
7 |
|
8 |
app = FastAPI()
|
9 |
app.include_router(router)
|
|
|
10 |
|
11 |
@app.on_event("startup")
|
12 |
async def startup_event():
|
|
|
1 |
from fastapi import FastAPI
|
2 |
from routes import router # routes.py must be in same folder
|
3 |
+
from question import askMe
|
4 |
from dotenv import load_dotenv
|
5 |
from cache_init import fetch_and_cache_articles
|
6 |
|
|
|
8 |
|
9 |
app = FastAPI()
|
10 |
app.include_router(router)
|
11 |
+
app.include_router(askMe)
|
12 |
|
13 |
@app.on_event("startup")
|
14 |
async def startup_event():
|
question.py
CHANGED
@@ -13,14 +13,14 @@ load_dotenv()
|
|
13 |
|
14 |
GNEWS_API_KEY = os.getenv("GNEWS_API_KEY")
|
15 |
|
16 |
-
|
17 |
|
18 |
qa_model = pipeline("text2text-generation", model="google/flan-t5-base") # replace with your preferred model
|
19 |
|
20 |
class QuestionInput(BaseModel):
|
21 |
question: str
|
22 |
|
23 |
-
@
|
24 |
async def ask_question(input: QuestionInput):
|
25 |
question = input.question
|
26 |
|
|
|
13 |
|
14 |
GNEWS_API_KEY = os.getenv("GNEWS_API_KEY")
|
15 |
|
16 |
+
askMe = APIRouter()
|
17 |
|
18 |
qa_model = pipeline("text2text-generation", model="google/flan-t5-base") # replace with your preferred model
|
19 |
|
20 |
class QuestionInput(BaseModel):
|
21 |
question: str
|
22 |
|
23 |
+
@askMe.post("/ask")
|
24 |
async def ask_question(input: QuestionInput):
|
25 |
question = input.question
|
26 |
|