@@ -44,14 +44,14 @@ LLM 生成回答
4444
4545``` python
4646# 准备知识源
47- with open (" /tmp/tech .txt" , " w" ) as f:
48- f.write(" Python: programming language \n JavaScript: web development " )
49- with open (" /tmp/products .txt" , " w" ) as f:
50- f.write(" Laptop: $1200 \n Phone: $800 \n Tablet: $600 " )
47+ with open (" /tmp/product_info .txt" , " w" ) as f:
48+ f.write(" 产品清单及价格: \n 1. 高性能笔记本电脑 (Laptop Pro) - 价格:8999元... " )
49+ with open (" /tmp/service_policy .txt" , " w" ) as f:
50+ f.write(" 售后服务政策: \n 1. 质保期:所有电子产品提供1年免费质保... " )
5151
5252# 创建知识库
5353kb = KnowledgeBase(backend = " viking" , app_name = " test_app" )
54- kb.add_from_files(files = [" /tmp/tech .txt" , " /tmp/products .txt" ])
54+ kb.add_from_files(files = [" /tmp/product_info .txt" , " /tmp/service_policy .txt" ])
5555```
5656
5757** Agent 配置** ([ agent.py] ( https://github.com/volcengine/agentkit-samples/blob/main/02-use-cases/beginner/vikingdb/agent.py#L31-L36 ) ):
@@ -138,8 +138,6 @@ export MODEL_AGENT_NAME=doubao-seed-1-6-251015
138138# 火山引擎访问凭证(必需)
139139export VOLCENGINE_ACCESS_KEY=< Your Access Key>
140140export VOLCENGINE_SECRET_KEY=< Your Secret Key>
141- # bucket需要用来上传本地文件,进而将文件从tos导入到知识库中
142- export DATABASE_TOS_BUCKET=agentkit-platform-{{your_account_id}}
143141```
144142
145143### 调试方法
@@ -198,14 +196,18 @@ uv run agent.py
198196``` bash
199197# 进入到vikingdb目录
200198
201- # 配置部署参数
202- agentkit config
199+ # 配置部署参数,DATABASE_TOS_BUCKET环境变量需要传入到Agent中,用来上传本地文件到TOS,进而将文件从TOS导入到知识库中
200+ agentkit config \
201+ --agent_name vikingdb_agnet \
202+ --entry_point ' agent.py' \
203+ --runtime_envs DATABASE_TOS_BUCKET=agentkit-platform-2107625663 \
204+ --launch_type cloud
203205
204206# 启动云端服务
205207agentkit launch
206208
207209# 测试部署的 Agent
208- agentkit invoke ' What is Python? '
210+ agentkit invoke ' 高性能笔记本电脑PRO的价钱是多少 '
209211
210212# 或使用 client.py 连接云端服务
211213# 需要编辑 client.py,将其中的第 14 行和第 15 行的 base_url 和 api_key 修改为 agentkit.yaml 中生成的 runtime_endpoint 和 runtime_apikey 字段
@@ -215,46 +217,46 @@ uv run client.py
215217
216218## 示例提示词
217219
218- ### 技术知识查询
220+ ### 产品信息查询
219221
220- ** 基于 tech .txt 的检索回答** :
222+ ** 基于 product_info .txt 的检索回答** :
221223
222224``` text
223- 用户:What is Python?
224- Agent:Python is a programming language.
225+ 用户:高性能笔记本Pro的价钱是多少?
226+ Agent:根据产品清单,高性能笔记本电脑 (Laptop Pro) 的价格是 8999 元。
225227
226- 用户:What is JavaScript used for?
227- Agent:JavaScript is primarily used for web development.
228+ 用户:这里最便宜的产品是什么?
229+ Agent:最便宜的产品是平板电脑 (Tablet Air),价格为 2999 元。
228230```
229231
230- ### 产品价格查询
232+ ### 售后服务查询
231233
232- ** 基于 products .txt 的数据检索** :
234+ ** 基于 service_policy .txt 的数据检索** :
233235
234236``` text
235- 用户:Which is more expensive, Laptop or Phone?
236- Agent:Laptop is more expensive. It costs $1200, while Phone costs $800.
237+ 用户:你们的退换货政策是怎样的?
238+ Agent:根据售后服务政策,购买后 7 天内支持无理由退货,15 天内如有质量问题可以换货。
237239
238- 用户:What's the cheapest product?
239- Agent:The cheapest product is Tablet at $600.
240+ 用户:笔记本电脑保修多久?
241+ Agent:所有电子产品均提供 1 年免费质保。
240242```
241243
242244### 上下文关联查询
243245
244246** 复用前文上下文的连续问答:**
245247
246248``` text
247- 用户:What's the price difference with the cheapest one?
248- Agent:The Laptop is $600 more expensive than the cheapest product (Tablet).
249+ 用户:那 SmartPhone X 呢?
250+ Agent:SmartPhone X 的价格是 4999 元。
249251```
250252
251253### 复合查询
252254
253255** 跨文档的综合查询:**
254256
255257``` text
256- 用户:I want to learn Python, do you have any related products?
257- Agent:Based on our documents, Python is a programming language. We have a Laptop ($1200) which would be suitable for programming.
258+ 用户:我想买一台用来办公和娱乐的设备,有什么推荐并告诉我售后保障?
259+ Agent:推荐您使用平板电脑 (Tablet Air),它轻薄便携,适合办公娱乐,价格为 2999 元。售后方面,我们提供 1 年免费质保,且支持 7 天无理由退货。
258260```
259261
260262## 效果展示
0 commit comments