rename bot app class
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "quickbot-agent"
|
name = "quickbot_agent"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
description = "Add your description here"
|
description = "Add your description here"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from openai.types.chat import ChatCompletionMessage
|
|||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from quickbot.model.user import UserBase
|
from quickbot.model.user import UserBase
|
||||||
from sqlmodel.ext.asyncio.session import AsyncSession
|
from sqlmodel.ext.asyncio.session import AsyncSession
|
||||||
from quickbot import QBotApp, BotContext
|
from quickbot import QuickBot, BotContext
|
||||||
from quickbot.model.crud_service import ForbiddenError, NotFoundError
|
from quickbot.model.crud_service import ForbiddenError, NotFoundError
|
||||||
from quickbot.model.crud_command import CrudCommand
|
from quickbot.model.crud_command import CrudCommand
|
||||||
from ..utils import get_message_log, add_message_log, generate_gpt_tools_schemas
|
from ..utils import get_message_log, add_message_log, generate_gpt_tools_schemas
|
||||||
@@ -165,11 +165,17 @@ async def handle_openai_cycle(
|
|||||||
try:
|
try:
|
||||||
if iscoroutinefunction(process_descriptor.process_class.run):
|
if iscoroutinefunction(process_descriptor.process_class.run):
|
||||||
result = await process_descriptor.process_class.run(
|
result = await process_descriptor.process_class.run(
|
||||||
context, parameters=process_descriptor.input_schema(**function_args)
|
context,
|
||||||
|
parameters=process_descriptor.input_schema(
|
||||||
|
**function_args
|
||||||
|
),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
result = process_descriptor.process_class.run(
|
result = process_descriptor.process_class.run(
|
||||||
context, parameters=process_descriptor.input_schema(**function_args)
|
context,
|
||||||
|
parameters=process_descriptor.input_schema(
|
||||||
|
**function_args
|
||||||
|
),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
result = {"error": f"Error: {e}"}
|
result = {"error": f"Error: {e}"}
|
||||||
@@ -209,7 +215,7 @@ async def handle_message(
|
|||||||
message: Message,
|
message: Message,
|
||||||
db_session: AsyncSession,
|
db_session: AsyncSession,
|
||||||
user: UserBase,
|
user: UserBase,
|
||||||
app: QBotApp,
|
app: QuickBot,
|
||||||
app_state: State,
|
app_state: State,
|
||||||
) -> None:
|
) -> None:
|
||||||
plugin: "AgentPlugin" = app.plugins["AgentPlugin"]
|
plugin: "AgentPlugin" = app.plugins["AgentPlugin"]
|
||||||
@@ -249,7 +255,7 @@ async def handle_business_message(
|
|||||||
message: Message,
|
message: Message,
|
||||||
db_session: AsyncSession,
|
db_session: AsyncSession,
|
||||||
user: UserBase,
|
user: UserBase,
|
||||||
app: QBotApp,
|
app: QuickBot,
|
||||||
app_state: State,
|
app_state: State,
|
||||||
) -> None:
|
) -> None:
|
||||||
plugin: "AgentPlugin" = app.plugins["AgentPlugin"]
|
plugin: "AgentPlugin" = app.plugins["AgentPlugin"]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from aiogram.utils.i18n.lazy_proxy import LazyProxy
|
from aiogram.utils.i18n.lazy_proxy import LazyProxy
|
||||||
from quickbot import QBotApp, BotEntity, BotProcess
|
from quickbot import QuickBot, BotEntity, BotProcess
|
||||||
from quickbot.model.crud_command import CrudCommand
|
from quickbot.model.crud_command import CrudCommand
|
||||||
from quickbot.model.descriptors import BotContext
|
from quickbot.model.descriptors import BotContext
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
@@ -26,7 +26,7 @@ class AgentPlugin:
|
|||||||
self.tools_context = tools_context
|
self.tools_context = tools_context
|
||||||
self._gpt_tools_metadata = []
|
self._gpt_tools_metadata = []
|
||||||
|
|
||||||
def register(self, app: QBotApp) -> None:
|
def register(self, app: QuickBot) -> None:
|
||||||
if not callable(self.tools_context):
|
if not callable(self.tools_context):
|
||||||
self._gpt_tools_metadata = generate_gpt_tools_schemas(
|
self._gpt_tools_metadata = generate_gpt_tools_schemas(
|
||||||
app.bot_metadata, self.tools_context
|
app.bot_metadata, self.tools_context
|
||||||
|
|||||||
@@ -303,7 +303,9 @@ def generate_gpt_tools_schemas(
|
|||||||
entity, commands = tool_item
|
entity, commands = tool_item
|
||||||
if commands:
|
if commands:
|
||||||
gpt_tools_schemas.extend(
|
gpt_tools_schemas.extend(
|
||||||
generate_crud_tool_schemas(entity.bot_entity_descriptor, commands=commands)
|
generate_crud_tool_schemas(
|
||||||
|
entity.bot_entity_descriptor, commands=commands
|
||||||
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
gpt_tools_schemas.extend(
|
gpt_tools_schemas.extend(
|
||||||
|
|||||||
Reference in New Issue
Block a user