File size: 1,592 Bytes
bbda6f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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("# <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()