from dotenv import load_dotenv
from langchain.output_parsers import StructuredOutputParser, ResponseSchema
from langchain_core.prompts import PromptTemplate
from langchain_openai import ChatOpenAI

# 加载.env文件的环境变量
load_dotenv()

# 创建一个大语言模型，model指定了大语言模型的种类
model = ChatOpenAI(model="qwen2.5-14b-instruct")

# 想要接收的响应模式
response_schemas = [
    ResponseSchema(name="brand_name", description="Brand name."),
    ResponseSchema(name="brand_slogan", description="Brand slogan."),
    ResponseSchema(name="brand_logo_prompt", description="prompt required for brand logo generation.")
]
output_parser = StructuredOutputParser.from_response_schemas(response_schemas)
format_instructions = output_parser.get_format_instructions()
prompt = PromptTemplate(
    template="你是一个时装品牌的设计师。根据用户输入提取出brand name，brand slogan,brand logo 描述。如果没有以上内容，需要你根据用户输入随意发挥。随后根据brand logo 描述生成一个prompt，这个prompt用于生成模型.\n{format_instructions}\n{question}",
    input_variables=["question"],
    partial_variables={"format_instructions": format_instructions}
)
_input = prompt.format_prompt(question="brand name: cat home")

output = model(_input.to_messages())
brand_data = output_parser.parse(output.content)


def generate_logo(bucket_name, object_name, prompt):
    pass
