clarkchan commited on
Commit
1967004
1 Parent(s): b0eef1b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -1,10 +1,12 @@
1
  import gradio as gr
2
- from transformers import AutoTokenizer
3
- tokenizer = AutoTokenizer.from_pretrained("liam168/c2-roberta-base-finetuned-dianping-chinese")
4
- def greet(name):
5
- result = tokenizer([name],padding=True,truncation=True,return_tensors="pt")
6
- tensor_str = ','.join(map(str, result.input_ids.numpy()))
7
- decode_str = tokenizer.decode(result)
8
- return tensor_str,decode_str
9
- iface = gr.Interface(fn=greet, inputs="text", outputs=["text","text"])
 
 
10
  iface.launch(server_name="0.0.0.0")
 
1
  import gradio as gr
2
+ import requests
3
+ #from transformers import AutoTokenizer
4
+ #tokenizer = AutoTokenizer.from_pretrained("liam168/c2-roberta-base-finetuned-dianping-chinese")
5
+ def chat(input):
6
+ url = 'http://dark.21cnai.com:5000/api/chat'
7
+ data = { 'message': input }
8
+ headers = {'content-type': 'application/json','Authorization':'Bearer kdfjwoieskdflasdnf'}
9
+ response = requests.post(url, data=data, headers=headers)
10
+ return response
11
+ iface = gr.Interface(fn=chat, inputs="text", outputs=["text"])
12
  iface.launch(server_name="0.0.0.0")