marluwe commited on
Commit
fbe1f2c
·
verified ·
1 Parent(s): 142599f

Update agents.py

Browse files
Files changed (1) hide show
  1. agents.py +4 -33
agents.py CHANGED
@@ -6,7 +6,6 @@ from mcp import StdioServerParameters
6
  from huggingface_hub import HfApi, login
7
  from dotenv import load_dotenv
8
  from typing import Optional
9
- from models.gemini_model import GeminiModel
10
  import requests
11
  import re
12
  import string
@@ -26,7 +25,6 @@ def download_file(task_id: str) -> str:
26
  Args:
27
  task_id: the ID of the task to download the file for.
28
  """
29
- # Implement your file download logic here
30
  data = requests.get(f"{DEFAULT_API_URL}/files/{task_id}")
31
  if data.status_code == 200:
32
  file_path = f"/tmp/{task_id}"
@@ -44,7 +42,6 @@ def get_file_content_as_text(task_id: str) -> str:
44
  Args:
45
  task_id: the ID of the task to get the file content for.
46
  """
47
- # Implement your file content retrieval logic here
48
  data = requests.get(f"{DEFAULT_API_URL}/files/{task_id}")
49
  if data.status_code == 200:
50
  return data.text
@@ -59,12 +56,11 @@ def load_hf_model(modelName: str):
59
  :param modelName: Name of the model
60
  :return: model
61
  """
62
- load_dotenv() # Lädt automatisch .env im Projektordner
63
 
64
  # for local usage, we might use a hf token to log in
65
  # hf_token = os.getenv("hugging_face")
66
- # login(token=hf_token) # Authentifizierung bei Hugging Face
67
- # Modell initialisieren
68
  model = HfApiModel(model_id=modelName)
69
  return model
70
 
@@ -75,7 +71,6 @@ def load_ollama_model(modelName: str):
75
  :param modelName: Name of the model
76
  :return: model (via OpenAI compatible API)
77
  """
78
- # Modell initialisieren
79
  model = OpenAIServerModel(model_id=modelName, api_base="http://localhost:11434/v1")
80
  return model
81
 
@@ -85,21 +80,18 @@ def load_lmStudio_model(modelName: str):
85
  :param modelName: Name of the model
86
  :return: model, accessible through the OpenAI compatible API
87
  """
88
- # Modell initialisieren
89
- #model = LiteLLMModel(model_id=modelName, api_base="http://localhost:1234")
90
  model = OpenAIServerModel(model_id=modelName, api_base="http://localhost:1234/v1")
91
  return model
92
 
93
  def load_gemini_model(model_name: str):
94
  """
95
- Loads
96
  :return: model
97
  """
98
  try:
99
  print(f"Gemini API Key: {os.getenv('GEMINI_API_KEY')}")
100
  model = LiteLLMModel(model_id=f"gemini/{model_name}",
101
  api_key=os.getenv("GEMINI_API_KEY"))
102
- #model = GeminiModel(api_key=os.getenv("GEMINI_API_KEY"))
103
  return model
104
  except Exception as e:
105
  print("Error loading Gemini model:", e)
@@ -108,7 +100,6 @@ def load_gemini_model(model_name: str):
108
 
109
 
110
  def get_agent(model_name:str, model_type:str) -> Optional[CodeAgent]:
111
- # Modell initialisieren
112
 
113
  match model_type:
114
  case "hugging face":
@@ -123,31 +114,11 @@ def get_agent(model_name:str, model_type:str) -> Optional[CodeAgent]:
123
  print("Model type not supported.")
124
  return None
125
 
126
- #model = load_lmStudio_model("gemma-3-4b-it")
127
- #model = load_gemini_model()
128
- #mopip del = HfApiModel()
129
- #model=InferenceClientModel(model_id="meta-llama/Meta-Llama-3.1-8B-Instruct")
130
- #model = TransformersModel(model_id="HuggingFaceTB/SmolLM-135M-Instruct")
131
  # Tools laden
132
  web_search_tool = DuckDuckGoSearchTool()
133
  final_answer_tool = FinalAnswerTool()
134
  visit_webpage_tool = VisitWebpageTool()
135
-
136
- #speech_to_text_tool = SpeechToTextTool()
137
- #transcript_tool = load_tool("maguid28/TranscriptTool", trust_remote_code=True)
138
-
139
- #mcp_tool_collection = ToolCollection.from_mcp(server_parameters, trust_remote_code=True)
140
- #with ToolCollection.from_mcp(server_parameters, trust_remote_code=True) as tool_collection:
141
- # mcp_tool_agent = CodeAgent(tools=[*tool_collection.tools], add_base_tools=True)
142
-
143
- #server_parameters = StdioServerParameters(
144
- # command="uv",
145
- # args=["--quiet", "[email protected]"],
146
- # env={"UV_PYTHON": "3.12", **os.environ},
147
- #)
148
- #
149
- #with ToolCollection.from_mcp(server_parameters, trust_remote_code=True) as tool_collection:
150
- # mcp_agent = CodeAgent(tools=[*tool_collection.tools], model=model, add_base_tools=True)
151
 
152
  variation_agent = CodeAgent(
153
  model=model,
 
6
  from huggingface_hub import HfApi, login
7
  from dotenv import load_dotenv
8
  from typing import Optional
 
9
  import requests
10
  import re
11
  import string
 
25
  Args:
26
  task_id: the ID of the task to download the file for.
27
  """
 
28
  data = requests.get(f"{DEFAULT_API_URL}/files/{task_id}")
29
  if data.status_code == 200:
30
  file_path = f"/tmp/{task_id}"
 
42
  Args:
43
  task_id: the ID of the task to get the file content for.
44
  """
 
45
  data = requests.get(f"{DEFAULT_API_URL}/files/{task_id}")
46
  if data.status_code == 200:
47
  return data.text
 
56
  :param modelName: Name of the model
57
  :return: model
58
  """
59
+ load_dotenv()
60
 
61
  # for local usage, we might use a hf token to log in
62
  # hf_token = os.getenv("hugging_face")
63
+ # login(token=hf_token) # Login at hugging face
 
64
  model = HfApiModel(model_id=modelName)
65
  return model
66
 
 
71
  :param modelName: Name of the model
72
  :return: model (via OpenAI compatible API)
73
  """
 
74
  model = OpenAIServerModel(model_id=modelName, api_base="http://localhost:11434/v1")
75
  return model
76
 
 
80
  :param modelName: Name of the model
81
  :return: model, accessible through the OpenAI compatible API
82
  """
 
 
83
  model = OpenAIServerModel(model_id=modelName, api_base="http://localhost:1234/v1")
84
  return model
85
 
86
  def load_gemini_model(model_name: str):
87
  """
88
+ Loads the gemini model
89
  :return: model
90
  """
91
  try:
92
  print(f"Gemini API Key: {os.getenv('GEMINI_API_KEY')}")
93
  model = LiteLLMModel(model_id=f"gemini/{model_name}",
94
  api_key=os.getenv("GEMINI_API_KEY"))
 
95
  return model
96
  except Exception as e:
97
  print("Error loading Gemini model:", e)
 
100
 
101
 
102
  def get_agent(model_name:str, model_type:str) -> Optional[CodeAgent]:
 
103
 
104
  match model_type:
105
  case "hugging face":
 
114
  print("Model type not supported.")
115
  return None
116
 
 
 
 
 
 
117
  # Tools laden
118
  web_search_tool = DuckDuckGoSearchTool()
119
  final_answer_tool = FinalAnswerTool()
120
  visit_webpage_tool = VisitWebpageTool()
121
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  variation_agent = CodeAgent(
124
  model=model,