Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,37 +15,32 @@ from langchain.tools import Tool
|
|
| 15 |
from langgraph.graph import START, StateGraph
|
| 16 |
from langgraph.graph.message import add_messages
|
| 17 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 18 |
-
from
|
| 19 |
import cv2
|
| 20 |
|
| 21 |
|
| 22 |
import getpass
|
| 23 |
import os
|
| 24 |
|
| 25 |
-
if "
|
| 26 |
-
os.environ["
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
model="
|
| 31 |
-
temperature=0.01,
|
| 32 |
-
max_retries=6,
|
| 33 |
-
mistral_api_key = os.getenv("Mistral")
|
| 34 |
-
)
|
| 35 |
-
chat2 = ChatMistralAI(
|
| 36 |
-
model="pixtral-large-2411",
|
| 37 |
temperature=0.01,
|
| 38 |
max_retries=6,
|
| 39 |
-
|
| 40 |
)
|
| 41 |
-
print(f"Model {
|
| 42 |
-
|
| 43 |
-
|
|
|
|
| 44 |
temperature=0.01,
|
| 45 |
max_retries=6,
|
| 46 |
-
|
| 47 |
)
|
| 48 |
-
print(f"Model {
|
| 49 |
|
| 50 |
# (Keep Constants as is)
|
| 51 |
# --- Constants ---
|
|
@@ -208,10 +203,10 @@ class BasicAgent:
|
|
| 208 |
wrong_answers = ["Requests rate limit exceeded", "", " ", " ", "insufficient information"]
|
| 209 |
while not answer or answer in wrong_answers or answer.lower().startswith("error"):
|
| 210 |
try:
|
| 211 |
-
alfred = build_agent(
|
| 212 |
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 213 |
except:
|
| 214 |
-
alfred = build_agent(
|
| 215 |
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 216 |
|
| 217 |
if answer:
|
|
|
|
| 15 |
from langgraph.graph import START, StateGraph
|
| 16 |
from langgraph.graph.message import add_messages
|
| 17 |
from langgraph.prebuilt import ToolNode, tools_condition
|
| 18 |
+
from langchain_deepseek import ChatDeepSeek
|
| 19 |
import cv2
|
| 20 |
|
| 21 |
|
| 22 |
import getpass
|
| 23 |
import os
|
| 24 |
|
| 25 |
+
if "DS_AGENT_API" not in os.environ:
|
| 26 |
+
os.environ["DS_AGENT_API"] = getpass.getpass("Enter your DS API key: ")
|
| 27 |
|
| 28 |
+
|
| 29 |
+
chat1 = ChatDeepSeek(
|
| 30 |
+
model="deepseek-chat",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
temperature=0.01,
|
| 32 |
max_retries=6,
|
| 33 |
+
api_key = os.getenv("DS_AGENT_API")
|
| 34 |
)
|
| 35 |
+
print(f"Model {chat1.model} downloaded!")
|
| 36 |
+
|
| 37 |
+
chat2 = ChatDeepSeek(
|
| 38 |
+
model="deepseek-reasoner",
|
| 39 |
temperature=0.01,
|
| 40 |
max_retries=6,
|
| 41 |
+
api_key = os.getenv("DS_AGENT_API")
|
| 42 |
)
|
| 43 |
+
print(f"Model {chat2.model} downloaded!")
|
| 44 |
|
| 45 |
# (Keep Constants as is)
|
| 46 |
# --- Constants ---
|
|
|
|
| 203 |
wrong_answers = ["Requests rate limit exceeded", "", " ", " ", "insufficient information"]
|
| 204 |
while not answer or answer in wrong_answers or answer.lower().startswith("error"):
|
| 205 |
try:
|
| 206 |
+
alfred = build_agent(chat1)
|
| 207 |
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 208 |
except:
|
| 209 |
+
alfred = build_agent(chat2)
|
| 210 |
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 6})['messages'][-1].content
|
| 211 |
|
| 212 |
if answer:
|