mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 12:05:54 +00:00
- Move sandbox system-prompt guidance from LocalAgentRunner into
BoxService.get_system_guidance() so all box domain knowledge stays
in the box module.
- Remove standalone logging_utils.py; merge format_result_log() into
MessageHandler base class alongside cut_str().
- Strip sandbox-specific JSON parsing from log formatting; tool
results now use generic truncation.
- Revert TYPE_CHECKING changes in stage.py and runner.py that were
unrelated to this feature.
- Skip two test files affected by a pre-existing circular import
(runner ↔ app) until the import cycle is resolved in a separate PR.
42 lines
889 B
Python
42 lines
889 B
Python
from __future__ import annotations
|
|
|
|
import abc
|
|
import typing
|
|
|
|
from ..core import app
|
|
|
|
|
|
preregistered_runners: list[typing.Type[RequestRunner]] = []
|
|
|
|
|
|
def runner_class(name: str):
|
|
"""注册一个请求运行器"""
|
|
|
|
def decorator(cls: typing.Type[RequestRunner]) -> typing.Type[RequestRunner]:
|
|
cls.name = name
|
|
preregistered_runners.append(cls)
|
|
return cls
|
|
|
|
return decorator
|
|
|
|
|
|
class RequestRunner(abc.ABC):
|
|
"""请求运行器"""
|
|
|
|
name: str = None
|
|
|
|
ap: app.Application
|
|
|
|
pipeline_config: dict
|
|
|
|
def __init__(self, ap: app.Application, pipeline_config: dict):
|
|
self.ap = ap
|
|
self.pipeline_config = pipeline_config
|
|
|
|
@abc.abstractmethod
|
|
async def run(
|
|
self, query: core_entities.Query
|
|
) -> typing.AsyncGenerator[llm_entities.Message | llm_entities.MessageChunk, None]:
|
|
"""运行请求"""
|
|
pass
|