# import libraries import os import gradio as gr from dotenv import load_dotenv, dotenv_values import openai load_dotenv() openai.organization = os.getenv("ORG_KEY") openai.api_key = os.getenv("OPENAI_API_KEY") def ai_response(query): completion = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "assistant", "content": os.getenv("Prompt_doctor") }, {"role": "user", "content": query } ], stop = [" Human:", " AI:"] ) return completion["choices"][0]["message"]["content"] def create_ui(query,past): output = ai_response(query) past.append((query,output)) return None , past with gr.Blocks(theme=gr.themes.Glass()) as demo: gr.Markdown("