akhaliq HF Staff commited on
Commit
8f11b16
·
1 Parent(s): 273e79c

add grok 4

Browse files
Files changed (2) hide show
  1. README.md +3 -0
  2. app.py +18 -0
README.md CHANGED
@@ -45,6 +45,7 @@ pip install -r requirements.txt
45
  export HF_TOKEN="your_huggingface_token"
46
  export TAVILY_API_KEY="your_tavily_api_key" # Optional, for web search feature
47
  export DASHSCOPE_API_KEY="your_dashscope_api_key" # Required for Qwen3-30B models via DashScope
 
48
  ```
49
 
50
  ## Usage
@@ -79,6 +80,8 @@ python app.py
79
  - Qwen3-30B-A3B-Thinking-2507 (via DashScope)
80
  - SmolLM3-3B
81
  - GLM-4.1V-9B-Thinking (multimodal)
 
 
82
 
83
  ## Input Options
84
 
 
45
  export HF_TOKEN="your_huggingface_token"
46
  export TAVILY_API_KEY="your_tavily_api_key" # Optional, for web search feature
47
  export DASHSCOPE_API_KEY="your_dashscope_api_key" # Required for Qwen3-30B models via DashScope
48
+ export POE_API_KEY="your_poe_api_key" # Required for GPT-5 and Grok-4 via Poe
49
  ```
50
 
51
  ## Usage
 
80
  - Qwen3-30B-A3B-Thinking-2507 (via DashScope)
81
  - SmolLM3-3B
82
  - GLM-4.1V-9B-Thinking (multimodal)
83
+ - GPT-5 (via Poe)
84
+ - Grok-4 (via Poe)
85
 
86
  ## Input Options
87
 
app.py CHANGED
@@ -495,6 +495,11 @@ AVAILABLE_MODELS = [
495
  "name": "GPT-5",
496
  "id": "gpt-5",
497
  "description": "OpenAI GPT-5 model for advanced code generation and general tasks"
 
 
 
 
 
498
  }
499
  ]
500
 
@@ -602,6 +607,12 @@ def get_inference_client(model_id, provider="auto"):
602
  api_key=os.getenv("POE_API_KEY"),
603
  base_url="https://api.poe.com/v1"
604
  )
 
 
 
 
 
 
605
  elif model_id == "step-3":
606
  # Use StepFun API client for Step-3 model
607
  return OpenAI(
@@ -2554,6 +2565,13 @@ This will help me create a better design for you."""
2554
  stream=True,
2555
  max_tokens=16384
2556
  )
 
 
 
 
 
 
 
2557
  else:
2558
  completion = client.chat.completions.create(
2559
  model=_current_model["id"],
 
495
  "name": "GPT-5",
496
  "id": "gpt-5",
497
  "description": "OpenAI GPT-5 model for advanced code generation and general tasks"
498
+ },
499
+ {
500
+ "name": "Grok-4",
501
+ "id": "grok-4",
502
+ "description": "Grok-4 model via Poe (OpenAI-compatible) for advanced tasks"
503
  }
504
  ]
505
 
 
607
  api_key=os.getenv("POE_API_KEY"),
608
  base_url="https://api.poe.com/v1"
609
  )
610
+ elif model_id == "grok-4":
611
+ # Use Poe (OpenAI-compatible) client for Grok-4 model
612
+ return OpenAI(
613
+ api_key=os.getenv("POE_API_KEY"),
614
+ base_url="https://api.poe.com/v1"
615
+ )
616
  elif model_id == "step-3":
617
  # Use StepFun API client for Step-3 model
618
  return OpenAI(
 
2565
  stream=True,
2566
  max_tokens=16384
2567
  )
2568
+ elif _current_model["id"] == "grok-4":
2569
+ completion = client.chat.completions.create(
2570
+ model="Grok-4",
2571
+ messages=messages,
2572
+ stream=True,
2573
+ max_tokens=16384
2574
+ )
2575
  else:
2576
  completion = client.chat.completions.create(
2577
  model=_current_model["id"],