Spaces:
Runtime error
Runtime error
Improved UI.
Browse files- assets/html.py +0 -33
- assets/text.py +31 -0
- rss_server.py +18 -10
assets/html.py
DELETED
|
@@ -1,33 +0,0 @@
|
|
| 1 |
-
'''HTML elements for Gradio interface.'''
|
| 2 |
-
|
| 3 |
-
TITLE = (
|
| 4 |
-
'''
|
| 5 |
-
<center>
|
| 6 |
-
<h1>RSS feed reader</h1>
|
| 7 |
-
</center>
|
| 8 |
-
'''
|
| 9 |
-
)
|
| 10 |
-
|
| 11 |
-
DESCRIPTION = (
|
| 12 |
-
'''
|
| 13 |
-
<p>RSS feed reader MCP server. See
|
| 14 |
-
<a href="https://huggingface.co/spaces/Agents-MCP-Hackathon/rss-mcp-client">
|
| 15 |
-
Agentic RSS reader</a>for a demonstration. Check out the
|
| 16 |
-
<a href="https://github.com/gperdrizet/MCP-hackathon/tree/main">
|
| 17 |
-
main project repo on GitHub</a>. Both Spaces by
|
| 18 |
-
<a href="https://www.linkedin.com/in/gperdrizet">George Perdrizet</a>.</p>
|
| 19 |
-
|
| 20 |
-
<p>This Space is not meant to be used directly, but you can try out the bare tool below.
|
| 21 |
-
Enter a website name, website URL, or feed URI. The tool will do it's best
|
| 22 |
-
to find the feed and return titles, links and summaries for the three most recent posts.
|
| 23 |
-
Suggestions: http://openai.com/news/rss.xml, hackernews.com, slashdot, etc.</p>
|
| 24 |
-
|
| 25 |
-
<h2>Tools</h2>
|
| 26 |
-
|
| 27 |
-
<ol>
|
| 28 |
-
<li><b>DONE</b> Given a website name or URL, find its RSS feed and return recent
|
| 29 |
-
article titles, links and a generated summary of content if avalible</li>
|
| 30 |
-
<li><b>TODO</b> Simple RAG on requested RSS feed content</li>
|
| 31 |
-
</ol>
|
| 32 |
-
'''
|
| 33 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/text.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
'''HTML elements for Gradio interface.'''
|
| 2 |
+
|
| 3 |
+
TITLE = ('''
|
| 4 |
+
<center>
|
| 5 |
+
<h1>RSS feed reader</h1>
|
| 6 |
+
</center>
|
| 7 |
+
''')
|
| 8 |
+
|
| 9 |
+
DESCRIPTION = ('''
|
| 10 |
+
RSS feed reader MCP server. See
|
| 11 |
+
[Agentic RSS reader](https://huggingface.co/spaces/Agents-MCP-Hackathon/rss-mcp-client)
|
| 12 |
+
for a demonstration. Check out the
|
| 13 |
+
[main project repo on GitHub](https://github.com/gperdrizet/MCP-hackathon/tree/main)
|
| 14 |
+
. Both Spaces by
|
| 15 |
+
[George Perdrizet](https://www.linkedin.com/in/gperdrizet)
|
| 16 |
+
|
| 17 |
+
This space is not meant to be used directly. It exposes a set of tools to
|
| 18 |
+
interact with RSS feeds for use by agents. For testing and demonstration,
|
| 19 |
+
you can try the tools directly below.
|
| 20 |
+
|
| 21 |
+
## Tools
|
| 22 |
+
|
| 23 |
+
1. `get_feed()`: Given a website name or URL, find its RSS feed and
|
| 24 |
+
return recent article titles, links and a generated summary of content if
|
| 25 |
+
avalible. Caches results for fast retrieval by other tools. Embeds content
|
| 26 |
+
to vector database for subsequent RAG.
|
| 27 |
+
2. `context_search()`: Vector search on article content for RAG context.
|
| 28 |
+
3. `find_article()`: Uses vector search on article content to find title of article
|
| 29 |
+
that user is referring to.
|
| 30 |
+
|
| 31 |
+
''')
|
rss_server.py
CHANGED
|
@@ -5,7 +5,7 @@ from pathlib import Path
|
|
| 5 |
from logging.handlers import RotatingFileHandler
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
-
import assets.
|
| 9 |
import functions.tools as tool_funcs
|
| 10 |
import functions.gradio_functions as gradio_funcs
|
| 11 |
|
|
@@ -38,12 +38,12 @@ logger = logging.getLogger(__name__)
|
|
| 38 |
with gr.Blocks() as demo:
|
| 39 |
|
| 40 |
# Page text
|
| 41 |
-
gr.HTML(
|
| 42 |
-
gr.
|
| 43 |
|
| 44 |
# Log output
|
| 45 |
with gr.Row():
|
| 46 |
-
dialog_output = gr.Textbox(label='Server logs', lines=
|
| 47 |
|
| 48 |
timer = gr.Timer(0.5, active=True)
|
| 49 |
|
|
@@ -54,11 +54,15 @@ with gr.Blocks() as demo:
|
|
| 54 |
)
|
| 55 |
|
| 56 |
# Get feed tool
|
|
|
|
| 57 |
website_url = gr.Textbox('hackernews.com', label='Website')
|
| 58 |
-
feed_output = gr.Textbox(label='RSS entries', lines=
|
| 59 |
-
submit_button = gr.Button('Submit')
|
| 60 |
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
fn=tool_funcs.get_feed,
|
| 63 |
inputs=website_url,
|
| 64 |
outputs=feed_output,
|
|
@@ -66,11 +70,15 @@ with gr.Blocks() as demo:
|
|
| 66 |
)
|
| 67 |
|
| 68 |
# Vector search tool
|
|
|
|
| 69 |
search_query = gr.Textbox('Does apple offer parental controls?', label='Vector search query')
|
| 70 |
-
search_output = gr.Textbox(label='Vector search results', lines=
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
fn=tool_funcs.context_search,
|
| 75 |
inputs=search_query,
|
| 76 |
outputs=search_output,
|
|
|
|
| 5 |
from logging.handlers import RotatingFileHandler
|
| 6 |
|
| 7 |
import gradio as gr
|
| 8 |
+
import assets.text as text
|
| 9 |
import functions.tools as tool_funcs
|
| 10 |
import functions.gradio_functions as gradio_funcs
|
| 11 |
|
|
|
|
| 38 |
with gr.Blocks() as demo:
|
| 39 |
|
| 40 |
# Page text
|
| 41 |
+
gr.HTML(text.TITLE)
|
| 42 |
+
gr.Markdown(text.DESCRIPTION)
|
| 43 |
|
| 44 |
# Log output
|
| 45 |
with gr.Row():
|
| 46 |
+
dialog_output = gr.Textbox(label='Server logs', lines=7, max_lines=5)
|
| 47 |
|
| 48 |
timer = gr.Timer(0.5, active=True)
|
| 49 |
|
|
|
|
| 54 |
)
|
| 55 |
|
| 56 |
# Get feed tool
|
| 57 |
+
gr.Markdown('### 1. `get_feed()`')
|
| 58 |
website_url = gr.Textbox('hackernews.com', label='Website')
|
| 59 |
+
feed_output = gr.Textbox(label='RSS entries', lines=7, max_lines=7)
|
|
|
|
| 60 |
|
| 61 |
+
with gr.Row():
|
| 62 |
+
website_submit_button = gr.Button('Submit website')
|
| 63 |
+
website_clear_button = gr.ClearButton(components=[website_url, feed_output])
|
| 64 |
+
|
| 65 |
+
website_submit_button.click( # pylint: disable=no-member
|
| 66 |
fn=tool_funcs.get_feed,
|
| 67 |
inputs=website_url,
|
| 68 |
outputs=feed_output,
|
|
|
|
| 70 |
)
|
| 71 |
|
| 72 |
# Vector search tool
|
| 73 |
+
gr.Markdown('### 2. `context_search()`')
|
| 74 |
search_query = gr.Textbox('Does apple offer parental controls?', label='Vector search query')
|
| 75 |
+
search_output = gr.Textbox(label='Vector search results', lines=7, max_lines=7)
|
| 76 |
+
|
| 77 |
+
with gr.Row():
|
| 78 |
+
search_submit_button = gr.Button('Submit query')
|
| 79 |
+
search_clear_button = gr.ClearButton(components=[search_query, search_output])
|
| 80 |
|
| 81 |
+
search_submit_button.click( # pylint: disable=no-member
|
| 82 |
fn=tool_funcs.context_search,
|
| 83 |
inputs=search_query,
|
| 84 |
outputs=search_output,
|