TomLii commited on
Commit
69abb97
·
1 Parent(s): 4938fee

Improve public Space configuration UX

Browse files
Files changed (2) hide show
  1. README.md +9 -0
  2. app.py +19 -2
README.md CHANGED
@@ -38,6 +38,15 @@ python app.py
38
  4. Optional Variables:
39
  - `DEFAULT_MODEL` (default: `Qwen/Qwen2.5-7B-Instruct`)
40
 
 
 
 
 
 
 
 
 
 
41
  ## 3) Free Model First, Your Model Later
42
 
43
  You can start with a free inference model, then switch by changing only env/config:
 
38
  4. Optional Variables:
39
  - `DEFAULT_MODEL` (default: `Qwen/Qwen2.5-7B-Instruct`)
40
 
41
+ ### Public Space Configuration Checklist
42
+
43
+ If the Space is public and you want users to run it directly:
44
+
45
+ 1. Keep the Space **Visibility** as Public.
46
+ 2. Add `HF_TOKEN` in **Secrets** (required by this starter).
47
+ 3. Click **Restart this Space** after saving the secret.
48
+ 4. Open the app and run a simple query like: `What is retrieval-augmented generation?`
49
+
50
  ## 3) Free Model First, Your Model Later
51
 
52
  You can start with a free inference model, then switch by changing only env/config:
app.py CHANGED
@@ -12,6 +12,11 @@ from huggingface_hub import InferenceClient
12
 
13
 
14
  DEFAULT_MODEL = os.getenv("DEFAULT_MODEL", "Qwen/Qwen2.5-7B-Instruct")
 
 
 
 
 
15
 
16
  SYSTEM_PROMPT = """You are a Deep Research assistant.
17
  You can think step by step, use tools, and then return a final answer.
@@ -238,6 +243,12 @@ def run_ui(
238
  ):
239
  if not question.strip():
240
  return "Please input a question.", "{}"
 
 
 
 
 
 
241
  try:
242
  return build_research_agent(
243
  question=question,
@@ -256,7 +267,7 @@ with gr.Blocks(title="DeepResearch Space Starter") as demo:
256
  # DeepResearch Space Starter
257
  Ask a question, and the agent will iteratively search and visit pages before producing a final answer.
258
 
259
- This starter uses a free HF Inference model by default. You can switch models later with environment variables.
260
  """
261
  )
262
 
@@ -267,7 +278,13 @@ This starter uses a free HF Inference model by default. You can switch models la
267
  placeholder="e.g. Compare top open-source deep research agents and summarize differences.",
268
  lines=4,
269
  )
270
- model = gr.Textbox(label="Model", value=DEFAULT_MODEL)
 
 
 
 
 
 
271
  with gr.Row():
272
  max_turns = gr.Slider(label="Max Turns", minimum=2, maximum=20, value=8, step=1)
273
  max_search_results = gr.Slider(
 
12
 
13
 
14
  DEFAULT_MODEL = os.getenv("DEFAULT_MODEL", "Qwen/Qwen2.5-7B-Instruct")
15
+ DEFAULT_FREE_MODELS = [
16
+ "Qwen/Qwen2.5-7B-Instruct",
17
+ "meta-llama/Llama-3.1-8B-Instruct",
18
+ "mistralai/Mistral-7B-Instruct-v0.3",
19
+ ]
20
 
21
  SYSTEM_PROMPT = """You are a Deep Research assistant.
22
  You can think step by step, use tools, and then return a final answer.
 
243
  ):
244
  if not question.strip():
245
  return "Please input a question.", "{}"
246
+ if not os.getenv("HF_TOKEN"):
247
+ warning = (
248
+ "HF_TOKEN is not configured in Space Secrets. "
249
+ "Go to Settings -> Secrets -> add `HF_TOKEN`, then retry."
250
+ )
251
+ return warning, json.dumps({"error": warning}, ensure_ascii=False, indent=2)
252
  try:
253
  return build_research_agent(
254
  question=question,
 
267
  # DeepResearch Space Starter
268
  Ask a question, and the agent will iteratively search and visit pages before producing a final answer.
269
 
270
+ This starter uses free HF Inference models by default. You can switch models later with environment variables.
271
  """
272
  )
273
 
 
278
  placeholder="e.g. Compare top open-source deep research agents and summarize differences.",
279
  lines=4,
280
  )
281
+ model = gr.Dropdown(
282
+ label="Model",
283
+ choices=DEFAULT_FREE_MODELS,
284
+ value=DEFAULT_MODEL if DEFAULT_MODEL in DEFAULT_FREE_MODELS else DEFAULT_FREE_MODELS[0],
285
+ allow_custom_value=True,
286
+ info="You can also type your own model id.",
287
+ )
288
  with gr.Row():
289
  max_turns = gr.Slider(label="Max Turns", minimum=2, maximum=20, value=8, step=1)
290
  max_search_results = gr.Slider(