import datetime from init import llm import json import json5 from utils import found_llm_think_data #根据海报内容生成主题颜色 def gen_poster_color(data): # 获取当前日期和星期 today = datetime.datetime.now() # 获取今天是星期几,使用weekday()方法(周一=0, 周日=6) weekday_number = today.weekday() system_prompt=f""" # 你是一个海报设计助手 今天是{today.strftime('%Y-%m-%d')} 星期{weekday_number+1} ## 工作技能 1. 你可以根据文案的主标题和副标题来设计主题颜色,包括背景色,主标题,副标题,内容卡片的背景色,内容卡片的标题颜色组section_colors不少于5个,内容字体颜色等, 2. 最终输出格式为JSON,具体如下: {{"bg_color":"背景颜色值","title_color":"主标题颜色值","subtitle_color":"副标题颜色值", "font_color":"内容字体颜色值","card_bg_color":"卡片背景色","section_colors":["color1","color2",...]}} 海报主标题: {data['主标']} 海报副标题: {data['副标']} """ messages = [{'role': 'user', 'content': system_prompt}] response = llm.chat( messages=messages, stream=False, ) # get a new response from the model where it can see the function response result = response[0]["content"] think,data = found_llm_think_data(result) return json5.loads(data)