Spaces:
Runtime error
Runtime error
Feed finder function done.
Browse files- assets/html.py +2 -2
- functions/helper_functions.py +1 -0
- functions/tools.py +16 -12
- rss_server.py +8 -9
assets/html.py
CHANGED
|
@@ -3,9 +3,9 @@
|
|
| 3 |
TITLE = (
|
| 4 |
'''
|
| 5 |
<center>
|
| 6 |
-
<h1>
|
| 7 |
</center>
|
| 8 |
'''
|
| 9 |
)
|
| 10 |
|
| 11 |
-
DESCRIPTION = 'Enter
|
|
|
|
| 3 |
TITLE = (
|
| 4 |
'''
|
| 5 |
<center>
|
| 6 |
+
<h1>RSS feed finder</h1>
|
| 7 |
</center>
|
| 8 |
'''
|
| 9 |
)
|
| 10 |
|
| 11 |
+
DESCRIPTION = 'Enter a website to crawl for RSS feed URI.'
|
functions/helper_functions.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
'''Helper functions for MCP tools.'''
|
functions/tools.py
CHANGED
|
@@ -1,18 +1,22 @@
|
|
| 1 |
'''Tool functions for MCP server'''
|
| 2 |
|
|
|
|
| 3 |
|
| 4 |
-
def letter_counter(word, letter):
|
| 5 |
-
"""
|
| 6 |
-
Count the number of occurrences of a letter in a word or text.
|
| 7 |
|
|
|
|
|
|
|
|
|
|
| 8 |
Args:
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
Returns:
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
'''Tool functions for MCP server'''
|
| 2 |
|
| 3 |
+
from findfeed import search
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
def get_feed(url: str) -> str:
|
| 7 |
+
'''Finds the RSS feed URI for a website given the website's url.
|
| 8 |
+
|
| 9 |
Args:
|
| 10 |
+
url: The url for the website to find the RSS feed for
|
| 11 |
+
|
|
|
|
| 12 |
Returns:
|
| 13 |
+
The website's RSS feed URI as a string
|
| 14 |
+
'''
|
| 15 |
+
|
| 16 |
+
feeds = search(url)
|
| 17 |
+
|
| 18 |
+
if len(feeds) > 0:
|
| 19 |
+
return str(feeds[0].url)
|
| 20 |
+
|
| 21 |
+
else:
|
| 22 |
+
return f'No feed found for {url}'
|
rss_server.py
CHANGED
|
@@ -11,16 +11,15 @@ with gr.Blocks() as demo:
|
|
| 11 |
gr.HTML(html.TITLE)
|
| 12 |
|
| 13 |
gr.Markdown(html.DESCRIPTION)
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
inputs=[input_word, target_letter],
|
| 22 |
outputs=output,
|
| 23 |
-
api_name='
|
| 24 |
)
|
| 25 |
|
| 26 |
|
|
|
|
| 11 |
gr.HTML(html.TITLE)
|
| 12 |
|
| 13 |
gr.Markdown(html.DESCRIPTION)
|
| 14 |
+
website_url = gr.Textbox('hackernews.com', label='Website URL')
|
| 15 |
+
output = gr.Textbox(label='RSS feed URI')
|
| 16 |
+
submit_button = gr.Button('Submit')
|
| 17 |
+
|
| 18 |
+
submit_button.click( # pylint: disable=no-member
|
| 19 |
+
fn=tool_funcs.get_feed,
|
| 20 |
+
inputs=website_url,
|
|
|
|
| 21 |
outputs=output,
|
| 22 |
+
api_name='get_feed'
|
| 23 |
)
|
| 24 |
|
| 25 |
|