fyodorov-llm-agents 0.4.15__py3-none-any.whl → 0.4.17__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.
@@ -72,15 +72,27 @@ class Agent(AgentModel):
72
72
  raise e
73
73
 
74
74
  @staticmethod
75
- async def get_all_in_db(limit: int = 10, created_at_lt: datetime = datetime.now()) -> [dict]:
75
+ async def get_all_in_db(limit: int = 10, created_at_lt: datetime = datetime.now(), user_id: str = None) -> list[AgentModel]:
76
76
  try:
77
- result = supabase.from_('agents') \
78
- .select("*") \
79
- .limit(limit) \
80
- .lt('created_at', created_at_lt) \
81
- .order('created_at', desc=True) \
82
- .execute()
83
- agents = result.data
77
+ supabase = get_supabase()
78
+ if user_id:
79
+ result = supabase.from_('agents') \
80
+ .select("*") \
81
+ .eq('user_id', user_id) \
82
+ .limit(limit) \
83
+ .lt('created_at', created_at_lt) \
84
+ .order('created_at', desc=True) \
85
+ .execute()
86
+ else:
87
+ result = supabase.from_('agents') \
88
+ .select("*") \
89
+ .limit(limit) \
90
+ .lt('created_at', created_at_lt) \
91
+ .order('created_at', desc=True) \
92
+ .execute()
93
+ if not result.data:
94
+ return []
95
+ agents = [AgentModel(**agent) for agent in result.data]
84
96
  print(f"Fetched agents: {agents}")
85
97
  return agents
86
98
  except Exception as e:
@@ -149,14 +149,26 @@ class Instance(InstanceModel):
149
149
  raise e
150
150
 
151
151
  @staticmethod
152
- def get_all_in_db(limit: int = 10, created_at_lt: datetime = datetime.now()) -> [InstanceModel]:
152
+ def get_all_in_db(limit: int = 10, created_at_lt: datetime = datetime.now(), user_id: str = None) -> list[InstanceModel]:
153
153
  try:
154
- result = supabase.from_('instances') \
155
- .select("*") \
156
- .limit(limit) \
157
- .lt('created_at', created_at_lt) \
158
- .order('created_at', desc=True) \
159
- .execute()
154
+ supabase = get_supabase()
155
+ if user_id:
156
+ result = supabase.from_('instances') \
157
+ .select("*") \
158
+ .eq('user_id', user_id) \
159
+ .limit(limit) \
160
+ .lt('created_at', created_at_lt) \
161
+ .order('created_at', desc=True) \
162
+ .execute()
163
+ else:
164
+ result = supabase.from_('instances') \
165
+ .select("*") \
166
+ .limit(limit) \
167
+ .lt('created_at', created_at_lt) \
168
+ .order('created_at', desc=True) \
169
+ .execute()
170
+ if not result.data:
171
+ return []
160
172
  instance_models = [InstanceModel(**{k: str(v) if not isinstance(v, list) else v for k, v in instance.items()}) for instance in result.data]
161
173
  return instance_models
162
174
  except Exception as e:
@@ -78,17 +78,28 @@ class LLM(LLMModel):
78
78
  raise e
79
79
 
80
80
  @staticmethod
81
- async def get_models(limit: int = 10, created_at_lt: datetime = datetime.now()) -> [dict]:
81
+ async def get_models(limit: int = 10, created_at_lt: datetime = datetime.now(), user_id: str = None) -> list[LLMModel]:
82
82
  try:
83
- result = supabase.table('models') \
84
- .select('*') \
85
- .order('created_at', desc=True) \
86
- .limit(limit) \
87
- .lt('created_at', created_at_lt) \
88
- .execute()
89
- data = result.data
90
- print('Fetched models', data)
91
- return data
83
+ if user_id:
84
+ result = supabase.table('models') \
85
+ .select('*') \
86
+ .eq('user_id', user_id) \
87
+ .order('created_at', desc=True) \
88
+ .limit(limit) \
89
+ .lt('created_at', created_at_lt) \
90
+ .execute()
91
+ data = result.data
92
+ else:
93
+ result = supabase.table('models') \
94
+ .select('*') \
95
+ .order('created_at', desc=True) \
96
+ .limit(limit) \
97
+ .lt('created_at', created_at_lt) \
98
+ .execute()
99
+ data = result.data
100
+ models = [LLMModel(**model) for model in data]
101
+ print('Fetched models', models)
102
+ return models
92
103
  except Exception as e:
93
104
  print('Error fetching models', str(e))
94
105
  raise e
@@ -122,17 +122,28 @@ class Provider(ProviderModel):
122
122
  return provider
123
123
 
124
124
  @staticmethod
125
- async def get_providers(limit: int = 10, created_at_lt: datetime = datetime.now()) -> [dict]:
125
+ async def get_providers(limit: int = 10, created_at_lt: datetime = datetime.now(), user_id: str = None) -> list[dict]:
126
126
  try:
127
- result = supabase.table('providers') \
128
- .select('*') \
129
- .order('created_at', desc=True) \
130
- .limit(limit) \
131
- .lt('created_at', created_at_lt) \
132
- .execute()
133
- data = result.data
134
- print('Fetched providers', data)
135
- return data
127
+ if user_id:
128
+ result = supabase.table('providers') \
129
+ .select('*') \
130
+ .eq('user_id', user_id) \
131
+ .order('created_at', desc=True) \
132
+ .limit(limit) \
133
+ .lt('created_at', created_at_lt) \
134
+ .execute()
135
+ data = result.data
136
+ else:
137
+ result = supabase.table('providers') \
138
+ .select('*') \
139
+ .order('created_at', desc=True) \
140
+ .limit(limit) \
141
+ .lt('created_at', created_at_lt) \
142
+ .execute()
143
+ data = result.data
144
+ providers = [ProviderModel(**provider) for provider in data]
145
+ print('Fetched providers', providers)
146
+ return providers
136
147
  except Exception as e:
137
148
  print('Error fetching providers', str(e))
138
149
  raise e
@@ -5,7 +5,7 @@ from .mcp_tool_model import MCPTool as ToolModel
5
5
  class MCPTool():
6
6
 
7
7
  @staticmethod
8
- async def create_or_update_in_db(access_token: str, tool: ToolModel, user_id: str) -> str:
8
+ async def create_or_update_in_db(access_token: str, tool: ToolModel, user_id: str) -> ToolModel:
9
9
  print(f"Creating or updating tool with handle {tool.handle} for user {user_id}")
10
10
  tool_w_id = await MCPTool.get_by_name_and_user_id(access_token, tool.handle, user_id)
11
11
  if tool_w_id:
@@ -16,7 +16,7 @@ class MCPTool():
16
16
  return await MCPTool.create_in_db(access_token, tool, user_id)
17
17
 
18
18
  @staticmethod
19
- async def create_in_db(access_token: str, tool: ToolModel, user_id: str) -> str:
19
+ async def create_in_db(access_token: str, tool: ToolModel, user_id: str) -> ToolModel:
20
20
  try:
21
21
  supabase = get_supabase(access_token)
22
22
  tool_dict = tool.to_dict()
@@ -30,14 +30,15 @@ class MCPTool():
30
30
  print('creating tool in db', tool_dict)
31
31
  result = supabase.table('mcp_tools').insert(tool_dict).execute()
32
32
  print('created tool in db', result)
33
- tool_id = result.data[0]['id']
34
- return tool_id
33
+ tool_dict = result.data[0]
34
+ tool = ToolModel(**tool_dict)
35
+ return tool
35
36
  except Exception as e:
36
37
  print('Error creating tool', str(e))
37
38
  raise e
38
39
 
39
40
  @staticmethod
40
- async def update_in_db(access_token: str, id: str, tool: ToolModel) -> dict:
41
+ async def update_in_db(access_token: str, id: str, tool: ToolModel) -> ToolModel:
41
42
  if not id:
42
43
  raise ValueError('Tool ID is required')
43
44
  try:
@@ -45,7 +46,9 @@ class MCPTool():
45
46
  tool_dict = tool.to_dict()
46
47
  print('updating tool in db', tool_dict)
47
48
  result = supabase.table('mcp_tools').update(tool_dict).eq('id', id).execute()
48
- return result.data[0]
49
+ tool_dict = result.data[0]
50
+ tool = ToolModel(**tool_dict)
51
+ return tool
49
52
  except Exception as e:
50
53
  print('An error occurred while updating tool:', id, str(e))
51
54
  raise
@@ -96,17 +99,26 @@ class MCPTool():
96
99
  raise e
97
100
 
98
101
  @staticmethod
99
- async def get_all_in_db(access_token: str, user_id: str = None, limit: int = 10, created_at_lt: datetime = datetime.now()) -> list[dict]:
102
+ async def get_all_in_db(access_token: str, limit: int = 10, created_at_lt: datetime = datetime.now(), user_id: str = None) -> list[ToolModel]:
100
103
  try:
101
104
  supabase = get_supabase(access_token)
102
105
  print('getting tools from db for user', user_id)
103
106
  tools = []
104
- result = supabase.from_('mcp_tools') \
105
- .select("*") \
106
- .limit(limit) \
107
- .lt('created_at', created_at_lt) \
108
- .order('created_at', desc=True) \
109
- .execute()
107
+ if user_id:
108
+ result = supabase.from_('mcp_tools') \
109
+ .select("*") \
110
+ .eq('user_id', user_id) \
111
+ .limit(limit) \
112
+ .lt('created_at', created_at_lt) \
113
+ .order('created_at', desc=True) \
114
+ .execute()
115
+ else:
116
+ result = supabase.from_('mcp_tools') \
117
+ .select("*") \
118
+ .limit(limit) \
119
+ .lt('created_at', created_at_lt) \
120
+ .order('created_at', desc=True) \
121
+ .execute()
110
122
  for tool in result.data:
111
123
  tool["id"] = str(tool["id"])
112
124
  tool["user_id"] = str(tool["user_id"])
@@ -114,7 +126,11 @@ class MCPTool():
114
126
  tool["updated_at"] = str(tool["updated_at"])
115
127
  if tool and (tool['public'] == True or (user_id and 'user_id' in tool and tool['user_id'] == user_id)):
116
128
  print('tool is public or belongs to user', tool)
117
- tools.append(tool)
129
+ tool_model = ToolModel(**tool)
130
+ if tool_model.validate():
131
+ tools.append(tool_model)
132
+ else:
133
+ print(f"Invalid tool data: {tool}")
118
134
  print('got tools from db', len(tools))
119
135
  return tools
120
136
  except Exception as e:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fyodorov_llm_agents
3
- Version: 0.4.15
3
+ Version: 0.4.17
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
@@ -0,0 +1,16 @@
1
+ fyodorov_llm_agents/agents/agent_model.py,sha256=UN8KJvPWsoiatBM3Pw0X8bt0G0pGJeEf4vOTMBITnKU,6839
2
+ fyodorov_llm_agents/agents/agent_service.py,sha256=qm3oGtgrbTV3LfmVYTIrZDs4GwmghdRAxxb3gkrS2i4,6553
3
+ fyodorov_llm_agents/agents/openai.py,sha256=FA5RS7yn3JwvFA8PXju60XSYC_2oUZFNgBUzeIYtGv0,1154
4
+ fyodorov_llm_agents/instances/instance_model.py,sha256=PQaoVSH9H4qp_wcLvyT_QgvNtwf9oehOxZaGI6mv1bA,1206
5
+ fyodorov_llm_agents/instances/instance_service.py,sha256=MNUJTKQnt62GiRpyBmGWJSht96ERchEVBlRamnAQv3s,8967
6
+ fyodorov_llm_agents/models/llm_model.py,sha256=aQtXtB7kRpnVdbPu-nmTGAaflbtKz3DPkgcckf1srsg,1645
7
+ fyodorov_llm_agents/models/llm_service.py,sha256=L_YxZIotlPea0ymUfYXY24rdnCuZdOZEMTDrh8J_BAM,4562
8
+ fyodorov_llm_agents/providers/provider_model.py,sha256=OyCK6WMRhyElsp88gILg0wso-OPHI7f55gEeypsJ7O0,957
9
+ fyodorov_llm_agents/providers/provider_service.py,sha256=-TUItGF8vD6Ndp6SbWVTH6IcavO04k8UsiYXHkHAlZQ,6438
10
+ fyodorov_llm_agents/tools/mcp_tool_model.py,sha256=nGdPmqSkA7hqDUTPbNCZAHNSVJCgVOs5dzJfPntLidI,5110
11
+ fyodorov_llm_agents/tools/mcp_tool_service.py,sha256=nOWeCXFP8t7pbFL4Co70c7ukEEl-TQbb1pnPHlG5Tac,7677
12
+ fyodorov_llm_agents/tools/tool.py,sha256=HyOk0X_3XE23sa8J-8UZx657tJ0sxwZWMbA4OPxXU6E,7940
13
+ fyodorov_llm_agents-0.4.17.dist-info/METADATA,sha256=9oSARobZSeTyth0gf0yriLdc4nNmM81CEyFhW7p8MUU,551
14
+ fyodorov_llm_agents-0.4.17.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
15
+ fyodorov_llm_agents-0.4.17.dist-info/top_level.txt,sha256=4QOslsBp8Gh7ng25DceA7fHp4KguTIdAxwURz97gH-g,20
16
+ fyodorov_llm_agents-0.4.17.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- fyodorov_llm_agents/agents/agent_model.py,sha256=UN8KJvPWsoiatBM3Pw0X8bt0G0pGJeEf4vOTMBITnKU,6839
2
- fyodorov_llm_agents/agents/agent_service.py,sha256=-55RDait3eZGFfYWGNLGoa06WMcdiBnkzpa7BnWW10Q,6016
3
- fyodorov_llm_agents/agents/openai.py,sha256=FA5RS7yn3JwvFA8PXju60XSYC_2oUZFNgBUzeIYtGv0,1154
4
- fyodorov_llm_agents/instances/instance_model.py,sha256=PQaoVSH9H4qp_wcLvyT_QgvNtwf9oehOxZaGI6mv1bA,1206
5
- fyodorov_llm_agents/instances/instance_service.py,sha256=QolwEosIH5MEVNdAcmPa4pB3cuDyygvOdNFIERRLquc,8468
6
- fyodorov_llm_agents/models/llm_model.py,sha256=aQtXtB7kRpnVdbPu-nmTGAaflbtKz3DPkgcckf1srsg,1645
7
- fyodorov_llm_agents/models/llm_service.py,sha256=35bS0RFXJhJUSjge-v4u5cftn_MT-CmcDuWnC2kCnJo,4008
8
- fyodorov_llm_agents/providers/provider_model.py,sha256=OyCK6WMRhyElsp88gILg0wso-OPHI7f55gEeypsJ7O0,957
9
- fyodorov_llm_agents/providers/provider_service.py,sha256=GST-NLV8aLPsvapQEvgT_qHGYu7IpS5Xsut60XFmD-g,5865
10
- fyodorov_llm_agents/tools/mcp_tool_model.py,sha256=nGdPmqSkA7hqDUTPbNCZAHNSVJCgVOs5dzJfPntLidI,5110
11
- fyodorov_llm_agents/tools/mcp_tool_service.py,sha256=RDFGx_qUibIm-j7GJZf4OZ_CRJAK7-V04JnTWiWshQg,6978
12
- fyodorov_llm_agents/tools/tool.py,sha256=HyOk0X_3XE23sa8J-8UZx657tJ0sxwZWMbA4OPxXU6E,7940
13
- fyodorov_llm_agents-0.4.15.dist-info/METADATA,sha256=Dgm22EVQsBabbiWMyuCrj7fI1ZF9xM7ydIFEpCCLsxQ,551
14
- fyodorov_llm_agents-0.4.15.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
15
- fyodorov_llm_agents-0.4.15.dist-info/top_level.txt,sha256=4QOslsBp8Gh7ng25DceA7fHp4KguTIdAxwURz97gH-g,20
16
- fyodorov_llm_agents-0.4.15.dist-info/RECORD,,