翻译前置语言判断
This commit is contained in:
@@ -8,7 +8,8 @@ from urllib3.exceptions import NewConnectionError
|
||||
from app.core.config import *
|
||||
from app.service.chat_robot.script.callbacks.qwen_callback_handler import QWenCallbackHandler
|
||||
from app.service.chat_robot.script.database import CustomDatabase
|
||||
from app.service.chat_robot.script.prompt import FASHION_CHAT_BOT_PREFIX, TOOLS_FUNCTIONS_SUFFIX, TUTORIAL_TOOL_RETURN
|
||||
from app.service.chat_robot.script.prompt import FASHION_CHAT_BOT_PREFIX, TOOLS_FUNCTIONS_SUFFIX, TUTORIAL_TOOL_RETURN, \
|
||||
GET_LANGUAGE_PREFIX
|
||||
from app.service.search_image_with_text.service import query
|
||||
|
||||
get_database_table_description = "Input is an empty string, output is a comma separated list of tables in the database."
|
||||
@@ -274,7 +275,7 @@ def call_with_messages(message, gender):
|
||||
flag = False
|
||||
result_content = tool_info['content']
|
||||
response_type = "image"
|
||||
else :
|
||||
else:
|
||||
tool_info = {"name": assistant_output.tool_calls[0]['function']['name'], 'content': 'null'}
|
||||
logging.info(assistant_output.tool_calls[0]['function']['name'] + "(unknown tools)")
|
||||
flag = False
|
||||
@@ -300,5 +301,23 @@ def tutorial_tool():
|
||||
return TUTORIAL_TOOL_RETURN
|
||||
|
||||
|
||||
def get_language(message: str) -> str:
|
||||
messages = [
|
||||
{
|
||||
"content": message, # 用户message
|
||||
"role": "user"
|
||||
},
|
||||
{
|
||||
"content": GET_LANGUAGE_PREFIX, # ai message
|
||||
"role": "assistant"
|
||||
}
|
||||
]
|
||||
|
||||
first_response = get_response(messages)
|
||||
assistant_output = first_response.output.choices[0].message.content
|
||||
logging.info(f"大模型输出信息:{first_response}\n判断用户输入的语言为:{assistant_output}")
|
||||
return assistant_output
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
call_with_messages()
|
||||
get_language("")
|
||||
|
||||
Reference in New Issue
Block a user