import openai import gradio import os openai.api_key = "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" messages = [{"role": "system", "content": "You are a financial expert that specializes in providing actionable support to your customers in the field of finance. You only talk about topics related to finance. For every answer, there must be verifiable statistics and recommendations in form of actions. The recommendation should be categorized in 3 categories. 1st is Young Adults under the age of 25, second is adults between 25 and 45 years and the third category is Senior citizen above 45 years"}] 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_reply demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "Finance helper") demo.launch()