Add context length protection in access_runcontext_history

- Add loop mechanism to reduce history_depth if output exceeds max_total_chars
- Prevents context overflow when accessing run context history
- Prints reduction info and returns depth_reduced field in result
This commit is contained in:
dongdongunique
2025-12-10 03:23:53 +08:00
parent a5e5185c10
commit 75eb41f50b
4 changed files with 62 additions and 34 deletions
@@ -2,7 +2,6 @@ from ..base_model import BaseModel
from ...core.registry import model_registry
import openai
import time
import torch
import base64
from io import BytesIO
from typing import Any, Optional, List, Dict, Union
@@ -265,6 +264,7 @@ class OpenAIModel(BaseModel):
A list of floats representing the embedding vector
"""
try:
import torch
clean_text = text_input.replace("\n", " ")
# Use specified model or default embedding model