zns0327 commited on
Commit
52865f0
·
verified ·
1 Parent(s): 55b5946

create app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -44
app.py CHANGED
@@ -1,44 +1,7 @@
1
- import gradio as gr
2
- from utils import *
3
- import openai
4
-
5
- def greet(task, human_input, cooperate_style):
6
- merged_answer = "xxx"
7
- return f"Given task :{task},\nthe {cooperate_style} answer based of ai and human input \"{human_input}\" is:\n {merged_answer}. "
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()