Spaces:
Runtime error
Runtime error
Download app.py from LogeshMurugan/agents: direct link, hf CLI and curl.
- Browser
- Download file 880 Bytes
-
https://huggingface.co/spaces/LogeshMurugan/agents/resolve/main/app.py
- Command line
-
hf download hf://spaces/LogeshMurugan/agents/app.py
-
curl -L -o app.py https://huggingface.co/spaces/LogeshMurugan/agents/resolve/main/app.py
880 Bytes
| import gradio as gr | |
| import requests | |
| from transformers import pipeline | |
| # Function to fetch Wikipedia summary | |
| def fetch_wikipedia_summary(topic): | |
| url = f"https://en.wikipedia.org/api/rest_v1/page/summary/{topic}" | |
| response = requests.get(url) | |
| if response.status_code == 200: | |
| data = response.json() | |
| return data.get("extract", "No summary available.") | |
| return "Error fetching data." | |
| # Function to fetch latest research papers from arXiv | |
| def fetch_arxiv_papers(query, max_results=3): | |
| base_url = "http://export.arxiv.org/api/query?" | |
| search_query = f"search_query=all:{query}&start=0&max_results={max_results}" | |
| response = requests.get(base_url + search_query) | |
| if response.status_code == 200: | |
| entries = response.text.split("<entry>") | |
| papers = [] | |
| for entry in entries[1:max_results + 1]: # Skip the first split part | |