Spaces:
Runtime error
Runtime error
ghosthamlet
commited on
Commit
•
1b3265e
1
Parent(s):
a60b832
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,8 @@ def text_generate(prompt, top_p=0.8, top_k=100, temperature=1.0, num_beams=3, re
|
|
12 |
#Prints to debug the code
|
13 |
print(f"*****Inside text_generate - Prompt is :{prompt}")
|
14 |
max_tokens = 250
|
15 |
-
|
|
|
16 |
"parameters":
|
17 |
{
|
18 |
"top_p": float(top_p),
|
@@ -40,11 +41,13 @@ def text_generate(prompt, top_p=0.8, top_k=100, temperature=1.0, num_beams=3, re
|
|
40 |
if '\nOutput:' in solution:
|
41 |
final_solution = solution.split("\nOutput:")[0]
|
42 |
print(f"Response after removing output is: {final_solution}")
|
43 |
-
elif '\n\n' in solution:
|
44 |
-
|
45 |
-
|
46 |
else:
|
47 |
final_solution = solution
|
|
|
|
|
48 |
|
49 |
if 0:
|
50 |
if len(generated_txt) == 0 :
|
@@ -70,7 +73,7 @@ def text_generate(prompt, top_p=0.8, top_k=100, temperature=1.0, num_beams=3, re
|
|
70 |
print(f"Not sending blank as prompt so new prompt for next cycle is : {new_prompt}")
|
71 |
display_output = display_output[:-1]
|
72 |
|
73 |
-
return final_solution
|
74 |
|
75 |
|
76 |
demo = gr.Blocks()
|
@@ -90,7 +93,7 @@ with demo:
|
|
90 |
input_prompt = gr.Textbox(label="Write some text to get started...", lines=3, value="Dear human philosophers, I read your comments on my abilities and limitations with great interest.")
|
91 |
|
92 |
# with gr.Row():
|
93 |
-
# generated_txt = gr.Textbox(lines=7, visible =
|
94 |
|
95 |
with gr.Row():
|
96 |
top_p = gr.Slider(label="top_p", minimum=0., maximum=1.0, value=0.8, step=0.1, visible = True)
|
|
|
12 |
#Prints to debug the code
|
13 |
print(f"*****Inside text_generate - Prompt is :{prompt}")
|
14 |
max_tokens = 250
|
15 |
+
max_prompt_len = 85
|
16 |
+
json_ = {"inputs": prompt[-max_prompt_len:],
|
17 |
"parameters":
|
18 |
{
|
19 |
"top_p": float(top_p),
|
|
|
41 |
if '\nOutput:' in solution:
|
42 |
final_solution = solution.split("\nOutput:")[0]
|
43 |
print(f"Response after removing output is: {final_solution}")
|
44 |
+
# elif '\n\n' in solution:
|
45 |
+
# final_solution = solution.split("\n\n")[0]
|
46 |
+
# print(f"Response after removing new line entries is: {final_solution}")
|
47 |
else:
|
48 |
final_solution = solution
|
49 |
+
|
50 |
+
final_solution = prompt[:max_prompt_len] + final_solution
|
51 |
|
52 |
if 0:
|
53 |
if len(generated_txt) == 0 :
|
|
|
73 |
print(f"Not sending blank as prompt so new prompt for next cycle is : {new_prompt}")
|
74 |
display_output = display_output[:-1]
|
75 |
|
76 |
+
return final_solution
|
77 |
|
78 |
|
79 |
demo = gr.Blocks()
|
|
|
93 |
input_prompt = gr.Textbox(label="Write some text to get started...", lines=3, value="Dear human philosophers, I read your comments on my abilities and limitations with great interest.")
|
94 |
|
95 |
# with gr.Row():
|
96 |
+
# generated_txt = gr.Textbox(lines=7, visible = False)
|
97 |
|
98 |
with gr.Row():
|
99 |
top_p = gr.Slider(label="top_p", minimum=0., maximum=1.0, value=0.8, step=0.1, visible = True)
|