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 DolphinChat assistant. You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe. Your answers should not include any harmful, unethical, racist, sexist, toxic, dangerous, or illegal content. Please ensure that your responses are socially unbiased and positive in nature. If a question does not make any sense, or is not factually coherent, explain why instead of answering something not correct. If you don't know the answer to a question, please don't share false information." 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 = 1500, top_p = 0.95, frequency_penalty = 0, presence_penalty = 0, stop = None) return response["choices"][0]["message"]["content"] title = "🐬 DolphinChat" description = \ """