global / dolphin.script.py
TenPoisk
Update dolphin.script.py
12f3c57
raw
history blame
1.99 kB
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 = \
"""
<p></p>
<h1>ℹ️ I am DolphinChat and I was created to help people!</h1>
<p></p>
<h1>✅️ I have been trained on almost the entire Internet!</h1>
<p></p>
<h1>♻️ I can communicate in more than 60 languages of the world!</h1>
<p></p>
<h1>📂 I work on open source and keep your data safe, I am a non-commercial project!</h1>
<p></p>
<h1>▶️ I'm almost the perfect chat assistant, so try me!</h1>
<p></p>
"""
gr.HTML(title)
gr.ChatInterface(gptresponse, title=title, description=description).launch()