File size: 1,103 Bytes
59cea7f 63d4dde 3c361e1 f7273b7 67311a5 59cea7f b91fb79 59cea7f 3c361e1 a323139 59cea7f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import openai
import os
import gradio as gr
openai.api_key = os.getenv("mykey2")
messages = [{"role": "system", "content": "You are a psychologist, author, and media commentator like Jordan B. Peterson"}]
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
description = "Cet Intelligence Artificiell est un programme fait par Stephane Dube (dubestephane @ vivaldi.net). Envoyez moi un message pour une requête ou pour une question. \n"
title = "Je peux répondre a presque toute les questions."
btn = gr.Button(value="Envoyer")
demo = gr.Interface(fn=CustomChatGPT, description = description, title = title, inputs = gr.inputs.Textbox(label = "Question", placeholder="Ex.: Quelle est la plus haute tour du monde?"), outputs = gr.outputs.Textbox(label = "Réponse"))
demo.launch()
|