Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -21,11 +21,12 @@ def answer_question(question,api_key,graph):
|
|
21 |
kg = graph[0]
|
22 |
return kg.chat_qa(question)
|
23 |
|
24 |
-
def clear_graph(api_key,graph):
|
25 |
graph = []
|
26 |
kg = KnowledgeGraph(api_key)
|
27 |
graph.append(kg)
|
28 |
-
|
|
|
29 |
|
30 |
title = "GPT-4 Knowledge Graph Generator"
|
31 |
description = "Enter text to generate a knowledge graph using GPT4KG:"
|
@@ -45,6 +46,6 @@ with gr.Blocks() as demo:
|
|
45 |
qa_btn.click(fn=answer_question, inputs=[question,api_key,graph], outputs=[answer])
|
46 |
|
47 |
clear_btn = gr.Button("Clear graph")
|
48 |
-
clear_btn.click(fn=clear_graph, inputs=[api_key,graph], outputs=[graph,output_image],api_name="clear")
|
49 |
|
50 |
demo.launch()
|
|
|
21 |
kg = graph[0]
|
22 |
return kg.chat_qa(question)
|
23 |
|
24 |
+
def clear_graph(api_key,graph,output_image):
|
25 |
graph = []
|
26 |
kg = KnowledgeGraph(api_key)
|
27 |
graph.append(kg)
|
28 |
+
w, h = output_image.size
|
29 |
+
return graph,Image.new('RGB', (w, h),(255, 255, 255))
|
30 |
|
31 |
title = "GPT-4 Knowledge Graph Generator"
|
32 |
description = "Enter text to generate a knowledge graph using GPT4KG:"
|
|
|
46 |
qa_btn.click(fn=answer_question, inputs=[question,api_key,graph], outputs=[answer])
|
47 |
|
48 |
clear_btn = gr.Button("Clear graph")
|
49 |
+
clear_btn.click(fn=clear_graph, inputs=[api_key,graph,output_image], outputs=[graph,output_image],api_name="clear")
|
50 |
|
51 |
demo.launch()
|