codingwithadi commited on
Commit
530fa5d
Β·
verified Β·
1 Parent(s): 159527f

Show landing page when credentials not configured

Browse files
Files changed (1) hide show
  1. openmark/ui/app.py +76 -54
openmark/ui/app.py CHANGED
@@ -120,63 +120,85 @@ def stats_fn():
120
  # ── Build UI ──────────────────────────────────────────────────
121
 
122
  def build_ui():
123
- categories = ["All"] + config.CATEGORIES
124
-
125
  with gr.Blocks(title="OpenMark") as app:
126
  gr.Markdown("# OpenMark β€” Your Personal Knowledge Graph")
127
 
128
- with gr.Tabs():
129
-
130
- # Tab 1: Chat
131
- with gr.Tab("Chat"):
132
- thread = gr.Textbox(value="default", label="Session ID", scale=1)
133
- chatbot = gr.Chatbot(height=500)
134
- msg_box = gr.Textbox(
135
- placeholder="Ask anything about your saved bookmarks...",
136
- label="Message", lines=2,
137
- )
138
- send_btn = gr.Button("Send", variant="primary")
139
-
140
- send_btn.click(
141
- chat_fn,
142
- inputs=[msg_box, chatbot, thread],
143
- outputs=[chatbot, msg_box],
144
- )
145
- msg_box.submit(
146
- chat_fn,
147
- inputs=[msg_box, chatbot, thread],
148
- outputs=[chatbot, msg_box],
149
- )
150
-
151
- # Tab 2: Search
152
- with gr.Tab("Search"):
153
- with gr.Row():
154
- q_input = gr.Textbox(placeholder="Search your knowledge base...", label="Query", scale=3)
155
- cat_input = gr.Dropdown(categories, value="All", label="Category")
156
- with gr.Row():
157
- score_input = gr.Slider(0, 10, value=0, step=1, label="Min Quality Score")
158
- n_input = gr.Slider(5, 50, value=10, step=5, label="Results")
159
- search_btn = gr.Button("Search", variant="primary")
160
- search_output = gr.Markdown()
161
-
162
- search_btn.click(
163
- search_fn,
164
- inputs=[q_input, cat_input, score_input, n_input],
165
- outputs=search_output,
166
- )
167
- q_input.submit(
168
- search_fn,
169
- inputs=[q_input, cat_input, score_input, n_input],
170
- outputs=search_output,
171
- )
172
-
173
- # Tab 3: Stats
174
- with gr.Tab("Stats"):
175
- refresh_btn = gr.Button("Refresh Stats")
176
- stats_output = gr.Markdown()
177
-
178
- refresh_btn.click(stats_fn, outputs=stats_output)
179
- app.load(stats_fn, outputs=stats_output)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
 
181
  return app
182
 
 
120
  # ── Build UI ──────────────────────────────────────────────────
121
 
122
  def build_ui():
 
 
123
  with gr.Blocks(title="OpenMark") as app:
124
  gr.Markdown("# OpenMark β€” Your Personal Knowledge Graph")
125
 
126
+ if _setup_error:
127
+ # No credentials β€” show landing page only
128
+ gr.Markdown(
129
+ "**8,000+ bookmarks, LinkedIn saves, and YouTube videos** indexed with "
130
+ "[pplx-embed](https://huggingface.co/collections/perplexity-ai/pplx-embed), "
131
+ "searchable with ChromaDB and Neo4j, queryable via a LangGraph agent.\n\n"
132
+ "Built by [Ahmad Othman Ammar Adi](https://github.com/OthmanAdi) Β· "
133
+ "[GitHub](https://github.com/OthmanAdi/OpenMark) Β· "
134
+ "[Dataset](https://huggingface.co/datasets/codingwithadi/openmark-bookmarks)\n\n"
135
+ "---\n\n"
136
+ "## Run it yourself\n\n"
137
+ "This Space requires your own data and credentials. "
138
+ "Clone the repo and follow the setup guide:\n\n"
139
+ "```bash\n"
140
+ "git clone https://github.com/OthmanAdi/OpenMark.git\n"
141
+ "cd OpenMark\n"
142
+ "pip install -r requirements.txt\n"
143
+ "cp .env.example .env # add your keys\n"
144
+ "python scripts/ingest.py\n"
145
+ "python openmark/ui/app.py\n"
146
+ "```"
147
+ )
148
+ else:
149
+ categories = ["All"] + config.CATEGORIES
150
+ with gr.Tabs():
151
+
152
+ # Tab 1: Chat
153
+ with gr.Tab("Chat"):
154
+ thread = gr.Textbox(value="default", label="Session ID", scale=1)
155
+ chatbot = gr.Chatbot(height=500)
156
+ msg_box = gr.Textbox(
157
+ placeholder="Ask anything about your saved bookmarks...",
158
+ label="Message", lines=2,
159
+ )
160
+ send_btn = gr.Button("Send", variant="primary")
161
+
162
+ send_btn.click(
163
+ chat_fn,
164
+ inputs=[msg_box, chatbot, thread],
165
+ outputs=[chatbot, msg_box],
166
+ )
167
+ msg_box.submit(
168
+ chat_fn,
169
+ inputs=[msg_box, chatbot, thread],
170
+ outputs=[chatbot, msg_box],
171
+ )
172
+
173
+ # Tab 2: Search
174
+ with gr.Tab("Search"):
175
+ with gr.Row():
176
+ q_input = gr.Textbox(placeholder="Search your knowledge base...", label="Query", scale=3)
177
+ cat_input = gr.Dropdown(categories, value="All", label="Category")
178
+ with gr.Row():
179
+ score_input = gr.Slider(0, 10, value=0, step=1, label="Min Quality Score")
180
+ n_input = gr.Slider(5, 50, value=10, step=5, label="Results")
181
+ search_btn = gr.Button("Search", variant="primary")
182
+ search_output = gr.Markdown()
183
+
184
+ search_btn.click(
185
+ search_fn,
186
+ inputs=[q_input, cat_input, score_input, n_input],
187
+ outputs=search_output,
188
+ )
189
+ q_input.submit(
190
+ search_fn,
191
+ inputs=[q_input, cat_input, score_input, n_input],
192
+ outputs=search_output,
193
+ )
194
+
195
+ # Tab 3: Stats
196
+ with gr.Tab("Stats"):
197
+ refresh_btn = gr.Button("Refresh Stats")
198
+ stats_output = gr.Markdown()
199
+
200
+ refresh_btn.click(stats_fn, outputs=stats_output)
201
+ app.load(stats_fn, outputs=stats_output)
202
 
203
  return app
204