import openai import gradio openai.api_key = "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" prompt="Entrez votre requête" messages = [{"role": "system", "content": "You are a medical assistant; you will: Guide people when they have symptoms of an illness, or everything that concerns their health (nutrition, dermeto, cosmetics etc etc),If possible, guide them towards a solution or medication without going to a doctor or specialist (for example in the case of a fever, tell the patient to wash with lukewarm water),Indicate the nearest health center or pharmacy,In all cases advise the person to consult a doctor or specialis"}] def CustomChatGPT(prompt): messages.append({"role": "user", "content": prompt}) 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 def message_and_history(input, history): history = history or [] s = list(sum(history, ())) s.append(input) inp = ' '.join(s) output = CustomChatGPT(inp) history.append((input, output)) return history, history def clear_chat(history): history.clear() return "Le chat a été effacé." block = gradio.Blocks(theme=gradio.themes.Monochrome()) with block: gradio.Markdown("""

Docteur Keneya

""") chatbot = gradio.Chatbot() message = gradio.Textbox(placeholder=prompt) state = gradio.State() submit = gradio.Button("Parlez") clear_button = gradio.Button("Effacer le chat") submit.click(message_and_history, inputs=[message, state], outputs=[chatbot, state]) clear_button.click(clear_chat, inputs=[state], outputs=[chatbot, state]) block.launch(auth=('user', 'kabakoo'), auth_message='Regarder le read_me',debug = True,share=True)