Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
import os
|
|
|
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
import requests
|
| 4 |
import inspect
|
|
@@ -86,7 +88,7 @@ image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_co
|
|
| 86 |
class BasicAgent:
|
| 87 |
def __init__(self):
|
| 88 |
print("BasicAgent initialized.")
|
| 89 |
-
os.environ["
|
| 90 |
self.system_prompt= """You are a helpful assistant. You will answer questions based on the provided context.You will always return a valid answer, even if the question is not clear or the context is insufficient. If you cannot answer, return a default answer.Always return a valid answer after validating the source.
|
| 91 |
Always return the answer in the following format:
|
| 92 |
"ANSWER: <your answer here>".
|
|
@@ -140,11 +142,12 @@ class BasicAgent:
|
|
| 140 |
If you are not able to find the answer using the tools privided, you can use the web_search tool.
|
| 141 |
If you are given a task to create an image,you can use the image_generation_tool.
|
| 142 |
"""
|
|
|
|
| 143 |
model = InferenceClientModel(
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
self.agent= CodeAgent(
|
| 149 |
tools = [add, subtract, multiply, divide, web_search, image_generation_tool],
|
| 150 |
model=model,
|
|
|
|
| 1 |
import os
|
| 2 |
+
from dotenv import load_dotenv
|
| 3 |
+
load_dotenv()
|
| 4 |
import gradio as gr
|
| 5 |
import requests
|
| 6 |
import inspect
|
|
|
|
| 88 |
class BasicAgent:
|
| 89 |
def __init__(self):
|
| 90 |
print("BasicAgent initialized.")
|
| 91 |
+
token = os.environ["HF_TOKEN"] # Set your Hugging Face token in the environment
|
| 92 |
self.system_prompt= """You are a helpful assistant. You will answer questions based on the provided context.You will always return a valid answer, even if the question is not clear or the context is insufficient. If you cannot answer, return a default answer.Always return a valid answer after validating the source.
|
| 93 |
Always return the answer in the following format:
|
| 94 |
"ANSWER: <your answer here>".
|
|
|
|
| 142 |
If you are not able to find the answer using the tools privided, you can use the web_search tool.
|
| 143 |
If you are given a task to create an image,you can use the image_generation_tool.
|
| 144 |
"""
|
| 145 |
+
|
| 146 |
model = InferenceClientModel(
|
| 147 |
+
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 148 |
+
token=token, # Set your Hugging Face token in the environment
|
| 149 |
+
provider="huggingface"
|
| 150 |
+
)
|
| 151 |
self.agent= CodeAgent(
|
| 152 |
tools = [add, subtract, multiply, divide, web_search, image_generation_tool],
|
| 153 |
model=model,
|