feat: support Java prompt_context passthrough (Plan A)
- content_generate_v2: use Java prompt_context if provided, fallback to local - topic_generate_v2: same passthrough support - Maintains backward compatibility with direct Python calls
This commit is contained in:
parent
73cc12fe65
commit
09bc862eee
@ -121,6 +121,9 @@ class ContentGenerateEngineV2(BaseAIGCEngine):
|
||||
self.log("开始生成内容 (V2)")
|
||||
self.set_progress(task_id, 10)
|
||||
|
||||
# 🎯 方案A: 检查是否有 Java 透传的 prompt_context
|
||||
prompt_context = params.get('prompt_context')
|
||||
|
||||
# 提取参数
|
||||
topic = params.get('topic', {})
|
||||
|
||||
@ -149,6 +152,17 @@ class ContentGenerateEngineV2(BaseAIGCEngine):
|
||||
# 获取 PromptRegistry
|
||||
prompt_registry = self._get_prompt_registry()
|
||||
|
||||
# 🎯 方案A: 如果有 Java 透传的 context,直接使用;否则本地构建
|
||||
if prompt_context:
|
||||
self.log("使用 Java 透传的 prompt_context")
|
||||
context = prompt_context
|
||||
# 补充可能缺少的字段
|
||||
if 'hot_topics' not in context and hot_topics:
|
||||
context['hot_topics'] = hot_topics
|
||||
if 'reference' not in context and reference:
|
||||
context['reference'] = reference
|
||||
else:
|
||||
self.log("使用本地构建的 context (兼容模式)")
|
||||
# 从 subject 提取产品信息
|
||||
current_product = None
|
||||
if subject and subject.get('products'):
|
||||
|
||||
@ -158,6 +158,21 @@ class TopicGenerateEngineV2(BaseAIGCEngine):
|
||||
# 获取 PromptRegistry
|
||||
prompt_registry = self._get_prompt_registry()
|
||||
|
||||
# 🎯 方案A: 检查是否有 Java 透传的 prompt_context
|
||||
prompt_context = params.get('prompt_context')
|
||||
|
||||
if prompt_context:
|
||||
self.log("使用 Java 透传的 prompt_context")
|
||||
context = prompt_context
|
||||
# 补充必要字段
|
||||
if 'num_topics' not in context:
|
||||
context['num_topics'] = num_topics
|
||||
if 'month' not in context:
|
||||
context['month'] = month
|
||||
if 'hot_topics' not in context and hot_topics:
|
||||
context['hot_topics'] = hot_topics
|
||||
else:
|
||||
self.log("使用本地构建的 context (兼容模式)")
|
||||
# 构建 prompt 上下文
|
||||
context = {
|
||||
'num_topics': num_topics,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user