dlaima commited on
Commit
8b469fc
·
verified ·
1 Parent(s): 1f2e05e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -24
app.py CHANGED
@@ -38,37 +38,21 @@ wikipedia_tool = WikipediaSearcher()
38
  tools = [audio_tool, image_tool, wikipedia_tool]
39
 
40
  # Define the custom agent using Dolphin model (free Mixtral)
41
- #class MyAgent(CodeAgent):
42
- # def __init__(self):
43
- # model = HfApiModel(
44
- # model="cognitivecomputations/dolphin-2.6-mixtral-8x7b",
45
- # api_key=os.getenv("HF_API_TOKEN", "").strip(),
46
- # system_prompt=SYSTEM_PROMPT
47
- # )
48
- # super().__init__(model=model, tools=tools)
49
-
50
-
51
  class MyAgent(CodeAgent):
52
  def __init__(self):
53
  model = HfApiModel(
54
  model="cognitivecomputations/dolphin-2.6-mixtral-8x7b",
55
- api_key=os.getenv("HF_API_TOKEN", "").strip()
 
56
  )
57
  super().__init__(model=model, tools=tools)
58
- self.system_prompt = SYSTEM_PROMPT
59
-
60
- def __call__(self, task):
61
- # Inject system prompt manually
62
- if isinstance(task, dict):
63
- if "question" in task:
64
- task["messages"] = [
65
- {"role": "system", "content": self.system_prompt},
66
- {"role": "user", "content": task["question"]}
67
- ]
68
- elif "messages" in task:
69
- task["messages"].insert(0, {"role": "system", "content": self.system_prompt})
70
- return super().__call__(task)
71
 
 
 
 
 
 
 
72
 
73
  # Evaluation + Submission function
74
  def run_and_submit_all(profile: gr.OAuthProfile | None):
 
38
  tools = [audio_tool, image_tool, wikipedia_tool]
39
 
40
  # Define the custom agent using Dolphin model (free Mixtral)
 
 
 
 
 
 
 
 
 
 
41
  class MyAgent(CodeAgent):
42
  def __init__(self):
43
  model = HfApiModel(
44
  model="cognitivecomputations/dolphin-2.6-mixtral-8x7b",
45
+ api_key=os.getenv("HF_API_TOKEN", "").strip(),
46
+ # No system_prompt here
47
  )
48
  super().__init__(model=model, tools=tools)
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ def __call__(self, question_dict):
51
+ system_message = {"role": "system", "content": SYSTEM_PROMPT}
52
+ user_message = {"role": "user", "content": question_dict.get("question", "")}
53
+ messages = [system_message, user_message]
54
+ # Pass messages directly in the call
55
+ return self.model(messages)
56
 
57
  # Evaluation + Submission function
58
  def run_and_submit_all(profile: gr.OAuthProfile | None):