fyodorov-llm-agents 0.4.60__py3-none-any.whl → 0.4.63__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fyodorov_llm_agents/agents/agent_service.py +2 -2
- fyodorov_llm_agents/instances/instance_service.py +1 -1
- fyodorov_llm_agents/tools/mcp_tool_service.py +39 -2
- {fyodorov_llm_agents-0.4.60.dist-info → fyodorov_llm_agents-0.4.63.dist-info}/METADATA +1 -1
- {fyodorov_llm_agents-0.4.60.dist-info → fyodorov_llm_agents-0.4.63.dist-info}/RECORD +7 -7
- {fyodorov_llm_agents-0.4.60.dist-info → fyodorov_llm_agents-0.4.63.dist-info}/WHEEL +1 -1
- {fyodorov_llm_agents-0.4.60.dist-info → fyodorov_llm_agents-0.4.63.dist-info}/top_level.txt +0 -0
@@ -63,11 +63,11 @@ class Agent(AgentModel):
|
|
63
63
|
raise e
|
64
64
|
|
65
65
|
@staticmethod
|
66
|
-
async def get_in_db(
|
66
|
+
async def get_in_db(id: str) -> AgentModel:
|
67
67
|
if not id:
|
68
68
|
raise ValueError('Agent ID is required')
|
69
69
|
try:
|
70
|
-
supabase = get_supabase(
|
70
|
+
supabase = get_supabase()
|
71
71
|
result = supabase.table('agents').select('*').eq('id', id).limit(1).execute()
|
72
72
|
agent_dict = result.data[0]
|
73
73
|
print(f"Fetched agent: {agent_dict}")
|
@@ -18,7 +18,7 @@ JWT = "eyJhbGciOiJIUzI1NiIsImtpZCI6Im14MmVrTllBY3ZYN292LzMiLCJ0eXAiOiJKV1QifQ.ey
|
|
18
18
|
class Instance(InstanceModel):
|
19
19
|
|
20
20
|
async def chat_w_fn_calls(self, input: str = "", access_token: str = JWT, user_id: str = "") -> str:
|
21
|
-
agent: AgentModel = await Agent.get_in_db(
|
21
|
+
agent: AgentModel = await Agent.get_in_db(id = self.agent_id)
|
22
22
|
print(f"Model fetched via LLM.get_model in chat_w_fn_calls: {agent.model}")
|
23
23
|
agent.provider = await Provider.get_provider_by_id(id = agent.model.provider)
|
24
24
|
agent.prompt = f"{agent.prompt}\n\n{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n\n"
|
@@ -1,7 +1,12 @@
|
|
1
1
|
from datetime import datetime
|
2
|
+
import json
|
3
|
+
from typing import Any, Optional
|
4
|
+
|
5
|
+
import requests
|
2
6
|
from fyodorov_utils.config.supabase import get_supabase
|
3
7
|
from .mcp_tool_model import MCPTool as ToolModel
|
4
8
|
|
9
|
+
|
5
10
|
class MCPTool():
|
6
11
|
|
7
12
|
@staticmethod
|
@@ -125,7 +130,7 @@ class MCPTool():
|
|
125
130
|
tool["user_id"] = str(tool["user_id"])
|
126
131
|
tool["created_at"] = str(tool["created_at"])
|
127
132
|
tool["updated_at"] = str(tool["updated_at"])
|
128
|
-
if tool and (tool['public']
|
133
|
+
if tool and (tool['public'] or (user_id and 'user_id' in tool and tool['user_id'] == user_id)):
|
129
134
|
print('tool is public or belongs to user', tool)
|
130
135
|
tool_model = ToolModel(**tool)
|
131
136
|
if tool_model.validate():
|
@@ -169,4 +174,36 @@ class MCPTool():
|
|
169
174
|
return agent_ids
|
170
175
|
except Exception as e:
|
171
176
|
print('Error setting tool agents', str(e))
|
172
|
-
raise
|
177
|
+
raise e
|
178
|
+
|
179
|
+
@staticmethod
|
180
|
+
async def call_mcp_server(id: str, access_token: Optional[str] = None, args: Optional[dict[str, Any]] = None) -> str:
|
181
|
+
"""Invoke an MCP tool via the tool's configured MCP server."""
|
182
|
+
if not id:
|
183
|
+
raise ValueError('Tool ID is required')
|
184
|
+
tool = await MCPTool.get_in_db(access_token, id)
|
185
|
+
if not tool:
|
186
|
+
raise ValueError('Tool not found')
|
187
|
+
if not tool.handle:
|
188
|
+
raise ValueError('Tool handle is required')
|
189
|
+
if not tool.api_url:
|
190
|
+
raise ValueError('Tool api_url is required')
|
191
|
+
|
192
|
+
url = f"{tool.api_url}:call"
|
193
|
+
headers = {'Content-Type': 'application/json'}
|
194
|
+
if access_token:
|
195
|
+
headers['Authorization'] = f'Bearer {access_token}'
|
196
|
+
if args is None:
|
197
|
+
args = {}
|
198
|
+
|
199
|
+
try:
|
200
|
+
print(f"Calling MCP server at {url} with args {args}")
|
201
|
+
response = requests.post(url, headers=headers, json=args, timeout=30)
|
202
|
+
response.raise_for_status()
|
203
|
+
content_type = response.headers.get('Content-Type', '')
|
204
|
+
if 'application/json' in content_type:
|
205
|
+
return json.dumps(response.json())
|
206
|
+
return response.text
|
207
|
+
except requests.RequestException as e:
|
208
|
+
print('Error calling MCP server', str(e))
|
209
|
+
raise e
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fyodorov_llm_agents
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.63
|
4
4
|
Summary: LLM agents for the Fyodorov AI suite
|
5
5
|
Author-email: Daniel Ransom <02masseur.alibis@icloud.com>
|
6
6
|
Project-URL: Homepage, https://github.com/FyodorovAI/fyodorov-llm-agents
|
@@ -1,17 +1,17 @@
|
|
1
1
|
fyodorov_llm_agents/base_model.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
fyodorov_llm_agents/agents/agent_model.py,sha256=JNbRBWtErHnFqlP_ONd0B8Vf3o_AyigHKchsd3COZrk,3899
|
3
|
-
fyodorov_llm_agents/agents/agent_service.py,sha256=
|
3
|
+
fyodorov_llm_agents/agents/agent_service.py,sha256=Exu_-pA4tkC67jv63G27dvAY_oQyih12xKS7TpFrjb4,10302
|
4
4
|
fyodorov_llm_agents/agents/openai.py,sha256=FA5RS7yn3JwvFA8PXju60XSYC_2oUZFNgBUzeIYtGv0,1154
|
5
5
|
fyodorov_llm_agents/instances/instance_model.py,sha256=swRzCXeUk2FFKzGMEjeToklBJRK7GdAJl1ZIoQALuxs,1368
|
6
|
-
fyodorov_llm_agents/instances/instance_service.py,sha256=
|
6
|
+
fyodorov_llm_agents/instances/instance_service.py,sha256=3e9qfBGfd2RydSu8skQhA_PaRiiqWjOt0jyjUTek6a0,8772
|
7
7
|
fyodorov_llm_agents/models/llm_model.py,sha256=9sAM2QbVp62yFxhETii1x4VhZCn3HNwut4wqA9RUABM,1918
|
8
8
|
fyodorov_llm_agents/models/llm_service.py,sha256=t7p8pRExJr-B8MD7KleKNe8YlHZ1geDuqYzbTFo_0MM,4837
|
9
9
|
fyodorov_llm_agents/providers/provider_model.py,sha256=7G0WSPJYGcLIFgyQF0Y-Rv4f37-TMGg7fyeZxrC3fNE,1100
|
10
10
|
fyodorov_llm_agents/providers/provider_service.py,sha256=dbLyi4_sOfciksBgbyf_iViMud93Kzpn23D7-aYIBj8,6761
|
11
11
|
fyodorov_llm_agents/tools/mcp_tool_model.py,sha256=aCJGW1WZoeTX5UVD8K-ljUTf0dxPLpPZphIKZTIuipM,5278
|
12
|
-
fyodorov_llm_agents/tools/mcp_tool_service.py,sha256=
|
12
|
+
fyodorov_llm_agents/tools/mcp_tool_service.py,sha256=dl6svc6ncqpAAQRTP8PM_xGH8EVnoENbvjzi7froT2Y,9089
|
13
13
|
fyodorov_llm_agents/tools/tool.py,sha256=HyOk0X_3XE23sa8J-8UZx657tJ0sxwZWMbA4OPxXU6E,7940
|
14
|
-
fyodorov_llm_agents-0.4.
|
15
|
-
fyodorov_llm_agents-0.4.
|
16
|
-
fyodorov_llm_agents-0.4.
|
17
|
-
fyodorov_llm_agents-0.4.
|
14
|
+
fyodorov_llm_agents-0.4.63.dist-info/METADATA,sha256=EVrnvLi_ZiIrmBjhBiHK1tbk63nm_j7bxTMjfs4Mav0,551
|
15
|
+
fyodorov_llm_agents-0.4.63.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
16
|
+
fyodorov_llm_agents-0.4.63.dist-info/top_level.txt,sha256=4QOslsBp8Gh7ng25DceA7fHp4KguTIdAxwURz97gH-g,20
|
17
|
+
fyodorov_llm_agents-0.4.63.dist-info/RECORD,,
|
File without changes
|