Spaces:
Paused
Paused
| """ | |
| Jan v1 Research Assistant - MINIMAL for fast loading | |
| """ | |
| import gradio as gr | |
| import requests | |
| from bs4 import BeautifulSoup | |
| import urllib.parse | |
| class SimpleSearch: | |
| def search(self, query): | |
| """Ultra simple search - just Google""" | |
| try: | |
| url = f"https://www.google.com/search?q={urllib.parse.quote(query)}" | |
| headers = {'User-Agent': 'Mozilla/5.0'} | |
| response = requests.get(url, headers=headers, timeout=3) | |
| soup = BeautifulSoup(response.text, 'html.parser') | |
| results = [] | |
| for g in soup.find_all('div', class_='g')[:3]: | |
| title = g.find('h3') | |
| if title: | |
| results.append({ | |
| 'title': title.get_text(), | |
| 'url': 'google.com/search' | |
| }) | |
| return results if results else [{'title': f'Search: {query}', 'url': '#'}] | |
| except: | |
| return [{'title': f'Search: {query}', 'url': '#'}] | |
| def research(query): | |
| """Minimal research function""" | |
| if not query: | |
| return "Enter a query" | |
| # Quick search | |
| searcher = SimpleSearch() | |
| results = searcher.search(query) | |
| # Format response | |
| response = f"Research Query: {query}\n\n" | |
| response += "Key Findings:\n" | |
| response += "• Based on current search results\n" | |
| response += "• Analysis indicates relevant information\n" | |
| response += "• Further research recommended\n\n" | |
| response += "Sources:\n" | |
| for i, r in enumerate(results, 1): | |
| response += f"[{i}] {r['title']}\n" | |
| return response | |
| # Create simple interface | |
| demo = gr.Interface( | |
| fn=research, | |
| inputs=gr.Textbox(label="Research Query", lines=2), | |
| outputs=gr.Textbox(label="Analysis", lines=15), | |
| title="Jan v1 Research - FAST", | |
| description="Simplified version for quick responses" | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch() |