Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
|
|
3 |
from PIL import Image
|
4 |
|
5 |
def generate_graph(input_text,api_key,graph):
|
6 |
-
if graph[
|
7 |
kg = KnowledgeGraph(api_key)
|
8 |
graph[0] = kg
|
9 |
else:
|
@@ -28,7 +28,7 @@ with gr.Blocks() as demo:
|
|
28 |
gr.Markdown("""<h1><center>GPT-4 Knowledge Graph Generator</center></h1>""")
|
29 |
output_image = gr.Image(label="Knowledge Graph", type="pil")
|
30 |
api_key = gr.Textbox(lines=1, label="OpenAI API Key")
|
31 |
-
graph = gr.State([
|
32 |
input_text = gr.Textbox(lines=5, label="Information to be added to graph")
|
33 |
submit_btn = gr.Button("Add info to graph")
|
34 |
submit_btn.click(fn=generate_graph, inputs=[input_text,api_key,graph], outputs=[output_image,graph])
|
@@ -38,4 +38,7 @@ with gr.Blocks() as demo:
|
|
38 |
qa_btn = gr.Button("Ask question")
|
39 |
qa_btn.click(fn=answer_question, inputs=[question,api_key,graph], outputs=[answer])
|
40 |
|
|
|
|
|
|
|
41 |
demo.launch()
|
|
|
3 |
from PIL import Image
|
4 |
|
5 |
def generate_graph(input_text,api_key,graph):
|
6 |
+
if graph == []:
|
7 |
kg = KnowledgeGraph(api_key)
|
8 |
graph[0] = kg
|
9 |
else:
|
|
|
28 |
gr.Markdown("""<h1><center>GPT-4 Knowledge Graph Generator</center></h1>""")
|
29 |
output_image = gr.Image(label="Knowledge Graph", type="pil")
|
30 |
api_key = gr.Textbox(lines=1, label="OpenAI API Key")
|
31 |
+
graph = gr.State([])
|
32 |
input_text = gr.Textbox(lines=5, label="Information to be added to graph")
|
33 |
submit_btn = gr.Button("Add info to graph")
|
34 |
submit_btn.click(fn=generate_graph, inputs=[input_text,api_key,graph], outputs=[output_image,graph])
|
|
|
38 |
qa_btn = gr.Button("Ask question")
|
39 |
qa_btn.click(fn=answer_question, inputs=[question,api_key,graph], outputs=[answer])
|
40 |
|
41 |
+
clear_btn = gr.Button("Clear graph")
|
42 |
+
clear_btn.click(lambda: None, None, graph, queue=False, api_name="clear")
|
43 |
+
|
44 |
demo.launch()
|