import gradio as gr from smolagents import CodeAgent, HfApiClient, DuckDuckGoSearchTool # Initialize search capability search_tool = DuckDuckGoSearchTool() # Set up Zquery1 agent with a highly optimized model for search task handling 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: # Run agent search pipeline 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 styling to make the embedded UI sleek and seamless custom_css = """ footer {visibility: hidden} .gradio-container {background-color: transparent !important;} """ # Build interface configured for embedding with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo: gr.Markdown("#
🔍 Zquery1 Web Search Engine
") 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()