Update app.py
Browse files
app.py
CHANGED
|
@@ -21,12 +21,11 @@ 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 |
-
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,6 +45,6 @@ with gr.Blocks() as demo:
|
|
| 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
|
| 50 |
|
| 51 |
demo.launch()
|
|
|
|
| 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 |
+
return graph,Image.new('RGB', (400, 100),(255, 255, 255))
|
|
|
|
| 29 |
|
| 30 |
title = "GPT-4 Knowledge Graph Generator"
|
| 31 |
description = "Enter text to generate a knowledge graph using GPT4KG:"
|
|
|
|
| 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()
|