1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
model = ModelFactory.create(
model_platform=ModelPlatformType.GEMINI,
model_type=ModelType.GEMINI_2_0_FLASH,
model_config_dict={
"max_tokens": 4096, # 设置合理的最大令牌数(根据模型支持调整)
"temperature": 0.7, # 可选:其他模型参数
},
api_key=GEMINI_API_KEY,
)
agent = ChatAgent(
system_message=SystemAnalysePrompt,
model=model,
message_window_size=1000,
)
usr_msg = f"""
agent1_competitor_analysis_summary_str: {agent1_competitor_analysis_summary_str}
brand_industry_str: {brand_industry_str}
target_audience_persona_data = {target_audience_persona_data}
social_media_platform_names_str: {social_media_platform_names_str}
"""
try:
response = agent.step(usr_msg)
strRes = response.msgs[0].content
if (strRes[0] == '`'):
strRes = strRes[7: -4]
try:
return json.loads(strRes)
except json.JSONDecodeError as e:
print(f"analyze_existing_visual_assets, JSON解析错误: {e}")
except Exception as e:
print(f"An error occured when ask for AI response: {e}")
|