Spaces:
Build error
Build error
Update agents.py
Browse files
agents.py
CHANGED
|
@@ -5,7 +5,6 @@ import requests
|
|
| 5 |
import yaml
|
| 6 |
import pandas as pd
|
| 7 |
|
| 8 |
-
from types import SimpleNamespace # NEW
|
| 9 |
|
| 10 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 11 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
|
@@ -13,19 +12,6 @@ groq_api_key = os.getenv("GROQ_API_KEY")
|
|
| 13 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, WikipediaSearchTool, Tool, SpeechToTextTool
|
| 14 |
from langchain_groq import ChatGroq
|
| 15 |
|
| 16 |
-
# === WRAPPER CLASS TO FIX 'content' ERROR ===
|
| 17 |
-
from langchain_core.messages import AIMessage
|
| 18 |
-
|
| 19 |
-
class WrappedChatGroq(ChatGroq):
|
| 20 |
-
def invoke(self, *args, **kwargs):
|
| 21 |
-
result = super().invoke(*args, **kwargs)
|
| 22 |
-
if isinstance(result, dict) and "content" in result:
|
| 23 |
-
return AIMessage(content=result["content"])
|
| 24 |
-
return result
|
| 25 |
-
|
| 26 |
-
def __call__(self, *args, **kwargs):
|
| 27 |
-
return self.invoke(*args, **kwargs)
|
| 28 |
-
|
| 29 |
|
| 30 |
# === TOOLS ===
|
| 31 |
class GetTaskFileTool(Tool):
|
|
@@ -81,7 +67,7 @@ prompts["system_prompt"] = (
|
|
| 81 |
|
| 82 |
# === AGENT FUNCTION ===
|
| 83 |
def agentRudra():
|
| 84 |
-
model =
|
| 85 |
model_name="llama3-8b-8192",
|
| 86 |
api_key=groq_api_key,
|
| 87 |
temperature=0
|
|
|
|
| 5 |
import yaml
|
| 6 |
import pandas as pd
|
| 7 |
|
|
|
|
| 8 |
|
| 9 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
| 10 |
groq_api_key = os.getenv("GROQ_API_KEY")
|
|
|
|
| 12 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool, WikipediaSearchTool, Tool, SpeechToTextTool
|
| 13 |
from langchain_groq import ChatGroq
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# === TOOLS ===
|
| 17 |
class GetTaskFileTool(Tool):
|
|
|
|
| 67 |
|
| 68 |
# === AGENT FUNCTION ===
|
| 69 |
def agentRudra():
|
| 70 |
+
model = ChatGroq(
|
| 71 |
model_name="llama3-8b-8192",
|
| 72 |
api_key=groq_api_key,
|
| 73 |
temperature=0
|