修复 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 .state_base import BaseState
|
||||
from .intent import (
|
||||
from .intent_classifier import (
|
||||
IntentType,
|
||||
IntentResult,
|
||||
IntentClassifier,
|
||||
classify_intent
|
||||
get_intent_classifier
|
||||
)
|
||||
from .intent_classifier import get_intent_classifier
|
||||
from .human_review import (
|
||||
ReviewManager,
|
||||
InMemoryReviewStore,
|
||||
@@ -16,6 +15,22 @@ from .human_review import (
|
||||
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__ = [
|
||||
"MarkdownFormatter",
|
||||
"BaseState",
|
||||
|
||||
Reference in New Issue
Block a user