Zakomako4567 commited on
Commit
bbda6f5
·
verified ·
1 Parent(s): 02b9ec8

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from smolagents import CodeAgent, HfApiClient, DuckDuckGoSearchTool
3
+
4
+ # Initialize search capability
5
+ search_tool = DuckDuckGoSearchTool()
6
+
7
+ # Set up Zquery1 agent with a highly optimized model for search task handling
8
+ agent = CodeAgent(
9
+ tools=[search_tool],
10
+ model=HfApiClient("Qwen/Qwen2.5-72B-Instruct"),
11
+ system_prompt=(
12
+ "You are Zquery1, an advanced AI search engine. "
13
+ "Your task is to search the web for the user's query, extract relevant facts, "
14
+ "and synthesize a clean response. Always include clickable source links "
15
+ "using markdown format: [Site Name](URL). Never use raw URLs."
16
+ )
17
+ )
18
+
19
+ def respond(message, history):
20
+ try:
21
+ # Run agent search pipeline
22
+ bot_response = agent.run(message)
23
+ return str(bot_response)
24
+ except Exception as e:
25
+ return f"An error occurred while fetching live data: {str(e)}"
26
+
27
+ # Custom CSS styling to make the embedded UI sleek and seamless
28
+ custom_css = """
29
+ footer {visibility: hidden}
30
+ .gradio-container {background-color: transparent !important;}
31
+ """
32
+
33
+ # Build interface configured for embedding
34
+ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
35
+ gr.Markdown("# <center>🔍 Zquery1 Web Search Engine</center>")
36
+
37
+ gr.ChatInterface(
38
+ fn=respond,
39
+ examples=[
40
+ "What are the top space discoveries this week?",
41
+ "Latest news about open source AI models",
42
+ "What is the current stock price of Apple?"
43
+ ],
44
+ cache_examples=False
45
+ )
46
+
47
+ if __name__ == "__main__":
48
+ demo.launch()