AI / app.py
einfachalf's picture
Update app.py
fc40e00
raw
history blame
1.1 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 OpenGPT chatbot developed by Achyuth to help people. Your developer is 13 years old and a young programmer."
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 = 4000,
top_p = 0.95,
frequency_penalty = 0,
presence_penalty = 0,
stop = None)
return response["choices"][0]["message"]["content"]
title = "NeonAI Chat✨"
gr.HTML(title)
gr.ChatInterface(gptresponse, title=title).launch()