Create app/agents/chat_agent.py
Browse files- app/agents/chat_agent.py +20 -0
app/agents/chat_agent.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app/agents/chat_agent.py
|
| 2 |
+
|
| 3 |
+
import requests
|
| 4 |
+
import os
|
| 5 |
+
|
| 6 |
+
OLLAMA_URL = os.getenv("OLLAMA_URL")
|
| 7 |
+
|
| 8 |
+
def run(task):
|
| 9 |
+
prompt = task["prompt"]
|
| 10 |
+
|
| 11 |
+
r = requests.post(
|
| 12 |
+
f"{OLLAMA_URL}/api/generate",
|
| 13 |
+
json={
|
| 14 |
+
"model": os.getenv("OLLAMA_MODEL"),
|
| 15 |
+
"prompt": prompt,
|
| 16 |
+
"stream": False
|
| 17 |
+
}
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
return r.json()
|