Spaces:
Runtime error
Runtime error
Changed endpoint and brought in hf api key explicitly
Browse files
app.py
CHANGED
|
@@ -30,7 +30,6 @@ def tracked_perplexity_call(prompt: str, system_messages: str, model_name: str =
|
|
| 30 |
stream=False,
|
| 31 |
).choices[0].message.content
|
| 32 |
|
| 33 |
-
# Below is an example of a tool that does nothing. Amaze us with your creativity !
|
| 34 |
@tool
|
| 35 |
def Sonar_Web_Search_Tool(arg1: str, arg2: str) -> str:
|
| 36 |
"""A tool that accesses Perplexity Sonar to search the web when the answer requires or would benefit from a real world web reference.
|
|
@@ -69,11 +68,11 @@ final_answer = FinalAnswerTool()
|
|
| 69 |
model = HfApiModel(
|
| 70 |
max_tokens=2096,
|
| 71 |
temperature=0.5,
|
| 72 |
-
model_id='
|
| 73 |
custom_role_conversions=None,
|
|
|
|
| 74 |
)
|
| 75 |
|
| 76 |
-
|
| 77 |
# Import tool from Hub
|
| 78 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 79 |
|
|
@@ -82,7 +81,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 82 |
|
| 83 |
agent = CodeAgent(
|
| 84 |
model=model,
|
| 85 |
-
tools=[final_answer, Sonar_Web_Search_Tool, get_current_time_in_timezone
|
| 86 |
max_steps=6,
|
| 87 |
verbosity_level=1,
|
| 88 |
grammar=None,
|
|
@@ -92,4 +91,6 @@ agent = CodeAgent(
|
|
| 92 |
prompt_templates=prompt_templates
|
| 93 |
)
|
| 94 |
|
|
|
|
|
|
|
| 95 |
GradioUI(agent).launch()
|
|
|
|
| 30 |
stream=False,
|
| 31 |
).choices[0].message.content
|
| 32 |
|
|
|
|
| 33 |
@tool
|
| 34 |
def Sonar_Web_Search_Tool(arg1: str, arg2: str) -> str:
|
| 35 |
"""A tool that accesses Perplexity Sonar to search the web when the answer requires or would benefit from a real world web reference.
|
|
|
|
| 68 |
model = HfApiModel(
|
| 69 |
max_tokens=2096,
|
| 70 |
temperature=0.5,
|
| 71 |
+
model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud', # Using the backup endpoint
|
| 72 |
custom_role_conversions=None,
|
| 73 |
+
huggingface_api_key=os.getenv("HUGGINGFACE_API_KEY") # Add this line to provide authentication
|
| 74 |
)
|
| 75 |
|
|
|
|
| 76 |
# Import tool from Hub
|
| 77 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 78 |
|
|
|
|
| 81 |
|
| 82 |
agent = CodeAgent(
|
| 83 |
model=model,
|
| 84 |
+
tools=[final_answer, Sonar_Web_Search_Tool, get_current_time_in_timezone],
|
| 85 |
max_steps=6,
|
| 86 |
verbosity_level=1,
|
| 87 |
grammar=None,
|
|
|
|
| 91 |
prompt_templates=prompt_templates
|
| 92 |
)
|
| 93 |
|
| 94 |
+
# To fix the TypeError, modify the Gradio_UI.py file to handle potential None values
|
| 95 |
+
# But for now, we can just use the agent directly
|
| 96 |
GradioUI(agent).launch()
|