Spaces:
Build error
Build error
Update app.py
Browse files123456789101112131415161718192021222324252627import gradio as grimport openaiopenai.api_key = "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"messages = [{"role": "system", "content": "You are a financial expert that specializes in real estate investment and negotiation."}]def CustomChatGPT(user_input):if len(messages) > 10:messages.pop(0)messages.append({"role": "user", "content": user_input})response = openai.ChatCompletion.create(model="gpt-3.5-turbo",prompt="".join([message["content"] for message in messages]),temperature=0.7,max_tokens=1024,n=1,stop=None,frequency_penalty=0,presence_penalty=0,)ChatGPT_reply = response.choices[0].textmessages.append({"role": "assistant", "content": ChatGPT_reply})return ChatGPT_replyiface = gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title="ChatBot")iface.launch(debug=True)123456789101112131415161718192021import osimport openaios.system("pip install gradio==3.19.1")import gradio as gropenai.api_key = "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"messages = [{"role": "system", "content": "You are a financial experts that specializes in real estate investment and negotiation"}]def CustomChatGPT(user_input):messages.append({"role": "user", "content": user_input})response = openai.ChatCompletion.create(model = "gpt-3.5-turbo",messages = messages)ChatGPT_reply = response["choices"][0]["message"]["content"]messages.append({"role": "assistant", "content": ChatGPT_reply})return ChatGPT_replyiface = gr.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title = "ChatBot")iface.launch(debug = True)
app.py+9-15