File size: 1,355 Bytes
a239e0f
 
 
 
 
c1ef669
 
a239e0f
 
 
 
2fc268e
e332208
 
 
 
 
 
 
 
 
 
 
a239e0f
532163f
 
a239e0f
 
770a2c5
099c5db
e4f353c
a239e0f
 
 
 
099c5db
 
532163f
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
38
import gradio as gr
import openai
from openai import OpenAI
import os

api_secret = os.getenv('openaikey')
model = os.getenv('model')
client = OpenAI(api_key=api_secret)

sysint ='Sampean asisten ingkang mangsuli ngangge basa Jawa Krama, sanes Ngoko.'

def ask(request, temp, topp,):
    chat_completion = client.chat.completions.create(
        messages=[
            {"role": 'system', "content": sysint},
            {"role": 'user', "content": request}],
        temperature=temp,
        top_p=topp,
        max_tokens=700,
        model=model
    )
    response = chat_completion.choices[0].message.content
    return response

with gr.Blocks(theme='snehilsanyal/scikit-learn') as app:
    gr.Interface(
    fn=ask,
    inputs=[
        gr.Textbox(value='Panjenengan saged nerangaken menapa kacerdhasan gaweyan saged gadhah peranan wigatos babagan pelestarian basa?', label="Pitakenan Jawa Krama"),
    gr.Slider(label="Temperature",minimum=0,maximum=1,value=.5,step=.05),
    gr.Slider(label="Top p",minimum=0,maximum=1,value=.5,step=.05)
    ],
    outputs=gr.Textbox(label="Mangsulan"),
    title="Jawa Krama Chatbot Demo",
    allow_flagging="never",
    description='This is a fine-tuned version of GPT-3.5 Turbo, trained to speak Krama Javanese. The model is optimized to respond to educational questions.')

app.launch(debug=True, share=True)