wt002 commited on
Commit
ac6b8be
·
verified ·
1 Parent(s): 454b838

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +36 -0
agent.py CHANGED
@@ -31,6 +31,12 @@ from langchain_community.vectorstores import FAISS
31
  from langchain_community.embeddings import HuggingFaceEmbeddings
32
 
33
 
 
 
 
 
 
 
34
 
35
  load_dotenv()
36
 
@@ -129,6 +135,20 @@ def arvix_search(query: str) -> str:
129
 
130
 
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  # load the system prompt from the file
133
  with open("system_prompt.txt", "r", encoding="utf-8") as f:
134
  system_prompt = f.read()
@@ -137,6 +157,22 @@ with open("system_prompt.txt", "r", encoding="utf-8") as f:
137
  sys_msg = SystemMessage(content=system_prompt)
138
 
139
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
  # -------------------------------
142
  # Step 2: Load the JSON file or tasks (Replace this part if you're loading tasks dynamically)
 
31
  from langchain_community.embeddings import HuggingFaceEmbeddings
32
 
33
 
34
+ from tools import (
35
+ multiply, add, subtract, divide, modulus,
36
+ wiki_search, web_search, arvix_search
37
+ )
38
+
39
+
40
 
41
  load_dotenv()
42
 
 
135
 
136
 
137
 
138
+ # -----------------------------
139
+ # Load configuration from YAML
140
+ # -----------------------------
141
+ with open("config.yaml", "r") as f:
142
+ config = yaml.safe_load(f)
143
+
144
+ provider = config["provider"]
145
+ #prompt_path = config["system_prompt_path"]
146
+ enabled_tool_names = config["tools"]
147
+
148
+
149
+ # -----------------------------
150
+ # Load system prompt
151
+ # -----------------------------
152
  # load the system prompt from the file
153
  with open("system_prompt.txt", "r", encoding="utf-8") as f:
154
  system_prompt = f.read()
 
157
  sys_msg = SystemMessage(content=system_prompt)
158
 
159
 
160
+ # -----------------------------
161
+ # Map tool names to functions
162
+ # -----------------------------
163
+ tool_map = {
164
+ "multiply": multiply,
165
+ "add": add,
166
+ "subtract": subtract,
167
+ "divide": divide,
168
+ "modulus": modulus,
169
+ "wiki_search": wiki_search,
170
+ "web_search": web_search,
171
+ "arvix_search": arvix_search,
172
+ }
173
+
174
+ tools = [tool_map[name] for name in enabled_tool_names]
175
+
176
 
177
  # -------------------------------
178
  # Step 2: Load the JSON file or tasks (Replace this part if you're loading tasks dynamically)