OppaAI commited on
Commit
1327560
·
verified ·
1 Parent(s): 888e247

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import os
2
  import gradio as gr
 
3
  from smolagents import Agent
4
  from smolagents.mcp import MCPServerHTTP
5
  from smolagents.models import HuggingFaceModel
@@ -13,9 +14,9 @@ server = MCPServerHTTP(url=SSE_URL)
13
 
14
  # Use HF Qwen3-8B model from Hugging Face Hub
15
  hf_model = HuggingFaceModel(
16
- model_name="Qwen/Qwen-3-8B", # change this if you have exact repo name or path
17
  provider=HuggingFaceProvider(
18
- api_token="HF_TOKEN" # put your HF token here if required
19
  )
20
  )
21
 
@@ -24,19 +25,19 @@ agent = Agent(
24
  model=hf_model,
25
  mcp_servers=[server],
26
  instructions="""
27
- Your name is Jobcy. You are an AI assistant designed to help users to find remote jobs by searching through job listings from various sources, including the Jobicy API and other platforms.
28
- You will list the job listings in a structured format, including the job title, company, location, and the google search link.
29
  """,
30
  stream=False
31
  )
32
 
33
- def chat_with_agent(user_input, history):
34
  history = history or []
35
  history.append(("user", user_input))
36
 
37
- result = agent.run(user_input)
38
 
39
- history.append(("agent", result))
40
  return history, history
41
 
42
  with gr.Blocks() as demo:
@@ -47,4 +48,4 @@ with gr.Blocks() as demo:
47
  user_input.submit(chat_with_agent, inputs=[user_input, state], outputs=[chatbot, state])
48
 
49
  demo.title = "Jobcy Remote Job Search Assistant"
50
- demo.launch()
 
1
  import os
2
  import gradio as gr
3
+ import asyncio
4
  from smolagents import Agent
5
  from smolagents.mcp import MCPServerHTTP
6
  from smolagents.models import HuggingFaceModel
 
14
 
15
  # Use HF Qwen3-8B model from Hugging Face Hub
16
  hf_model = HuggingFaceModel(
17
+ model_name="Qwen/Qwen-3-8B",
18
  provider=HuggingFaceProvider(
19
+ api_token=HF_TOKEN
20
  )
21
  )
22
 
 
25
  model=hf_model,
26
  mcp_servers=[server],
27
  instructions="""
28
+ Your name is Jobcy. You are an AI assistant designed to help users find remote jobs by searching through job listings from various sources, including the Jobicy API and other platforms.
29
+ You will list the job listings in a structured format, including the job title, company, location, and the Google search link.
30
  """,
31
  stream=False
32
  )
33
 
34
+ async def chat_with_agent(user_input, history):
35
  history = history or []
36
  history.append(("user", user_input))
37
 
38
+ result = await agent.run(user_input)
39
 
40
+ history.append(("agent", result.output)) # result.output contains the answer text
41
  return history, history
42
 
43
  with gr.Blocks() as demo:
 
48
  user_input.submit(chat_with_agent, inputs=[user_input, state], outputs=[chatbot, state])
49
 
50
  demo.title = "Jobcy Remote Job Search Assistant"
51
+ demo.launch()