from g4f.client import Client
import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

client = Client()
messages = [{"role": "system", "content": "你是一名助手，你的任务是回答日常问题的解决方法，并提供有用的建议。"}]

while True:
    content = input(">说点什么:")
    messages.append({"role": "user", "content": content})
    response = client.chat.completions.create(
    model="gpt-3.5-turbo",
    messages=messages,
    # proxy="socks5://127.0.0.1:1080"
    )
    messages.append({"role": response.choices[0].message.role, "content": response.choices[0].message.content})
    gpt_reply = messages[-1]["content"]
    print(f"GPT 回答：{gpt_reply}")
