Spaces:
Sleeping
Sleeping
Create app.py
Browse files
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()
|