修复 app/core/__init__.py 的导入,从 intent_classifier.py 获取正确的类
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled
This commit is contained in:
@@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
from .formatter import MarkdownFormatter
|
from .formatter import MarkdownFormatter
|
||||||
from .state_base import BaseState
|
from .state_base import BaseState
|
||||||
from .intent import (
|
from .intent_classifier import (
|
||||||
IntentType,
|
IntentType,
|
||||||
IntentResult,
|
IntentResult,
|
||||||
IntentClassifier,
|
IntentClassifier,
|
||||||
classify_intent
|
get_intent_classifier
|
||||||
)
|
)
|
||||||
from .intent_classifier import get_intent_classifier
|
|
||||||
from .human_review import (
|
from .human_review import (
|
||||||
ReviewManager,
|
ReviewManager,
|
||||||
InMemoryReviewStore,
|
InMemoryReviewStore,
|
||||||
@@ -16,6 +15,22 @@ from .human_review import (
|
|||||||
HumanReview
|
HumanReview
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 为了兼容性,添加 classify_intent 函数
|
||||||
|
def classify_intent(user_input: str, context: str = None):
|
||||||
|
"""兼容旧代码的 classify_intent 函数"""
|
||||||
|
from app.core.intent_classifier import get_intent_classifier
|
||||||
|
import asyncio
|
||||||
|
classifier = get_intent_classifier()
|
||||||
|
try:
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
if loop.is_running():
|
||||||
|
task = loop.create_task(classifier.classify(user_input, context))
|
||||||
|
return asyncio.run_coroutine_threadsafe(task, loop).result()
|
||||||
|
except RuntimeError:
|
||||||
|
loop = asyncio.new_event_loop()
|
||||||
|
asyncio.set_event_loop(loop)
|
||||||
|
return loop.run_until_complete(classifier.classify(user_input, context))
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"MarkdownFormatter",
|
"MarkdownFormatter",
|
||||||
"BaseState",
|
"BaseState",
|
||||||
|
|||||||
Reference in New Issue
Block a user