async def generate_article(request): data = await request.json() title = data["title"] api_key = data["api_key"] print(f"接受到title {title} api_key {api_key}") # openai.api_key = api_key messages = [{'role': 'system', 'content': '你是一个资深的技术和文学专家,很擅长写一些运维类和编程类的技术文章'}, {'role': 'user', 'content': f'以{title},写一篇技术文章!'}] response = openai.ChatCompletion.create( model='gpt-3.5-turbo', messages=messages, temperature=0.9, max_tokens=4000, ) response = response.choices[0]["message"]["content"] print(f"response {response}") return web.json_response({"status": 200, "content": f"{response}"})