agent model changed
Browse files
app.py
CHANGED
@@ -158,7 +158,7 @@ class AppState:
|
|
158 |
|
159 |
def get_chat_history_name_agent(self):
|
160 |
return dspy.ChainOfThought(self.chat_name_agent)
|
161 |
-
|
162 |
# Initialize FastAPI app with state
|
163 |
app = FastAPI(title="AI Analytics API", version="1.0")
|
164 |
app.state = AppState()
|
@@ -476,17 +476,13 @@ async def index():
|
|
476 |
],
|
477 |
}
|
478 |
|
479 |
-
# @app.post("/chat_history_name")
|
480 |
-
# async def chat_history_name(request: dict):
|
481 |
-
# query = request.get("query")
|
482 |
-
# name = dspy.ChainOfThought(chat_history_name_agent)(query=query)
|
483 |
-
# return {"name": name.name}
|
484 |
-
|
485 |
@app.post("/chat_history_name")
|
486 |
async def chat_history_name(request: dict):
|
487 |
query = request.get("query")
|
488 |
-
name =
|
489 |
-
|
|
|
|
|
490 |
|
491 |
# In the section where routers are included, add the session_router
|
492 |
app.include_router(chat_router)
|
|
|
158 |
|
159 |
def get_chat_history_name_agent(self):
|
160 |
return dspy.ChainOfThought(self.chat_name_agent)
|
161 |
+
|
162 |
# Initialize FastAPI app with state
|
163 |
app = FastAPI(title="AI Analytics API", version="1.0")
|
164 |
app.state = AppState()
|
|
|
476 |
],
|
477 |
}
|
478 |
|
|
|
|
|
|
|
|
|
|
|
|
|
479 |
@app.post("/chat_history_name")
|
480 |
async def chat_history_name(request: dict):
|
481 |
query = request.get("query")
|
482 |
+
name = None
|
483 |
+
with dspy.settings.context(lm=dspy.GROQ(model="llama-3.2-11b-vision-preview", max_tokens=100, temperature=1.0, api_key=os.getenv("GROQ_API_KEY"))):
|
484 |
+
name = app.state.get_chat_history_name_agent()(query=str(query))
|
485 |
+
return {"name": name.name if name else "New Chat"}
|
486 |
|
487 |
# In the section where routers are included, add the session_router
|
488 |
app.include_router(chat_router)
|