Spaces:
Sleeping
Sleeping
json
Browse files
app.py
CHANGED
@@ -17,7 +17,6 @@ def extract_json(gen_text, n_shot_learning=0):
|
|
17 |
for i in range(0, n_shot_learning):
|
18 |
gen_text = gen_text[start_index:]
|
19 |
start_index = gen_text.index("### Response:\n{") + 14
|
20 |
-
|
21 |
end_index = gen_text.index("}\n\n### ") + 1
|
22 |
return gen_text[start_index:end_index]
|
23 |
|
@@ -47,9 +46,8 @@ def get_completion(prompt):
|
|
47 |
def greet(input):
|
48 |
response = get_completion(input)
|
49 |
gen_text = response["predictions"][0]["generated_text"]
|
50 |
-
|
51 |
return extract_json(gen_text, 3)
|
52 |
#return json.dumps(response)
|
53 |
|
54 |
-
iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Prompt", lines=3)], outputs="
|
55 |
iface.launch()
|
|
|
17 |
for i in range(0, n_shot_learning):
|
18 |
gen_text = gen_text[start_index:]
|
19 |
start_index = gen_text.index("### Response:\n{") + 14
|
|
|
20 |
end_index = gen_text.index("}\n\n### ") + 1
|
21 |
return gen_text[start_index:end_index]
|
22 |
|
|
|
46 |
def greet(input):
|
47 |
response = get_completion(input)
|
48 |
gen_text = response["predictions"][0]["generated_text"]
|
|
|
49 |
return extract_json(gen_text, 3)
|
50 |
#return json.dumps(response)
|
51 |
|
52 |
+
iface = gr.Interface(fn=greet, inputs=[gr.Textbox(label="Prompt", lines=3)], outputs="json")
|
53 |
iface.launch()
|