Skip to content

Bug: LLM Model temperature field ignored in create/update API #247

@yong-cn

Description

@yong-cn

Bug Description

The temperature field in the LLM Model Pool API is silently ignored — it is never persisted to the database on both create and update operations, despite being fully defined in schema, model, and migration.

Environment

  • File: backend/app/api/enterprise.py

Root Cause

Bug 1: POST /api/enterprise/llm-models (create)

In add_llm_model(), the LLMModel constructor receives all fields from LLMModelCreate except temperature:

model = LLMModel(
    provider=data.provider,
    model=data.model,
    api_key_encrypted=data.api_key,
    base_url=data.base_url,
    label=data.label,
    # temperature=data.temperature,  # <-- MISSING
    max_tokens_per_day=data.max_tokens_per_day,
    enabled=data.enabled,
    supports_vision=data.supports_vision,
    tenant_id=uuid.UUID(tid) if tid else None,
)
###Bug 2 - PUT /api/enterprise/llm-models/{model_id} (update):
update_llm_model() 里漏了# if data.temperature is not None:

#     model.temperature = data.temperature

Fix--- a/backend/app/api/enterprise.py

+++ b/backend/app/api/enterprise.py

@@ -122,6 +122,7 @@ async def add_llm_model(

         api_key_encrypted=data.api_key,

         base_url=data.base_url,

         label=data.label,

+        temperature=data.temperature,

         max_tokens_per_day=data.max_tokens_per_day,

         enabled=data.enabled,

         supports_vision=data.supports_vision,

@@ -199,6 +200,8 @@ async def update_llm_model(

         if data.api_key and data.api_key.strip() and not data.api_key.startswith('****'):

             model.api_key_encrypted = data.api_key.strip()

+        if data.temperature is not None:

+            model.temperature = data.temperature

         if data.max_tokens_per_day is not None:

             model.max_tokens_per_day = data.max_tokens_per_day

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions