signalwire-agents 0.1.9__py3-none-any.whl → 0.1.11__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.
- signalwire_agents/__init__.py +39 -4
- signalwire_agents/agent_server.py +46 -2
- signalwire_agents/cli/__init__.py +9 -0
- signalwire_agents/cli/test_swaig.py +2545 -0
- signalwire_agents/core/agent_base.py +691 -82
- signalwire_agents/core/contexts.py +289 -0
- signalwire_agents/core/data_map.py +499 -0
- signalwire_agents/core/function_result.py +57 -10
- signalwire_agents/core/skill_base.py +31 -1
- signalwire_agents/core/skill_manager.py +89 -23
- signalwire_agents/core/swaig_function.py +13 -1
- signalwire_agents/core/swml_handler.py +37 -13
- signalwire_agents/core/swml_service.py +37 -28
- signalwire_agents/skills/datasphere/__init__.py +12 -0
- signalwire_agents/skills/datasphere/skill.py +229 -0
- signalwire_agents/skills/datasphere_serverless/__init__.py +1 -0
- signalwire_agents/skills/datasphere_serverless/skill.py +156 -0
- signalwire_agents/skills/datetime/skill.py +7 -3
- signalwire_agents/skills/joke/__init__.py +1 -0
- signalwire_agents/skills/joke/skill.py +88 -0
- signalwire_agents/skills/math/skill.py +8 -5
- signalwire_agents/skills/registry.py +23 -4
- signalwire_agents/skills/web_search/skill.py +58 -33
- signalwire_agents/skills/wikipedia/__init__.py +9 -0
- signalwire_agents/skills/wikipedia/skill.py +180 -0
- signalwire_agents/utils/__init__.py +2 -0
- signalwire_agents/utils/schema_utils.py +111 -44
- signalwire_agents/utils/serverless.py +38 -0
- signalwire_agents-0.1.11.dist-info/METADATA +756 -0
- signalwire_agents-0.1.11.dist-info/RECORD +58 -0
- {signalwire_agents-0.1.9.dist-info → signalwire_agents-0.1.11.dist-info}/WHEEL +1 -1
- signalwire_agents-0.1.11.dist-info/entry_points.txt +2 -0
- signalwire_agents-0.1.9.dist-info/METADATA +0 -311
- signalwire_agents-0.1.9.dist-info/RECORD +0 -44
- {signalwire_agents-0.1.9.data → signalwire_agents-0.1.11.data}/data/schema.json +0 -0
- {signalwire_agents-0.1.9.dist-info → signalwire_agents-0.1.11.dist-info}/licenses/LICENSE +0 -0
- {signalwire_agents-0.1.9.dist-info → signalwire_agents-0.1.11.dist-info}/top_level.txt +0 -0
signalwire_agents/__init__.py
CHANGED
@@ -14,16 +14,51 @@ SignalWire AI Agents SDK
|
|
14
14
|
A package for building AI agents using SignalWire's AI and SWML capabilities.
|
15
15
|
"""
|
16
16
|
|
17
|
-
__version__ = "0.1.
|
17
|
+
__version__ = "0.1.11"
|
18
18
|
|
19
19
|
# Import core classes for easier access
|
20
|
-
from
|
20
|
+
from .core.agent_base import AgentBase
|
21
|
+
from .core.contexts import ContextBuilder, Context, Step, create_simple_context
|
22
|
+
from .core.data_map import DataMap, create_simple_api_tool, create_expression_tool
|
23
|
+
from .core.state import StateManager, FileStateManager
|
21
24
|
from signalwire_agents.agent_server import AgentServer
|
22
25
|
from signalwire_agents.core.swml_service import SWMLService
|
23
26
|
from signalwire_agents.core.swml_builder import SWMLBuilder
|
24
|
-
from signalwire_agents.core.
|
27
|
+
from signalwire_agents.core.function_result import SwaigFunctionResult
|
28
|
+
from signalwire_agents.core.swaig_function import SWAIGFunction
|
25
29
|
|
26
30
|
# Import skills to trigger discovery
|
27
31
|
import signalwire_agents.skills
|
28
32
|
|
29
|
-
|
33
|
+
# Import convenience functions from the CLI (if available)
|
34
|
+
try:
|
35
|
+
from signalwire_agents.cli.helpers import start_agent, run_agent, list_skills
|
36
|
+
except ImportError:
|
37
|
+
# CLI helpers not available, define minimal versions
|
38
|
+
def start_agent(*args, **kwargs):
|
39
|
+
raise NotImplementedError("CLI helpers not available")
|
40
|
+
def run_agent(*args, **kwargs):
|
41
|
+
raise NotImplementedError("CLI helpers not available")
|
42
|
+
def list_skills(*args, **kwargs):
|
43
|
+
raise NotImplementedError("CLI helpers not available")
|
44
|
+
|
45
|
+
__all__ = [
|
46
|
+
"AgentBase",
|
47
|
+
"AgentServer",
|
48
|
+
"SWMLService",
|
49
|
+
"SWMLBuilder",
|
50
|
+
"StateManager",
|
51
|
+
"FileStateManager",
|
52
|
+
"SwaigFunctionResult",
|
53
|
+
"SWAIGFunction",
|
54
|
+
"DataMap",
|
55
|
+
"create_simple_api_tool",
|
56
|
+
"create_expression_tool",
|
57
|
+
"ContextBuilder",
|
58
|
+
"Context",
|
59
|
+
"Step",
|
60
|
+
"create_simple_context",
|
61
|
+
"start_agent",
|
62
|
+
"run_agent",
|
63
|
+
"list_skills"
|
64
|
+
]
|
@@ -66,7 +66,8 @@ class AgentServer:
|
|
66
66
|
self.app = FastAPI(
|
67
67
|
title="SignalWire AI Agents",
|
68
68
|
description="Hosted SignalWire AI Agents",
|
69
|
-
version="0.1.2"
|
69
|
+
version="0.1.2",
|
70
|
+
redirect_slashes=False
|
70
71
|
)
|
71
72
|
|
72
73
|
# Keep track of registered agents
|
@@ -105,7 +106,8 @@ class AgentServer:
|
|
105
106
|
# Store the agent
|
106
107
|
self.agents[route] = agent
|
107
108
|
|
108
|
-
# Get the router and register it
|
109
|
+
# Get the router and register it using the standard approach
|
110
|
+
# The agent's router already handles both trailing slash versions properly
|
109
111
|
router = agent.as_router()
|
110
112
|
self.app.include_router(router, prefix=route)
|
111
113
|
|
@@ -322,6 +324,48 @@ class AgentServer:
|
|
322
324
|
"routes": list(self.agents.keys())
|
323
325
|
}
|
324
326
|
|
327
|
+
# Add catch-all route handler to handle both trailing slash and non-trailing slash versions
|
328
|
+
@self.app.get("/{full_path:path}")
|
329
|
+
@self.app.post("/{full_path:path}")
|
330
|
+
async def handle_all_routes(request: Request, full_path: str):
|
331
|
+
"""Handle requests that don't match registered routes (e.g. /matti instead of /matti/)"""
|
332
|
+
# Check if this path maps to one of our registered agents
|
333
|
+
for route, agent in self.agents.items():
|
334
|
+
# Check for exact match with registered route
|
335
|
+
if full_path == route.lstrip("/"):
|
336
|
+
# This is a request to an agent's root without trailing slash
|
337
|
+
return await agent._handle_root_request(request)
|
338
|
+
elif full_path.startswith(route.lstrip("/") + "/"):
|
339
|
+
# This is a request to an agent's sub-path
|
340
|
+
relative_path = full_path[len(route.lstrip("/")):]
|
341
|
+
relative_path = relative_path.lstrip("/")
|
342
|
+
|
343
|
+
# Route to appropriate handler based on path
|
344
|
+
if not relative_path or relative_path == "/":
|
345
|
+
return await agent._handle_root_request(request)
|
346
|
+
|
347
|
+
clean_path = relative_path.rstrip("/")
|
348
|
+
if clean_path == "debug":
|
349
|
+
return await agent._handle_debug_request(request)
|
350
|
+
elif clean_path == "swaig":
|
351
|
+
from fastapi import Response
|
352
|
+
return await agent._handle_swaig_request(request, Response())
|
353
|
+
elif clean_path == "post_prompt":
|
354
|
+
return await agent._handle_post_prompt_request(request)
|
355
|
+
elif clean_path == "check_for_input":
|
356
|
+
return await agent._handle_check_for_input_request(request)
|
357
|
+
|
358
|
+
# Check for custom routing callbacks
|
359
|
+
if hasattr(agent, '_routing_callbacks'):
|
360
|
+
for callback_path, callback_fn in agent._routing_callbacks.items():
|
361
|
+
cb_path_clean = callback_path.strip("/")
|
362
|
+
if clean_path == cb_path_clean:
|
363
|
+
request.state.callback_path = callback_path
|
364
|
+
return await agent._handle_root_request(request)
|
365
|
+
|
366
|
+
# No matching agent found
|
367
|
+
return {"error": "Not Found"}
|
368
|
+
|
325
369
|
# Print server info
|
326
370
|
host = host or self.host
|
327
371
|
port = port or self.port
|