artificialguybr commited on
Commit
b44dadb
1 Parent(s): 015af8d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -16
app.py CHANGED
@@ -134,25 +134,32 @@ def generate_knowledge_graph(api_key, user_input):
134
  title_and_description = """
135
  # Instagraph - Knowledge Graph Generator
136
 
137
- This interactive knowledge graph generator is inspired by [this GitHub project](https://github.com/yoheinakajima/instagraph/).
138
-
139
  Enter your OpenAI API Key and a question, and let the AI create a detailed knowledge graph for you.
140
 
141
- You can input a URL to scrape text for generating the knowledge graph. Rest assured, the code is open for your inspection to ensure safety.
142
  """
143
 
144
- # Create the Gradio interface with queueing enabled and concurrency_count set to 10
145
- iface = gr.Interface(
146
- fn=generate_knowledge_graph,
147
- inputs=[
148
- gr.inputs.Textbox(label="OpenAI API Key", type="password"),
149
- gr.inputs.Textbox(label="User Input for Graph or URL", type="text"),
150
- ],
151
- outputs=gr.outputs.Image(type="pil", label="Generated Knowledge Graph"),
152
- live=False,
153
- title=title_and_description,
154
- )
 
 
 
 
 
 
 
155
 
156
  # Enable queueing system for multiple users
157
- iface.queue(concurrency_count=10)
158
- iface.launch()
 
 
 
134
  title_and_description = """
135
  # Instagraph - Knowledge Graph Generator
136
 
 
 
137
  Enter your OpenAI API Key and a question, and let the AI create a detailed knowledge graph for you.
138
 
139
+ **New Feature:** You can now input a URL to scrape text for generating the knowledge graph. Rest assured, the code is open for your inspection to ensure safety.
140
  """
141
 
142
+ with gr.Blocks() as app:
143
+ gr.Markdown(title_and_description)
144
+
145
+ with gr.Row():
146
+ with gr.Column():
147
+ result_image = gr.Image(type="pil", label="Generated Knowledge Graph")
148
+
149
+ with gr.Row():
150
+ with gr.Column():
151
+ api_key = gr.Textbox(label="OpenAI API Key", type="password")
152
+ user_input = gr.Textbox(label="User Input for Graph or URL", type="text")
153
+ run_btn = gr.Button("Generate")
154
+
155
+ run_btn.click(
156
+ generate_knowledge_graph,
157
+ inputs=[api_key, user_input],
158
+ outputs=[result_image]
159
+ )
160
 
161
  # Enable queueing system for multiple users
162
+ app.queue(concurrency_count=10)
163
+
164
+ print("Iniciando a interface Gradio...")
165
+ app.launch()