Код: Выделить всё
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)
С веб-сайта Flet я вставил эту строку кода в мой проект:
Код: Выделить всё
import flet as ft
def main(page: ft.Page):
page.add(ft.SafeArea(ft.Text("Hello, Flet!")))
ft.app(main)
Код: Выделить всё
flet create
Код: Выделить всё
+ flet create
+ ~
The '
Подробнее здесь: [url]https://stackoverflow.com/questions/78680213/possible-way-to-have-openai-code-run-on-flet[/url]
Мобильная версия