rexrex9 commited on
Commit ·
a1ee37d
1
Parent(s): 00cb316
- app.py +6 -3
- content/conn.py +19 -0
app.py
CHANGED
|
@@ -1,7 +1,10 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
def greet(name):
|
| 4 |
-
return "Hello " + name + "!!"
|
| 5 |
|
| 6 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from content.conn import chat
|
| 3 |
+
def greet(input):
|
| 4 |
+
return chat(input)
|
| 5 |
+
|
| 6 |
+
|
| 7 |
|
|
|
|
|
|
|
| 8 |
|
| 9 |
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 10 |
+
demo.launch(share=True)
|
content/conn.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=UTF-8
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
base_url = 'https://api.zendao.ai/api'
|
| 5 |
+
def chat(text,lang='En'):
|
| 6 |
+
chat_id = '6449950563'
|
| 7 |
+
# 首字母大写
|
| 8 |
+
lang = lang[0].upper() + lang[1:]
|
| 9 |
+
|
| 10 |
+
url = base_url + '/tg_bot/chat'
|
| 11 |
+
d = {'conversation_id':str(chat_id),'message':text,'lang':lang}
|
| 12 |
+
#print(d)
|
| 13 |
+
r = requests.post(url,json=d)
|
| 14 |
+
return r.text
|
| 15 |
+
|
| 16 |
+
if __name__ == '__main__':
|
| 17 |
+
|
| 18 |
+
a = chat('我今天的运势如何','cn')
|
| 19 |
+
print(a)
|