自定义agent调用知识库 #3432
Replies: 1 comment 1 reply
-
嗨,@LCR997!很高兴再次看到你。希望你最近一切都好! 您可以通过修改
from datetime import datetime
# 在knowledge_base_chat_iterator函数中,搜索文档之前
# 获取当前的小时数
current_hour = datetime.now().hour
# 根据一天中的时间修改查询
if 5 <= current_hour < 12:
greeting = "早上好!"
elif 12 <= current_hour < 18:
greeting = "下午好!"
else:
greeting = "晚上好!"
# 在查询前添加问候语
query = greeting + query 这个例子演示了如何在查询知识库之前,将一个基于时间的问候语添加到用户的查询中。您可以通过修改查询或根据一天中的时间或其他相关条件调整回答逻辑,来适应这种方法以包含其他基于时间的条件。 请记住,这段代码片段应该放在 关于
函数执行以下步骤:
最后,函数返回一个包装 相关资源: Sources
|
Beta Was this translation helpful? Give feedback.
-
自定义agent怎么调用知识库进行回答,并加入一些限定条件,例如时间。
Beta Was this translation helpful? Give feedback.
All reactions