ZahirJS commited on
Commit
a2fe2e6
·
verified ·
1 Parent(s): 9912372

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -1
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import json
3
  from graphviz import Digraph
4
- import io
5
  import base64
6
 
7
  def generate_concept_map(json_input: str) -> str:
@@ -125,9 +124,37 @@ def generate_concept_map(json_input: str) -> str:
125
  return f"Error: {str(e)}"
126
 
127
  if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  demo = gr.Interface(
129
  fn=generate_concept_map,
130
  inputs=gr.Textbox(
 
131
  placeholder="Paste structured JSON here...",
132
  label="JSON Input",
133
  lines=15
 
1
  import gradio as gr
2
  import json
3
  from graphviz import Digraph
 
4
  import base64
5
 
6
  def generate_concept_map(json_input: str) -> str:
 
124
  return f"Error: {str(e)}"
125
 
126
  if __name__ == "__main__":
127
+ # Sample JSON for placeholder
128
+ sample_json = """
129
+ {
130
+ "central_node": "Artificial Intelligence (AI)",
131
+ "nodes": [
132
+ {
133
+ "id": "ml",
134
+ "label": "Machine Learning",
135
+ "relationship": "core_component",
136
+ "subnodes": [
137
+ {"id": "sl", "label": "Supervised Learning", "relationship": "type_of"},
138
+ {"id": "ul", "label": "Unsupervised Learning", "relationship": "type_of"}
139
+ ]
140
+ },
141
+ {
142
+ "id": "nlp",
143
+ "label": "Natural Language Processing",
144
+ "relationship": "application_area",
145
+ "subnodes": [
146
+ {"id": "sa", "label": "Sentiment Analysis", "relationship": "technique"},
147
+ {"id": "tr", "label": "Translation", "relationship": "technique"}
148
+ ]
149
+ }
150
+ ]
151
+ }
152
+ """
153
+
154
  demo = gr.Interface(
155
  fn=generate_concept_map,
156
  inputs=gr.Textbox(
157
+ value=sample_json, # Pre-filled sample JSON
158
  placeholder="Paste structured JSON here...",
159
  label="JSON Input",
160
  lines=15