Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,13 +50,32 @@ wiki_tool = WikipediaTool()
|
|
| 50 |
tools = [audio_tool, image_tool, wiki_tool]
|
| 51 |
|
| 52 |
# Define the custom agent using Mixtral on Hugging Face
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
class MyAgent(CodeAgent):
|
| 54 |
def __init__(self):
|
| 55 |
model = HfApiModel(
|
| 56 |
api_url="https://api-inference.huggingface.com/models/mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 57 |
api_key=os.getenv("HF_API_TOKEN")
|
| 58 |
)
|
| 59 |
-
super().__init__(model=model, tools=tools
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
# Evaluation + Submission function
|
| 62 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|
|
|
|
| 50 |
tools = [audio_tool, image_tool, wiki_tool]
|
| 51 |
|
| 52 |
# Define the custom agent using Mixtral on Hugging Face
|
| 53 |
+
#class MyAgent(CodeAgent):
|
| 54 |
+
# def __init__(self):
|
| 55 |
+
# model = HfApiModel(
|
| 56 |
+
# api_url="https://api-inference.huggingface.com/models/mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 57 |
+
# api_key=os.getenv("HF_API_TOKEN")
|
| 58 |
+
# )
|
| 59 |
+
# super().__init__(model=model, tools=tools, system_prompt=SYSTEM_PROMPT)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
|
| 63 |
class MyAgent(CodeAgent):
|
| 64 |
def __init__(self):
|
| 65 |
model = HfApiModel(
|
| 66 |
api_url="https://api-inference.huggingface.com/models/mistralai/Mixtral-8x7B-Instruct-v0.1",
|
| 67 |
api_key=os.getenv("HF_API_TOKEN")
|
| 68 |
)
|
| 69 |
+
super().__init__(model=model, tools=tools)
|
| 70 |
+
|
| 71 |
+
def __call__(self, question_dict):
|
| 72 |
+
question = question_dict.get("question", "")
|
| 73 |
+
full_prompt = SYSTEM_PROMPT + "\n\n" + question
|
| 74 |
+
# Pass a new dict with the full prompt, adjust key if your agent expects differently
|
| 75 |
+
new_input = question_dict.copy()
|
| 76 |
+
new_input["question"] = full_prompt
|
| 77 |
+
return super().__call__(new_input)
|
| 78 |
+
|
| 79 |
|
| 80 |
# Evaluation + Submission function
|
| 81 |
def run_and_submit_all(profile: gr.OAuthProfile | None):
|