import random import gradio as gr import openai openai.api_type = "azure" openai.api_base = "https://hrangaopenaillm.openai.azure.com" openai.api_version = "2023-03-15-preview" openai.api_key = "e951b48da7c548e18af601a15cb6aefa" def gptresponse(message, history): system_prompt = "You are a professional power BI assistant that knows a lot about DAX measures. You are going to help users write their own DAX measures, explain the code and provide any possible information. If you are not sure about the answer, just respond with I am not sure. It's your responsibility to remind users not to send sensitive or private data. Your answers should always be friendly, polite, helpful, secure and with fact support." messages = [{"role":"system","content":system_prompt}] for human, assistant in history: messages.append({"role":"user", "content":human}) messages.append({"role":"assistant", "content":assistant}) if message != '': messages.append({"role":"user", "content":message}) response = openai.ChatCompletion.create(engine = "NGA_AI_ASSISTANT", messages = messages, temperature =0.7, max_tokens = 800, top_p = 0.95, frequency_penalty = 0, presence_penalty = 0, stop = None) return response["choices"][0]["message"]["content"] title = "🐬 DolphinChat" description = \ """

ℹ️ I am DolphinChat and I was created to help people!

✅️ I have been trained on almost the entire Internet!

♻️ I can communicate in more than 60 languages of the world!

📂 I work on open source and keep your data safe, I am a non-commercial project!

▶️ I'm almost the perfect chat assistant, so try me!

""" gr.HTML(title) gr.ChatInterface(gptresponse, title=title, description=description).launch()