Skip to content

Send a phone call from AI agent, in an API call. Or, directly call the bot from the configured phone number!

Python

fix: Tool execution

Clémence Lesné7803e1a35aaa
diff --git a/app/models/message.py b/app/models/message.py
index d127dfe..43f9cc5 100644
--- a/app/models/message.py
+++ b/app/models/message.py
@@ -15,7 +15,6 @@ from openai.types.chat import (
from openai.types.chat.chat_completion_chunk import ChoiceDeltaToolCall
from pydantic import BaseModel, Field, field_validator
-from app.helpers.config import CONFIG
from app.helpers.llm_utils import AbstractPlugin
from app.helpers.monitoring import tracer
@@ -23,8 +22,6 @@ _FUNC_NAME_SANITIZER_R = r"[^a-zA-Z0-9_-]"
_MESSAGE_ACTION_R = r"(?:action=*([a-z_]*))? *(.*)"
_MESSAGE_STYLE_R = r"(?:style=*([a-z_]*))? *(.*)"
-_db = CONFIG.database.instance()
-
class StyleEnum(str, Enum):
"""
@@ -103,9 +100,13 @@ class ToolModel(BaseModel):
},
)
+ # TODO: Move this to AbstractPlugin to avoid doing live imports
async def execute_function(self, plugin: AbstractPlugin) -> None:
+ from app.helpers.config import CONFIG
from app.helpers.logging import logger
+ db = CONFIG.database.instance()
+
json_str = self.function_arguments
name = self.function_name
@@ -142,7 +143,7 @@ class ToolModel(BaseModel):
) as span:
try:
# Persist the call if updating it
- async with _db.call_transac(
+ async with db.call_transac(
call=plugin.call,
scheduler=plugin.scheduler,
):