fyodorov-llm-agents 0.2.139__py3-none-any.whl → 0.2.140__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.py +16 -12
- fyodorov_llm_agents/tools/mcp_tool.py +20 -7
- {fyodorov_llm_agents-0.2.139.dist-info → fyodorov_llm_agents-0.2.140.dist-info}/METADATA +1 -1
- fyodorov_llm_agents-0.2.140.dist-info/RECORD +8 -0
- {fyodorov_llm_agents-0.2.139.dist-info → fyodorov_llm_agents-0.2.140.dist-info}/WHEEL +1 -1
- fyodorov_llm_agents-0.2.139.dist-info/RECORD +0 -8
- {fyodorov_llm_agents-0.2.139.dist-info → fyodorov_llm_agents-0.2.140.dist-info}/top_level.txt +0 -0
@@ -8,17 +8,20 @@ import yaml
|
|
8
8
|
from pydantic import BaseModel, HttpUrl
|
9
9
|
from openai import OpenAI as oai
|
10
10
|
import litellm
|
11
|
-
from fyodorov_llm_agents.tools.
|
11
|
+
from fyodorov_llm_agents.tools.mcp_tool import MCPTool as Tool
|
12
12
|
|
13
13
|
MAX_NAME_LENGTH = 80
|
14
14
|
MAX_DESCRIPTION_LENGTH = 280
|
15
15
|
VALID_CHARACTERS_REGEX = r'^[a-zA-Z0-9\s.,!?:;\'"-_]+$'
|
16
16
|
|
17
17
|
class Agent(BaseModel):
|
18
|
+
id: Optional[int] = None
|
19
|
+
created_at: Optional[datetime] = None
|
18
20
|
api_key: str | None = None
|
19
21
|
api_url: HttpUrl | None = None
|
20
|
-
tools: [Tool] = []
|
21
|
-
rag: [] = []
|
22
|
+
tools: list[Tool] = []
|
23
|
+
rag: list[dict] = []
|
24
|
+
chat_history: list[dict] = []
|
22
25
|
model: str | None = None
|
23
26
|
modelid: str | None = None
|
24
27
|
name: str = "My Agent"
|
@@ -63,15 +66,16 @@ class Agent(BaseModel):
|
|
63
66
|
return prompt
|
64
67
|
|
65
68
|
def to_dict(self) -> dict:
|
66
|
-
return
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
69
|
+
return self.dict(exclude_none=True)
|
70
|
+
# return {
|
71
|
+
# 'model': self.model,
|
72
|
+
# 'name': self.name,
|
73
|
+
# 'description': self.description,
|
74
|
+
# 'prompt': self.prompt,
|
75
|
+
# 'prompt_size': self.prompt_size,
|
76
|
+
# 'tools': self.tools,
|
77
|
+
# 'rag': self.rag,
|
78
|
+
# }
|
75
79
|
|
76
80
|
def call_with_fn_calling(self, input: str = "", history = []) -> dict:
|
77
81
|
litellm.set_verbose = True
|
@@ -2,12 +2,13 @@ from pydantic import BaseModel, HttpUrl, Field
|
|
2
2
|
from typing import Optional, Dict, Any, Literal
|
3
3
|
import re
|
4
4
|
from datetime import datetime
|
5
|
+
import yaml
|
5
6
|
|
6
7
|
APIUrlTypes = Literal['openapi']
|
7
8
|
|
8
9
|
# Example regex for validating textual fields; adjust as needed
|
9
10
|
VALID_CHARACTERS_REGEX = r'^[a-zA-Z0-9\s.,!?:;\'"\-_]+$'
|
10
|
-
|
11
|
+
MAX_NAME_LENGTH = 80
|
11
12
|
MAX_DESCRIPTION_LENGTH = 1000
|
12
13
|
|
13
14
|
class MCPTool(BaseModel):
|
@@ -19,7 +20,7 @@ class MCPTool(BaseModel):
|
|
19
20
|
created_at: Optional[datetime] = None # timestamptz
|
20
21
|
updated_at: Optional[datetime] = None # timestamptz
|
21
22
|
|
22
|
-
|
23
|
+
name: Optional[str] = Field(..., max_length=MAX_NAME_LENGTH)
|
23
24
|
handle: Optional[str] = None
|
24
25
|
description: Optional[str] = Field(None, max_length=MAX_DESCRIPTION_LENGTH)
|
25
26
|
logo_url: Optional[str] = None # stored as text; could be a URL
|
@@ -36,13 +37,13 @@ class MCPTool(BaseModel):
|
|
36
37
|
|
37
38
|
# Example validations below. Adjust/extend to fit your needs.
|
38
39
|
|
39
|
-
def
|
40
|
+
def validate(self) -> bool:
|
40
41
|
"""
|
41
42
|
Run custom validations on the model fields.
|
42
43
|
Returns True if all validations pass, otherwise raises ValueError.
|
43
44
|
"""
|
44
|
-
if self.
|
45
|
-
self.
|
45
|
+
if self.name:
|
46
|
+
self._validate_name(self.name)
|
46
47
|
if self.description:
|
47
48
|
self._validate_description(self.description)
|
48
49
|
if self.api_url:
|
@@ -53,9 +54,9 @@ class MCPTool(BaseModel):
|
|
53
54
|
return True
|
54
55
|
|
55
56
|
@staticmethod
|
56
|
-
def
|
57
|
+
def _validate_name(name: str) -> None:
|
57
58
|
if not re.match(VALID_CHARACTERS_REGEX, name):
|
58
|
-
raise ValueError("
|
59
|
+
raise ValueError("name contains invalid characters.")
|
59
60
|
|
60
61
|
@staticmethod
|
61
62
|
def _validate_description(description: str) -> None:
|
@@ -67,6 +68,18 @@ class MCPTool(BaseModel):
|
|
67
68
|
if not HttpUrl.validate(url):
|
68
69
|
raise ValueError("{url} is not a valid URL.")
|
69
70
|
|
71
|
+
@staticmethod
|
72
|
+
def from_yaml(yaml_str: str):
|
73
|
+
"""Instantiate Tool from YAML."""
|
74
|
+
if not yaml_str:
|
75
|
+
raise ValueError('YAML string is required')
|
76
|
+
tool_dict = yaml.safe_load(yaml_str)
|
77
|
+
if not isinstance(tool_dict, dict):
|
78
|
+
raise ValueError('YAML string must represent a dictionary')
|
79
|
+
tool = MCPTool(**tool_dict)
|
80
|
+
tool.validate()
|
81
|
+
return tool
|
82
|
+
|
70
83
|
def to_dict(self) -> dict:
|
71
84
|
"""
|
72
85
|
Convert this Pydantic model to a plain dict (e.g., for inserting into Supabase).
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fyodorov_llm_agents
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.140
|
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,8 @@
|
|
1
|
+
fyodorov_llm_agents/agents/agent.py,sha256=jC-xHJFcCKcCpgF4oL0tWEIwg4fYPf5E0TQnUP2NL6w,6758
|
2
|
+
fyodorov_llm_agents/agents/openai.py,sha256=FA5RS7yn3JwvFA8PXju60XSYC_2oUZFNgBUzeIYtGv0,1154
|
3
|
+
fyodorov_llm_agents/tools/mcp_tool.py,sha256=QRKtja2tYcmcNYFL-1bXfYLo0w7FPSmBCJCgTDmiUYE,3197
|
4
|
+
fyodorov_llm_agents/tools/tool.py,sha256=HyOk0X_3XE23sa8J-8UZx657tJ0sxwZWMbA4OPxXU6E,7940
|
5
|
+
fyodorov_llm_agents-0.2.140.dist-info/METADATA,sha256=Rc_5DnBA3HjdhquMqh8zE3JQogrUhDp5LUQZwIoa4rM,552
|
6
|
+
fyodorov_llm_agents-0.2.140.dist-info/WHEEL,sha256=lTU6B6eIfYoiQJTZNc-fyaR6BpL6ehTzU3xGYxn2n8k,91
|
7
|
+
fyodorov_llm_agents-0.2.140.dist-info/top_level.txt,sha256=4QOslsBp8Gh7ng25DceA7fHp4KguTIdAxwURz97gH-g,20
|
8
|
+
fyodorov_llm_agents-0.2.140.dist-info/RECORD,,
|
@@ -1,8 +0,0 @@
|
|
1
|
-
fyodorov_llm_agents/agents/agent.py,sha256=W1VkCeKAN7PYabUFlrchmad91P4NFcuqr1rRquwH1hI,6564
|
2
|
-
fyodorov_llm_agents/agents/openai.py,sha256=FA5RS7yn3JwvFA8PXju60XSYC_2oUZFNgBUzeIYtGv0,1154
|
3
|
-
fyodorov_llm_agents/tools/mcp_tool.py,sha256=arRXqaldrJAv9w3mkzZU_lYKOWFYN0LjHF_8yyID7OU,2845
|
4
|
-
fyodorov_llm_agents/tools/tool.py,sha256=HyOk0X_3XE23sa8J-8UZx657tJ0sxwZWMbA4OPxXU6E,7940
|
5
|
-
fyodorov_llm_agents-0.2.139.dist-info/METADATA,sha256=PjwZ4jRUpuRWMftCG3RZeyIyIfeuBd3i4zGlsedPbdg,552
|
6
|
-
fyodorov_llm_agents-0.2.139.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
7
|
-
fyodorov_llm_agents-0.2.139.dist-info/top_level.txt,sha256=4QOslsBp8Gh7ng25DceA7fHp4KguTIdAxwURz97gH-g,20
|
8
|
-
fyodorov_llm_agents-0.2.139.dist-info/RECORD,,
|
{fyodorov_llm_agents-0.2.139.dist-info → fyodorov_llm_agents-0.2.140.dist-info}/top_level.txt
RENAMED
File without changes
|