| import gradio as gr |
| from smolagents import CodeAgent, HfApiClient, DuckDuckGoSearchTool |
|
|
| |
| search_tool = DuckDuckGoSearchTool() |
|
|
| |
| agent = CodeAgent( |
| tools=[search_tool], |
| model=HfApiClient("Qwen/Qwen2.5-72B-Instruct"), |
| system_prompt=( |
| "You are Zquery1, an advanced AI search engine. " |
| "Your task is to search the web for the user's query, extract relevant facts, " |
| "and synthesize a clean response. Always include clickable source links " |
| "using markdown format: [Site Name](URL). Never use raw URLs." |
| ) |
| ) |
|
|
| def respond(message, history): |
| try: |
| |
| bot_response = agent.run(message) |
| return str(bot_response) |
| except Exception as e: |
| return f"An error occurred while fetching live data: {str(e)}" |
|
|
| |
| custom_css = """ |
| footer {visibility: hidden} |
| .gradio-container {background-color: transparent !important;} |
| """ |
|
|
| |
| with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo: |
| gr.Markdown("# <center>🔍 Zquery1 Web Search Engine</center>") |
| |
| gr.ChatInterface( |
| fn=respond, |
| examples=[ |
| "What are the top space discoveries this week?", |
| "Latest news about open source AI models", |
| "What is the current stock price of Apple?" |
| ], |
| cache_examples=False |
| ) |
|
|
| if __name__ == "__main__": |
| demo.launch() |
|
|