un-index commited on
Commit
5e06490
·
1 Parent(s): dd62ca3
Files changed (2) hide show
  1. app.py +18 -15
  2. requirements.txt +1 -4
app.py CHANGED
@@ -20,15 +20,18 @@ import gradio as gr
20
 
21
  import requests
22
  def f(text):
23
- context = text
24
- payload = {
25
- "context": context,
26
- "token_max_length": 512,
27
- "temperature": 1.0,
28
- "top_p": 0.9,
29
- }
30
- response = requests.post("http://api.vicgalle.net:5000/generate", params=payload).json()
31
- # http://api.vicgalle.net:5000/docs#/default/generate_generate_post
 
 
 
32
  return response.text
33
 
34
 
@@ -39,13 +42,13 @@ iface.launch(enable_queue=True)
39
  # all below works but testing
40
  # import gradio as gr
41
 
42
- title = "GPT-J-6B"
43
 
44
- examples = [
45
- ['The tower is 324 metres (1,063 ft) tall,'],
46
- ["The Moon's orbit around Earth has"],
47
- ["The smooth Borealis basin in the Northern Hemisphere covers 40%"]
48
- ]
49
 
50
  # gr.Interface.load("huggingface/EleutherAI/gpt-j-6B",
51
  # inputs=gr.inputs.Textbox(lines=10, label="Input Text"),
 
20
 
21
  import requests
22
  def f(text):
23
+ try:
24
+ context = text
25
+ payload = {
26
+ "context": context,
27
+ "token_max_length": 512,
28
+ "temperature": 1.0,
29
+ "top_p": 0.9,
30
+ }
31
+ response = requests.post("http://api.vicgalle.net:5000/generate", params=payload).json()
32
+ # http://api.vicgalle.net:5000/docs#/default/generate_generate_post
33
+ except Exception as e:
34
+ return "error: \n"+str(e)
35
  return response.text
36
 
37
 
 
42
  # all below works but testing
43
  # import gradio as gr
44
 
45
+ # title = "GPT-J-6B"
46
 
47
+ # examples = [
48
+ # ['The tower is 324 metres (1,063 ft) tall,'],
49
+ # ["The Moon's orbit around Earth has"],
50
+ # ["The smooth Borealis basin in the Northern Hemisphere covers 40%"]
51
+ # ]
52
 
53
  # gr.Interface.load("huggingface/EleutherAI/gpt-j-6B",
54
  # inputs=gr.inputs.Textbox(lines=10, label="Input Text"),
requirements.txt CHANGED
@@ -1,4 +1 @@
1
- transformers
2
- flax
3
- tensorflow
4
- torch
 
1
+ requests