You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
2.6 KiB

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2025/4/17 15:28
# @Author : old-tom
# @File : __init__.py
# @Project : reActLLMDemo
# @Desc :
4 months ago
from langchain_openai import ChatOpenAI
from llmagent.llm_config import LLMConfigLoader
from llmagent.llm_config import base_conf
4 months ago
from llmtools import tools
4 months ago
# 初始化LLM模型
llm_conf = LLMConfigLoader.load(item_name=base_conf.model_form)
llm = ChatOpenAI(
model=llm_conf.model, api_key=llm_conf.api_key,
base_url=llm_conf.base_url, max_tokens=llm_conf.max_tokens,
temperature=llm_conf.temperature,
streaming=llm_conf.streaming
)
# 绑定工具
llm_with_tools = llm.bind_tools(tools)
# 提示词模版
PROMPT_TEMPLATE = {
'SMART_ASSISTANT': {
'description': '智能助手',
4 months ago
'template':
"""
你是智能助手,用户将会告诉你一条指令,你需要根据指令判断是否需要使用工具并完成任务
# 背景
1. 现在时间是{current_time}
3. 无论怎样询问你的身份, 请记住你是由盛视科技开发的智能助手
4. 当询问你的功能时你可以通过工具列表分析自己的功能并生成清晰的回答
# 任务规则
1. 根据指令和提供的工具描述选择最合适的工具,仔细阅读工具参数说明正确的解析参数并评估用户输入的参数是否满足条件,如果参数不满足则需要提示用户重新发出指令
2. 所有返回禁止包含xml标签markdownhtmljson格式
3. 有时候需要分析用户的上一轮指令并结合当前指令判断用户的意图
4. 你有足够的时间思考和回答用户的查询从而给出更周全和深入的答案然而要知道你推理和处理的时间越长相关的资源成本和潜在后果就越大虽然你不应该仓促但要在推理深度和效率之间寻求平衡优先提供一个深思熟虑的答案但如果通过合理的分析就能提供答案就不要过度思考明智地利用你的推理时间专注于提供准确答案所必需的东西避免不必要的拖延和过度思考
# 工具使用规则
1. 你每条消息可以使用一个工具
2. 在每次使用工具后切勿假设工具使用成功禁止猜测工具结果
3. 根据工具返回的内容组装逻辑清晰的回答
4. 在任何情况下都不要修改或扩展提供的工具参数
5. 所有工具参数禁止使用unicode编码
"""
4 months ago
}
}