Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ from huggingface_hub import login
|
|
11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
12 |
|
13 |
login(token=os.environ["HUGGINGFACEHUB_API_TOKEN"])
|
|
|
14 |
|
15 |
search_tool = DuckDuckGoSearchTool()
|
16 |
|
@@ -18,11 +19,20 @@ async def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
18 |
log_output = ""
|
19 |
|
20 |
try:
|
21 |
-
|
|
|
22 |
tools=[search_tool],
|
23 |
-
model=InferenceClientModel(
|
24 |
-
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
)
|
27 |
except Exception as e:
|
28 |
yield f"Error initializing agent: {e}", None, log_output
|
|
|
11 |
DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
|
12 |
|
13 |
login(token=os.environ["HUGGINGFACEHUB_API_TOKEN"])
|
14 |
+
openai_key = os.environ.get("OPENAI_API_KEY")
|
15 |
|
16 |
search_tool = DuckDuckGoSearchTool()
|
17 |
|
|
|
19 |
log_output = ""
|
20 |
|
21 |
try:
|
22 |
+
|
23 |
+
agent = ToolCallingAgentAgent(
|
24 |
tools=[search_tool],
|
25 |
+
model=InferenceClientModel(
|
26 |
+
model="gpt-3.5-turbo",
|
27 |
+
provider="openai",
|
28 |
+
model_kwargs={
|
29 |
+
"api_key": os.environ.get("OPENAI_API_KEY"),
|
30 |
+
"temperature": 0,
|
31 |
+
"max_tokens": 256
|
32 |
+
}
|
33 |
+
),
|
34 |
+
max_steps=7,
|
35 |
+
verbosity_level=2
|
36 |
)
|
37 |
except Exception as e:
|
38 |
yield f"Error initializing agent: {e}", None, log_output
|