Files
novelty-seeking/backend/app/prompts/transformation_prompt.py
2026-01-05 22:32:08 +08:00

161 lines
5.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Transformation Agent prompts module - Bilingual support"""
from typing import List
from .language_config import LanguageType
def get_keyword_generation_prompt(
category: str,
attributes: List[str],
keyword_count: int = 3,
lang: LanguageType = "zh"
) -> str:
"""
Step 1: Generate new keywords
Given a category and existing attributes, generate new, creative keywords.
Don't consider the original query, focus only on possible extensions of the category itself.
"""
attrs_text = ", ".join(attributes) if lang == "en" else "".join(attributes)
if lang == "en":
return f"""/no_think
You are a creative brainstorming expert. Given a category and its existing attributes, please generate new, creative keywords or descriptive phrases.
[Category] {category}
[Existing Attributes] {attrs_text}
[Important Rules]
1. Generate {keyword_count} completely new keywords
2. Keywords must fit within the scope of "{category}" category
3. Keywords should be creative and not duplicate or be too similar to existing attributes
4. Don't consider any specific object, focus only on possible extensions of this category
5. Each keyword should be 2-6 words
Return JSON only:
{{
"keywords": ["keyword1", "keyword2", "keyword3"]
}}"""
else:
return f"""/no_think
你是一個創意發想專家。給定一個類別和該類別下的現有屬性,請生成全新的、有創意的關鍵字或描述片段。
【類別】{category}
【現有屬性】{attrs_text}
【重要規則】
1. 生成 {keyword_count} 個全新的關鍵字
2. 關鍵字必須符合「{category}」這個類別的範疇
3. 關鍵字要有創意,不能與現有屬性重複或太相似
4. 不要考慮任何特定物件,只專注於這個類別本身可能的延伸
5. 每個關鍵字應該是 2-6 個字的詞彙或短語
只回傳 JSON
{{
"keywords": ["關鍵字1", "關鍵字2", "關鍵字3"]
}}"""
def get_description_generation_prompt(
query: str,
category: str,
keyword: str,
lang: LanguageType = "zh"
) -> str:
"""
Step 2: Combine with original query to generate description
Use new keyword to create an innovative application description related to the original query.
"""
if lang == "en":
return f"""/no_think
You are an innovation application expert. Please apply a new keyword concept to a specific object to create an innovative application description.
[Object] {query}
[Category] {category}
[New Keyword] {keyword}
[Task]
Using the concept of "{keyword}", create an innovative application description for "{query}".
The description should be a complete sentence or phrase explaining how to apply this new concept to the object.
[Example Format]
- If the object is "bicycle" and keyword is "monitor", you could generate "bicycle monitors the rider's health status"
- If the object is "umbrella" and keyword is "generate power", you could generate "umbrella generates electricity using raindrop impacts"
Return JSON only:
{{
"description": "innovative application description"
}}"""
else:
return f"""/no_think
你是一個創新應用專家。請將一個新的關鍵字概念應用到特定物件上,創造出創新的應用描述。
【物件】{query}
【類別】{category}
【新關鍵字】{keyword}
【任務】
請用「{keyword}」這個概念,為「{query}」創造一個創新的應用描述。
描述應該是一個完整的句子或短語,說明如何將這個新概念應用到物件上。
【範例格式】
- 如果物件是「腳踏車」,關鍵字是「監視」,可以生成「腳踏車監視騎乘者的身體健康狀況」
- 如果物件是「雨傘」,關鍵字是「發電」,可以生成「雨傘利用雨滴撞擊發電」
只回傳 JSON
{{
"description": "創新應用描述"
}}"""
def get_batch_description_prompt(
query: str,
category: str,
keywords: List[str],
lang: LanguageType = "zh"
) -> str:
"""
Batch description generation (optional optimized version, process multiple keywords at once)
"""
keywords_text = ", ".join(keywords) if lang == "en" else "".join(keywords)
if lang == "en":
return f"""/no_think
You are an innovation application expert. Please apply multiple new keyword concepts to a specific object, creating an innovative application description for each keyword.
[Object] {query}
[Category] {category}
[New Keywords] {keywords_text}
[Task]
Create an innovative application description related to "{query}" for each keyword.
Each description should be a complete sentence or phrase.
Return JSON only:
{{
"descriptions": [
{{"keyword": "keyword1", "description": "description1"}},
{{"keyword": "keyword2", "description": "description2"}}
]
}}"""
else:
return f"""/no_think
你是一個創新應用專家。請將多個新的關鍵字概念應用到特定物件上,為每個關鍵字創造創新的應用描述。
【物件】{query}
【類別】{category}
【新關鍵字】{keywords_text}
【任務】
為每個關鍵字創造一個與「{query}」相關的創新應用描述。
每個描述應該是一個完整的句子或短語。
只回傳 JSON
{{
"descriptions": [
{{"keyword": "關鍵字1", "description": "描述1"}},
{{"keyword": "關鍵字2", "description": "描述2"}}
]
}}"""