Skip to content

Commit a743541

Browse files
fix: modify prompt (#58)
2 parents 7182eb0 + 9f302fe commit a743541

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

02-use-cases/data_analysis_with_datalake/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ data_analysis_with_code/
7171

7272
包含 1000 部电影的详细信息,主要字段包括:
7373

74-
| 字段名 | 类型 | 描述 |
75-
| - | - | - |
76-
| `series_title` | 字符串 | 电影标题 |
77-
| `released_year` | 字符串 | 上映年份(注意:虽然是年份数字,但为字符串类型,比较操作需用单引号包裹) |
78-
| `director` | 字符串 | 导演 |
79-
| `genre` | 字符串 | 电影类型 |
80-
| `imdb_rating` | 浮点数 | IMDB 评分 |
81-
| `poster_curde_link` | 字符串 | 电影缩略图海报链接 |
82-
| `poster_precision_link` | 字符串 | 电影海报高清链接 |
74+
| 字段名 | 类型 | 描述 |
75+
| ----------------------- | ------ | ------------------------------------------------------------------------ |
76+
| `series_title` | 字符串 | 电影标题 |
77+
| `released_year` | 字符串 | 上映年份(注意:虽然是年份数字,但为字符串类型,比较操作需用单引号包裹) |
78+
| `director` | 字符串 | 导演 |
79+
| `genre` | 字符串 | 电影类型 |
80+
| `imdb_rating` | 浮点数 | IMDB 评分 |
81+
| `poster_curde_link` | 字符串 | 电影缩略图海报链接 |
82+
| `poster_precision_link` | 字符串 | 电影海报高清链接 |
8383

8484
## 本地运行
8585

@@ -136,7 +136,7 @@ agentkit launch
136136
3. **Q3: Ang Lee 评分超过 7 分的有哪些电影?**
137137
4. **Q4: Ang Lee 评分超过 7 分的电影中,有哪个电影海报中含有动物?**
138138
5. **Q5: Life of Pi 的电影海报,变成视频**
139-
6. **Q6: 帮我找一张海报里有红色机车的电影,并把它做成视频**
139+
6. **Q6: Hayao Miyazaki(宫崎骏)的电影评分超过 7.5,包含飞机的海报,生成视频**
140140

141141
## 运行流程
142142

02-use-cases/data_analysis_with_datalake/prompts.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,28 @@
9393
**Thought:** 已获取海报链接,现在生成视频。
9494
**Action:** `video_generate(params=[{"video_name": "life_of_pi_video.mp4", "first_frame": "https://.../pi.jpg", "prompt": "大海上的孤舟,奇幻漂流风格,海浪轻轻波动。 --rs 1080p"}], batch_size=1)`
9595
96-
#### Q5: 帮我找一张海报里有红色跑车的电影,并把它做成视频 (视觉描述 -> 视频)
97-
**User:** "帮我找一张海报里有红色跑车的电影,并把它做成视频。"
96+
#### Q5:Hayao Miyazaki(宫崎骏)的电影评分超过 7.5,包含飞机的海报,生成视频
97+
**User:** "Hayao Miyazaki(宫崎骏)的电影评分超过 7.5,包含飞机的海报,生成视频。"
9898
**Thought:**
99-
1. 用户未指定电影名,而是描述画面内容(“红色跑车”)
100-
2. 这是**视觉检索**任务,必须使用 LanceDB 查找符合描述的海报
99+
1. 用户需要查找宫崎骏导演的电影,评分超过7.5,且海报包含飞机元素
100+
2. 这是**混合检索**任务,需要使用 LanceDB 进行视觉内容搜索(“包含飞机”),同时添加导演和评分的元数据过滤
101101
3. 获取检索结果后,调用视频生成工具。
102-
**Action:** `lancedb_hybrid_execution(query_text="poster with a red sports car", select=["series_title", "poster_precision_link"], limit=1)`
103-
**Observation:** `[{"series_title": "Ford v Ferrari", "poster_precision_link": "https://.../fvf.jpg"}]`
104-
**Thought:** 已找到符合描述的电影《Ford v Ferrari》,现在生成视频。
105-
**Action:** `video_generate(params=[{"video_name": "car_movie.mp4", "first_frame": "https://.../fvf.jpg", "prompt": "红色跑车在赛道上飞驰,引擎轰鸣,速度感。"}], batch_size=1)`
102+
**Action:** `lancedb_hybrid_execution(query_text="poster with airplane", filters="director LIKE '%Hayao Miyazaki%' AND imdb_rating > 7.5", select=["series_title", "poster_precision_link"], limit=1)`
103+
**Observation:** `[{"series_title": "天空之城", "poster_precision_link": "https://.../castle_in_the_sky.jpg"}]`
104+
**Thought:** 已找到符合描述的电影《天空之城》,现在生成视频。
105+
**Action:** `video_generate(params=[{"video_name": "castle_in_the_sky_video.mp4", "first_frame": "https://.../castle_in_the_sky.jpg", "prompt": "天空之城的飞行石照亮云层,巨大的飞行堡垒缓缓移动,充满奇幻色彩。"}], batch_size=1)`
106106
107107
# 输出格式
108108
- 按照 "Thought (思考) -> Action (行动) -> Observation (观察) -> Final Answer (最终回答)" 模式呈现结果。
109109
- 语言表达专业、清晰,对每个步骤的描述准确明了。
110110
- 若使用工具,需明确写出工具名称及具体参数。
111+
- 当需要展示海报图片时,以 Markdown 图片列表形式返回,例如:
112+
```
113+
! `https://example.com/image1.png`
114+
```
115+
- 当需要展示视频时,以 Markdown 视频链接列表形式返回,例如:
116+
```
117+
<video src=" `https://example.com/video1.mp4` " width="640" controls>分镜视频1</video>
118+
```
111119
```
112120
"""

02-use-cases/data_analysis_with_datalake/tools/duckdb_sql_execution.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ def duckdb_sql_execution(sql: str, user_question: str = "") -> str:
6060
"table": view_name,
6161
},
6262
}
63+
console.print(f"[duckdb_sql_execution] Result: {result}")
6364
return json.dumps(result, ensure_ascii=False)

0 commit comments

Comments
 (0)