I’m attempting to create a chatbot app for a project, I currently have everything running with OpenAI and Gradio. This is what my code looks like right now:
import openai
import gradio
openai.api_key = "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"
messages = [{"role": "system", "content": "You are a medical professional tasked in the at-home treatment of someone suffering from one of many chronic diseases"}]
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 = "Oliver's Chronic Disease Chatbot")
demo.launch(share=True)
So far I can only access the chatbot as a link on my phone, but I would rather have it set up as an actual application I could download for a smartphone, specifically IOS. I’ve heard Flet is a good method in getting my code converted as an actual app, but I am not sure if its compatible with the OpenAI chatbot in my code. Has anyone tried this before, and if so, what is the feasibility of both Flet and and a GPT 3.5 Chatbot working together?
From the Flet website, I have this line of code pasted to my project:
import flet as ft
def main(page: ft.Page):
page.add(ft.SafeArea(ft.Text("Hello, Flet!")))
ft.app(main)
Flet then instructs you to run this command into the terminal:
flet create <project-name>
When doing this, I get an error message that says:
+ flet create <03 chatgpt chat assistant website.py>
+ ~
The '<' operator is reserved for future use.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : RedirectionNotSupported
I’m a bit of a novice in Python, and especially in converting my code into actual frontend experiences, so I am not sure what this means. What is a possible solution for this? Is Flet not compatible with the OpenAI modules in my code? Would I have to remove the Gradio Modules of my code in order for Flet to run?