ysharma HF staff commited on
Commit
0ba02be
·
1 Parent(s): 063bf56

update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -16,16 +16,6 @@ headers = {"Authorization": f"Bearer {HF_TOKEN}"}
16
  #})
17
 
18
 
19
- # GPT-J-6B API
20
- #API_URL = "https://api-inference.huggingface.co/models/EleutherAI/gpt-j-6B"
21
- #HF_TOKEN = os.environ["HF_TOKEN"]
22
- #headers = {"Authorization": f"Bearer {HF_TOKEN}"}
23
- #word: bird
24
- #poem using word: She sights a bird, she chuckles
25
- #She flattens, then she crawls
26
- #She runs without the look of feet
27
- #Her eyes increase to Balls.
28
-
29
  prompt1 = """
30
  word: risk
31
  poem using word: And then the day came,
@@ -48,12 +38,10 @@ prompt3 = """Q: A juggler can juggle 16 balls. Half of the balls are golf balls,
48
  A: Let’s think step by step.
49
  """
50
 
51
- examples = [["river"], ["night"], ["trees"],["table"],["laughs"]]
52
 
53
 
54
  def text_generate(prompt):
55
 
56
- #p = prompt .lower() + "\n" + "poem using word: "
57
  print(f"*****Inside poem_generate - Prompt is :{prompt}")
58
  json_ = {"inputs": prompt,
59
  "parameters":
@@ -69,7 +57,7 @@ def text_generate(prompt):
69
  print(f"output is : {output}") #{output}")
70
  output_tmp = output[0]['generated_text']
71
  print(f"Bloom response without splits is: {output_tmp}")
72
- solution = output[0]['generated_text'].split("\n\n")[0] # +"."
73
  print(f"Final response after splits is: {solution}")
74
  #if "\n\n" not in output_tmp:
75
  # if output_tmp.find('.') != -1:
@@ -82,7 +70,7 @@ def text_generate(prompt):
82
  # poem = output_tmp.split("\n\n")[0] # +"."
83
  #poem = poem.replace('?','')
84
  #print(f"Poem being returned is: {poem}")
85
- return output #response #output_tmp #poem
86
 
87
 
88
  demo = gr.Blocks()
@@ -93,7 +81,7 @@ with demo:
93
  """Testing Bloom """
94
  )
95
  with gr.Row():
96
- example_prompt = gr.Radio( ["Q: A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there? \nA: Let’s think step by step.\n"], label= "Choose a sample Prompt")
97
  #input_word = gr.Textbox(placeholder="Enter a word here to generate text ...")
98
  generated_txt = gr.Textbox(lines=7)
99
  #output_image = gr.Image(type="filepath", shape=(256,256))
 
16
  #})
17
 
18
 
 
 
 
 
 
 
 
 
 
 
19
  prompt1 = """
20
  word: risk
21
  poem using word: And then the day came,
 
38
  A: Let’s think step by step.
39
  """
40
 
 
41
 
42
 
43
  def text_generate(prompt):
44
 
 
45
  print(f"*****Inside poem_generate - Prompt is :{prompt}")
46
  json_ = {"inputs": prompt,
47
  "parameters":
 
57
  print(f"output is : {output}") #{output}")
58
  output_tmp = output[0]['generated_text']
59
  print(f"Bloom response without splits is: {output_tmp}")
60
+ solution = output[0]['generated_text'].split("\nQ:")[0] # +"."
61
  print(f"Final response after splits is: {solution}")
62
  #if "\n\n" not in output_tmp:
63
  # if output_tmp.find('.') != -1:
 
70
  # poem = output_tmp.split("\n\n")[0] # +"."
71
  #poem = poem.replace('?','')
72
  #print(f"Poem being returned is: {poem}")
73
+ return solution #output #response #output_tmp #poem
74
 
75
 
76
  demo = gr.Blocks()
 
81
  """Testing Bloom """
82
  )
83
  with gr.Row():
84
+ example_prompt = gr.Radio( ["Q: A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there?\nA: Let’s think step by step.\n"], label= "Choose a sample Prompt")
85
  #input_word = gr.Textbox(placeholder="Enter a word here to generate text ...")
86
  generated_txt = gr.Textbox(lines=7)
87
  #output_image = gr.Image(type="filepath", shape=(256,256))