mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-10 15:56:03 +00:00
style: introduce ruff as linter and formatter (#1356)
* style: remove necessary imports * style: fix F841 * style: fix F401 * style: fix F811 * style: fix E402 * style: fix E721 * style: fix E722 * style: fix E722 * style: fix F541 * style: ruff format * style: all passed * style: add ruff in deps * style: more ignores in ruff.toml * style: add pre-commit
This commit is contained in:
committed by
GitHub
parent
09e70d70e9
commit
209f16af76
@@ -3,13 +3,11 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
|
||||
from ...core import app, entities as core_entities
|
||||
from ...plugin import context as plugin_context
|
||||
from ...provider import entities as provider_entities
|
||||
|
||||
|
||||
class SessionManager:
|
||||
"""会话管理器
|
||||
"""
|
||||
"""会话管理器"""
|
||||
|
||||
ap: app.Application
|
||||
|
||||
@@ -23,10 +21,12 @@ class SessionManager:
|
||||
pass
|
||||
|
||||
async def get_session(self, query: core_entities.Query) -> core_entities.Session:
|
||||
"""获取会话
|
||||
"""
|
||||
"""获取会话"""
|
||||
for session in self.session_list:
|
||||
if query.launcher_type == session.launcher_type and query.launcher_id == session.launcher_id:
|
||||
if (
|
||||
query.launcher_type == session.launcher_type
|
||||
and query.launcher_id == session.launcher_id
|
||||
):
|
||||
return session
|
||||
|
||||
session_concurrency = self.ap.instance_config.data['concurrency']['session']
|
||||
@@ -39,7 +39,12 @@ class SessionManager:
|
||||
self.session_list.append(session)
|
||||
return session
|
||||
|
||||
async def get_conversation(self, query: core_entities.Query, session: core_entities.Session, prompt_config: list[dict]) -> core_entities.Conversation:
|
||||
async def get_conversation(
|
||||
self,
|
||||
query: core_entities.Query,
|
||||
session: core_entities.Session,
|
||||
prompt_config: list[dict],
|
||||
) -> core_entities.Conversation:
|
||||
"""获取对话或创建对话"""
|
||||
|
||||
if not session.conversations:
|
||||
@@ -52,7 +57,7 @@ class SessionManager:
|
||||
prompt_messages.append(provider_entities.Message(**prompt_message))
|
||||
|
||||
prompt = provider_entities.Prompt(
|
||||
name="default",
|
||||
name='default',
|
||||
messages=prompt_messages,
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user