Spaces:
Sleeping
Sleeping
create app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,7 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
def get_answer(task, human_input, cooperate_style):
|
| 10 |
-
if cooperate_style=="sequential":
|
| 11 |
-
merged_text = merge_texts_sequential(task, human_input)
|
| 12 |
-
print(f"AI merged text: {merged_text}")
|
| 13 |
-
else:
|
| 14 |
-
generated_text = generate_text_with_gpt(task)
|
| 15 |
-
print(f"AI provided text: {generated_text}")
|
| 16 |
-
merged_text = merge_texts_parallel(task, human_input, generated_text)
|
| 17 |
-
return merged_text
|
| 18 |
-
|
| 19 |
-
def main():
|
| 20 |
-
with gr.Blocks() as demo:
|
| 21 |
-
task = gr.Textbox(label="Please Give a task description.")
|
| 22 |
-
human_input = gr.Textbox(label="Please provide a human answer.", value = "Write a poem about the moon.")
|
| 23 |
-
cooperate_style = gr.Radio(['sequential', 'parallel'], label="What type of cooperation would you like?")
|
| 24 |
-
greet_btn = gr.Button("Think!")
|
| 25 |
-
output = gr.Textbox(label="Answer with cooperation")
|
| 26 |
-
|
| 27 |
-
greet_btn.click(fn=get_answer,
|
| 28 |
-
inputs=[task, human_input, cooperate_style],
|
| 29 |
-
outputs=output,
|
| 30 |
-
api_name="answer")
|
| 31 |
-
|
| 32 |
-
evaluate_btn = gr.Button("Evaluate")
|
| 33 |
-
evaluation_results = gr.Textbox(label="Evaluation results.")
|
| 34 |
-
evaluate_btn.click(fn= evaluation,
|
| 35 |
-
inputs=[task, output],
|
| 36 |
-
outputs= evaluation_results,
|
| 37 |
-
api_name = "evaluate")
|
| 38 |
-
demo.launch(share=True)
|
| 39 |
-
|
| 40 |
-
if __name__ == "__main__":
|
| 41 |
-
main()
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def greet(name):
|
| 4 |
+
return "Hello " + name + "!!"
|
| 5 |
+
|
| 6 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
| 7 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|