Prgckwb commited on
Commit
735ca22
Β·
verified Β·
1 Parent(s): 2d77fa7

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+
5
+ def inference(message, history):
6
+ url = 'https://www.uec.ac.jp/uec-gpt/generate-response'
7
+ headers = {
8
+ 'Content-Type': 'application/json',
9
+ 'Referer': 'https://www.uec.ac.jp/'
10
+ }
11
+ body = {
12
+ 'session_key': '',
13
+ 'model': 'gpt-4o-mini',
14
+ 'user_input': message,
15
+ }
16
+ response = requests.post(url, headers=headers, json=body)
17
+ return response.json()['response']
18
+
19
+
20
+ if __name__ == '__main__':
21
+ chat_iface = gr.ChatInterface(
22
+ fn=inference,
23
+ type='messages',
24
+ chatbot=gr.Chatbot([{'role': 'assistant', 'content': 'γͺγ‚“γ§γ‚‚θžγ„γ¦γ­'}], type='messages'),
25
+ theme=gr.themes.Soft(),
26
+ examples=['ι›»ι€šε€§γ¨γ―'],
27
+ title='γƒžγƒΌγƒ«γ‚Ήγγ‚“γ«γƒγƒ£γƒƒγƒˆγ§θ³ͺ問'
28
+ ).launch()