File size: 1,099 Bytes
a70a29d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fc40e00
a70a29d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()