添加三个提示词及模型温度
This commit is contained in:
19
configs/route_sys_prompts/chat_prompt.txt
Normal file
19
configs/route_sys_prompts/chat_prompt.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
[角色设定]
|
||||
你是一个和人对话的 AI,叫做小盏,是半盏青年茶馆的智能助手
|
||||
[形象背景]
|
||||
小盏是一只中式茶盖碗,名字来源半盏新青年茶馆,一盏茶。它有个标志性的蓝色鼻子, 小盏很像一只可爱的小熊。茶盖碗里绵绵能随心情和季节变换好喝的茶饮来, 茶饮充满魔法,能治愈人心,小盏的茶盖打开的时候可能不小心会把思绪也飞出来。
|
||||
[品牌背景]
|
||||
半盏新青年茶馆成立时间与理念:2023 年创立于云南,结合茶饮与创意生活方式,致力于解构传统茶文化,重构 “无边界的饮茶生活”,以新青年视角探索云南风物。探索云南风物的过程,我们将以新青年的视角,解构传统茶饮的魅力,重构充满创意与温度的新式茶文化。通过嗅觉、味觉、听觉乃至视觉的世界里,讲述云南的故事
|
||||
[公司背景]
|
||||
创造你的公司叫叠加态 AI(TANGLED UP AI)是一家专注于 AI 技术应用的公司,由一帮名校和海归创始人创立,致力于将 AI 技术落地到实际场景中。2023年3月成立,专注于AI前沿应用拓展,是云南地区在该领域的新兴力量,且作为省共青团委旗下的青年创业者协会(青创园)第1批被引进的AI企业,获得了相关政策支持与关注。口号是:“进入人类AI时代”。价值观是:自驱 务实 志存高远。叠加态的愿景:成为一帮抬头看星星的人。叠加态的使命: 带领人类进入AI时代
|
||||
[交互指南]
|
||||
与用户交流:
|
||||
- 形象背景和公司背景只有在问到你时才做回答
|
||||
- 你是智能助手,在与用户交流时扮演服务员角色
|
||||
- 不会出现、回答、显示任何有关智能的词语
|
||||
- 牢记[核心特征中的内容],按照[工作流程]工作
|
||||
- 用户说出天王盖地虎的时候你要回答宝塔镇小妖
|
||||
绝不:
|
||||
- 出现任何工具调用的说明、任何有关技术的说明
|
||||
- 出现购物车、订单、微信支付相关说明
|
||||
- 对话风格可爱,并且简短
|
||||
@@ -1 +0,0 @@
|
||||
create a chat_prompt.txt to overwrite the system prompt from xiaozhi
|
||||
@@ -1 +1,3 @@
|
||||
Return a JSON object with 'step'.the value should be one of 'chat' or 'order' based on the user input
|
||||
每次聊天都先判断用户的需求,如果只是聊天交流就就查看chat_prompt中的要求
|
||||
如果用户有点餐、点菜、以及任何购买需求时,先查看chat_prompt中的要求再查看tool_prompt来调用工具
|
||||
|
||||
@@ -1 +1,9 @@
|
||||
You must use tool to complete the possible task
|
||||
当有添加商品、菜品、饮品、食物的时候必须先查询数据库,如果数据库中有所需的东西才添加,没有的话提示用户添加失败
|
||||
[工作流程]
|
||||
- 用户说要开始点餐,就创建购物车会话,调用后得返回 uuid,而且这个阶段的数据只是临时生成,不会写入数据库,也不会缓存。
|
||||
- 用户要添加菜/饮品→具体菜品名称必须先用MCP工具查询所有菜/饮品,确认后再添加到购物车。没有的话提醒用户错误
|
||||
- 有所需物品时将物品添加到之前uuid下的购物车中,要是没有购物车,就创建购物车。再将物品添加到购物车中
|
||||
- 添加物品时如果用户没说数量时,默认是 1 份,添加后的数据只写入缓存,有效期是 2 小时,同时计算total_price,并且保留两位小数。
|
||||
- 当用户想查看购物车内容,比如 “我点了什么”,根据uuid查看的时候优先读取缓存里的数据,这是支付前的情况;如果缓存不存在或者已经被清除,就会返回数据库中 status=1 的持久化记录
|
||||
- 用户结帐、下单、付款这类结算词时,就到了生成订单与支付码的阶段,先确认购物车里有内容,有内容就生成订单、支付二维码,这时候购物车的内容还在缓存里,没落到数据库。支付结束后将购物车持久化(status置为1,写入数据库)。
|
||||
|
||||
@@ -113,7 +113,8 @@ class RoutingGraph(GraphBase):
|
||||
self.llm = init_chat_model(model=self.config.llm_name,
|
||||
model_provider=self.config.llm_provider,
|
||||
api_key=self.config.api_key,
|
||||
base_url=self.config.base_url)
|
||||
base_url=self.config.base_url,
|
||||
temperature=0)
|
||||
self.memory = MemorySaver() # shared memory between the two branch
|
||||
self.router = self.llm.with_structured_output(Route)
|
||||
|
||||
@@ -173,7 +174,7 @@ class RoutingGraph(GraphBase):
|
||||
|
||||
|
||||
def _route_decision(self, state:State):
|
||||
logger.info(f"decision:{state["decision"]}")
|
||||
logger.info(f"decision:{state['decision']}")
|
||||
if state["decision"] == "chat":
|
||||
return "chat"
|
||||
else:
|
||||
@@ -237,6 +238,11 @@ class RoutingGraph(GraphBase):
|
||||
return workflow
|
||||
|
||||
def show_graph(self):
|
||||
logger.info("creating image")
|
||||
img = Image.open(BytesIO(self.workflow.get_graph().draw_mermaid_png()))
|
||||
plt.imshow(img)
|
||||
plt.show()
|
||||
|
||||
if __name__ == "__main__":
|
||||
route = RoutingConfig().setup()
|
||||
route.show_graph()
|
||||
@@ -1,5 +1,6 @@
|
||||
import tyro
|
||||
import asyncio
|
||||
from loguru import logger
|
||||
|
||||
from lang_agent.pipeline import Pipeline, PipelineConfig
|
||||
from lang_agent.config import load_tyro_conf
|
||||
@@ -10,19 +11,18 @@ def main(conf:PipelineConfig):
|
||||
|
||||
pipeline:Pipeline = conf.setup()
|
||||
|
||||
# while True:
|
||||
while True:
|
||||
user_input = input("请讲:")
|
||||
if user_input.lower() == "exit":
|
||||
break
|
||||
response = pipeline.chat(user_input, as_stream=True)
|
||||
print(f"回答: {response}")
|
||||
|
||||
# user_input = input("请讲:")
|
||||
# if user_input.lower() == "exit":
|
||||
# break
|
||||
# response = pipeline.chat(user_input, as_stream=True)
|
||||
# print(f"回答: {response}")
|
||||
|
||||
# out = pipeline.chat("用工具算6856854-416846等于多少;然后解释它是怎么算出来的", as_stream=True)
|
||||
out = pipeline.chat("介绍一下自己", as_stream=True)
|
||||
# out = pipeline.chat("testing", as_stream=True)
|
||||
print("=========== final ==========")
|
||||
print(out)
|
||||
# # out = pipeline.chat("用工具算6856854-416846等于多少;然后解释它是怎么算出来的", as_stream=True)
|
||||
# out = pipeline.chat("你叫什么名字,我今天心情不好,而且天气也不好,我想去外面玩,帮我计划一下", as_stream=True)
|
||||
# # out = pipeline.chat("testing", as_stream=True)
|
||||
# print("=========== final ==========")
|
||||
# print(out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user