Update main.py
Browse files
main.py
CHANGED
|
@@ -30,5 +30,14 @@ async def generate_response(request: PromptRequest):
|
|
| 30 |
temperature=request.temperature,
|
| 31 |
base_url="http://localhost:11434"
|
| 32 |
)
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
|
|
|
| 30 |
temperature=request.temperature,
|
| 31 |
base_url="http://localhost:11434"
|
| 32 |
)
|
| 33 |
+
tool_prompt = f"System Role: You are an autonomous AI Agent with real-time internet access. Current Date: {{today_date}} TOOL_DEFINITION: - Name: Search_tool - Activation Command: Search [Your Query Here]"
|
| 34 |
+
response = llm.invoke(f'{{tool_prompt}}, User-Query:-{{request.prompt}}')
|
| 35 |
+
|
| 36 |
+
if "Search " in response:
|
| 37 |
+
new_query = response.removeprefix("Search ")
|
| 38 |
+
search_response = search_tool(query=new_query)
|
| 39 |
+
new_response = llm.invoke(f"Extra_information:- {{search_response}} User-Query:- {{request.prompt}}")
|
| 40 |
+
return {"response": new_response}
|
| 41 |
+
else:
|
| 42 |
+
return {"response": response}
|
| 43 |
|