mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-07 00:16:57 +08:00
feat: improve context_tokens_k calculation and update Tencent provider name
This commit is contained in:
@@ -232,7 +232,7 @@ class LLMProviderManager(metaclass=Singleton):
|
|||||||
),
|
),
|
||||||
ProviderSpec(
|
ProviderSpec(
|
||||||
id="tencent",
|
id="tencent",
|
||||||
name="Tencent",
|
name="腾讯云",
|
||||||
runtime="openai_compatible",
|
runtime="openai_compatible",
|
||||||
models_dev_provider_id="tencent-tokenhub",
|
models_dev_provider_id="tencent-tokenhub",
|
||||||
default_base_url="https://tokenhub.tencentmaas.com/v1",
|
default_base_url="https://tokenhub.tencentmaas.com/v1",
|
||||||
@@ -562,6 +562,18 @@ class LLMProviderManager(metaclass=Singleton):
|
|||||||
else bool(metadata.get("reasoning"))
|
else bool(metadata.get("reasoning"))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if context_tokens:
|
||||||
|
try:
|
||||||
|
ct_int = int(context_tokens)
|
||||||
|
if ct_int % 1024 == 0 or ct_int == 1048576 or ct_int == 2097152:
|
||||||
|
context_tokens_k = max(1, ct_int // 1024)
|
||||||
|
else:
|
||||||
|
context_tokens_k = max(1, (ct_int + 999) // 1000)
|
||||||
|
except Exception:
|
||||||
|
context_tokens_k = None
|
||||||
|
else:
|
||||||
|
context_tokens_k = None
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"id": model_id,
|
"id": model_id,
|
||||||
"name": display_name or metadata.get("name") or model_id,
|
"name": display_name or metadata.get("name") or model_id,
|
||||||
@@ -569,9 +581,7 @@ class LLMProviderManager(metaclass=Singleton):
|
|||||||
"context_tokens": context_tokens,
|
"context_tokens": context_tokens,
|
||||||
"input_tokens": input_tokens,
|
"input_tokens": input_tokens,
|
||||||
"output_tokens": output_tokens,
|
"output_tokens": output_tokens,
|
||||||
"context_tokens_k": max(1, int((int(context_tokens) + 999) / 1000))
|
"context_tokens_k": context_tokens_k,
|
||||||
if context_tokens
|
|
||||||
else None,
|
|
||||||
"supports_reasoning": supports_reasoning,
|
"supports_reasoning": supports_reasoning,
|
||||||
"supports_tools": supports_tools,
|
"supports_tools": supports_tools,
|
||||||
"supports_image_input": supports_image_input,
|
"supports_image_input": supports_image_input,
|
||||||
|
|||||||
Reference in New Issue
Block a user