Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ AGNES_API_KEY = "<YOUR_KEY>"

# SILICONFLOW_API_KEY
SILICONFLOW_API_KEY = "<YOUR_KEY>"

# aliyun
ALIYUN_API_KEY="<YOUR_KEY>"
42 changes: 42 additions & 0 deletions llm_inference/model_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def __init__(self):
self.minimax_api_key = os.getenv("MINIMAX_API_KEY")
self.agnes_api_key = os.getenv("AGNES_API_KEY")
self.siliconflow_api_key = os.getenv("SILICONFLOW_API_KEY")
self.aliyun_api_key = os.getenv("ALIYUN_API_KEY")

def infer(
self, model_name: str, prompt: str, max_retries: int = 3
Expand Down Expand Up @@ -97,6 +98,8 @@ def infer(
return self._call_agnes(model_name, prompt)
elif provider == "siliconflow":
return self._call_siliconflow(model_name, prompt)
elif provider == "aliyun":
return self._call_aliyun(model_name, prompt)

else:
# Default to Together API for most open-source models
Expand Down Expand Up @@ -217,6 +220,8 @@ def _get_provider(self, model_name: str) -> str:
# Siliconflow
"THUDM/GLM-4-9B-0414": "siliconflow",
"deepseek-ai/DeepSeek-R1-0528-Qwen3-8B": "siliconflow",
"deepseek-v4-flash-0731": "aliyun",
"agnes-3.0-flash": "agnes",
}

# Check if exact model name is in mapping
Expand Down Expand Up @@ -833,6 +838,43 @@ def _call_siliconflow(self, model_name: str, prompt: str) -> Dict[str, Any]:
"provider": "siliconflow",
}

def _call_aliyun(self, model_name: str, prompt: str) -> Dict[str, Any]:
"""Call Aliyun API."""
import openai

client = openai.OpenAI(
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
api_key=self.aliyun_api_key,
)

response = client.chat.completions.create(
model=model_name.replace("openai/", ""),
messages=[{"role": "user", "content": prompt}],
)

usage = getattr(response, "usage", None)
input_tokens = getattr(usage, "prompt_tokens", 0) if usage is not None else 0
completion_tokens = (
getattr(usage, "completion_tokens", 0) if usage is not None else 0
)
total_tokens = (
getattr(usage, "total_tokens", 0)
if usage is not None
else input_tokens + completion_tokens
)

return {
"response": response.choices[0].message.content,
"success": True,
"token_usage": {
"input_tokens": input_tokens,
"output_tokens": completion_tokens,
"total_tokens": total_tokens,
},
"model_used": model_name,
"provider": "aliyun",
}

def _call_aws(self, model_name: str, prompt: str) -> Dict[str, Any]:
"""Call AWS Bedrock API."""
import boto3
Expand Down
8 changes: 8 additions & 0 deletions model_cost/model_cost.json
Original file line number Diff line number Diff line change
Expand Up @@ -730,5 +730,13 @@
"z-ai/glm-5.3-flash@default": {
"input_token_price_per_million": 0.15,
"output_token_price_per_million": 0.5
},
"agnes-3.0-flash": {
"input_token_price_per_million": 0.05,
"output_token_price_per_million": 0.15
},
"deepseek-v4-flash-0731": {
"input_token_price_per_million": 0.21,
"output_token_price_per_million": 0.64
}
}
12 changes: 12 additions & 0 deletions model_cost/model_profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -550,3 +550,15 @@ models:
as_of: "2026-10-31"
source: "https://openrouter.ai/z-ai/glm-5.3-flash"
note: "Unified spellings; previous prices: glm-5.3-flash 0.15/0.5; z-ai/glm-5.3-flash 0.15/0.5."
"agnes-3.0-flash":
price: {input: 0.05, output: 0.15}
as_of: "2026-11-27"
source: null
note: "Not listed on OpenRouter."
sync: false
"deepseek-v4-flash-0731":
price: {input: 0.21, output: 0.64}
as_of: "2026-11-27"
source: null
note: "provided by aliyu."
sync: false
13 changes: 13 additions & 0 deletions router_inference/config/Paix3-router.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"pipeline_params": {
"router_name": "Paix3-router",
"router_cls_name": "MyPaix2Router",
"models": [
"MiniMax-M3",
"agnes-3.0-flash",
"deepseek-v4-flash-0731",
"THUDM/GLM-4-9B-0414"

]
}
}
3,782 changes: 3,782 additions & 0 deletions router_inference/predictions/Paix3-router-robustness.json

Large diffs are not rendered by default.

205,715 changes: 205,715 additions & 0 deletions router_inference/predictions/Paix3-router.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions universal_model_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@
"upstage/solar-pro3",
"upstage/solar-pro4",
"z-ai/glm-5.3-flash",
"deepseek-v4-flash-0731",
"agnes-3.0-flash",
]


Expand Down