Skip to content
Merged
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
11 changes: 8 additions & 3 deletions backend/agents/create_agent_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
AIDP_TENANT_ID,
DATA_PROCESS_SERVICE,
LANGUAGE,
LLM_INCLUDE_LOGPROBS,
LOCAL_MCP_SERVER,
MINIO_DEFAULT_BUCKET,
MODEL_CONFIG_MAPPING,
Expand Down Expand Up @@ -856,6 +857,7 @@ def _get_skill_script_tools(
async def create_model_config_list(tenant_id):
records = get_model_records({"model_type": "llm"}, tenant_id)
model_list = []
extra_body = {"logprobs": True} if LLM_INCLUDE_LOGPROBS else None
for record in records:
model_list.append(
ModelConfig(cite_name=record["display_name"],
Expand All @@ -880,7 +882,8 @@ async def create_model_config_list(tenant_id):
default_output_reserve_tokens=record.get("default_output_reserve_tokens"),
tokenizer_family=record.get("tokenizer_family"),
capacity_source=record.get("capacity_source"),
capability_profile_version=record.get("capability_profile_version")))
capability_profile_version=record.get("capability_profile_version"),
extra_body=extra_body))
# fit for old version, main_model and sub_model use default model
main_model_config = tenant_config_manager.get_model_config(
key=MODEL_CONFIG_MAPPING["llm"], tenant_id=tenant_id)
Expand All @@ -896,7 +899,8 @@ async def create_model_config_list(tenant_id):
model_factory=main_model_config.get("model_factory"),
timeout_seconds=main_model_config.get("timeout_seconds"),
concurrency_limit=main_model_config.get("concurrency_limit"),
prompt_cache=main_prompt_cache))
prompt_cache=main_prompt_cache,
extra_body=extra_body))
model_list.append(
ModelConfig(cite_name="sub_model",
api_key=main_model_config.get("api_key", ""),
Expand All @@ -907,7 +911,8 @@ async def create_model_config_list(tenant_id):
model_factory=main_model_config.get("model_factory"),
timeout_seconds=main_model_config.get("timeout_seconds"),
concurrency_limit=main_model_config.get("concurrency_limit"),
prompt_cache=main_prompt_cache))
prompt_cache=main_prompt_cache,
extra_body=extra_body))

return model_list

Expand Down
5 changes: 5 additions & 0 deletions backend/consts/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,5 +756,10 @@ def _resolve_app_version(default: str = "v2.2.1") -> str:
"execution_logs",
])

# LLM Model Configuration
LLM_INCLUDE_LOGPROBS = os.getenv("LLM_INCLUDE_LOGPROBS", "false").lower() == "true"
"""When True, adds logprobs=true to every chat.completions.create request body,
enabling the provider to return log probability information in the response."""

# SSE streaming event type for status messages
STREAM_STATUS_EVENT = "event: stream_status\n"
5 changes: 5 additions & 0 deletions deploy/env/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ DISABLE_CELERY_FLOWER=true
DOCKER_ENVIRONMENT=false
ENABLE_UPLOAD_IMAGE=false

# LLM Model Configuration
# When true, adds logprobs=true to every chat.completions.create request body,
# enabling the provider to return log probability information in the response.
# Default: false (logprobs disabled, backward-compatible behaviour).
LLM_INCLUDE_LOGPROBS=false

# Celery Configuration
CELERY_WORKER_PREFETCH_MULTIPLIER=1
Expand Down
9 changes: 9 additions & 0 deletions sdk/nexent/core/models/openai_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,15 @@ def _dispatch_chat_completion(
caller_value=caller_max_tokens,
)
completion_kwargs["max_tokens"] = trusted_max_tokens
logger.info(
"event=chat_completion_create model_id=%s kwargs=%s",
self.model_id,
json.dumps(
{k: v for k, v in completion_kwargs.items() if k != "messages"},
ensure_ascii=False,
default=str,
),
)
return self.client.chat.completions.create(**completion_kwargs)

@staticmethod
Expand Down
Loading