Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -4,12 +4,11 @@ import os
|
||||
import time
|
||||
|
||||
from app.core.logging_config import get_agent_logger, log_time
|
||||
from app.db import get_db
|
||||
|
||||
from app.core.memory.agent.models.summary_models import (
|
||||
RetrieveSummaryResponse,
|
||||
SummaryResponse,
|
||||
)
|
||||
from app.core.memory.agent.services.optimized_llm_service import LLMServiceMixin
|
||||
from app.core.memory.agent.services.search_service import SearchService
|
||||
from app.core.memory.agent.utils.llm_tools import (
|
||||
PROJECT_ROOT_,
|
||||
@@ -18,7 +17,7 @@ from app.core.memory.agent.utils.llm_tools import (
|
||||
from app.core.memory.agent.utils.redis_tool import store
|
||||
from app.core.memory.agent.utils.session_tools import SessionService
|
||||
from app.core.memory.agent.utils.template_tools import TemplateService
|
||||
from app.core.memory.agent.services.optimized_llm_service import LLMServiceMixin
|
||||
from app.db import get_db
|
||||
|
||||
template_root = os.path.join(PROJECT_ROOT_, 'agent', 'utils', 'prompt')
|
||||
logger = get_agent_logger(__name__)
|
||||
@@ -182,7 +181,8 @@ async def Input_Summary(state: ReadState) -> ReadState:
|
||||
search_params = {
|
||||
"group_id": group_id,
|
||||
"question": data,
|
||||
"return_raw_results": True
|
||||
"return_raw_results": True,
|
||||
"include": ["summaries"] # Only search summary nodes for faster performance
|
||||
}
|
||||
|
||||
try:
|
||||
|
||||
@@ -89,14 +89,15 @@ def validate_model_exists_and_active(
|
||||
start_time = time.time()
|
||||
|
||||
try:
|
||||
# First check if model exists at all (without tenant filtering)
|
||||
model_without_tenant = ModelConfigRepository.get_by_id(db, model_id, tenant_id=None)
|
||||
|
||||
# Then check with tenant filtering
|
||||
# OPTIMIZED: Single query with tenant filter
|
||||
# We'll check tenant mismatch in the error handling
|
||||
model = ModelConfigRepository.get_by_id(db, model_id, tenant_id)
|
||||
elapsed_ms = (time.time() - start_time) * 1000
|
||||
|
||||
if not model:
|
||||
# Model not found with tenant filter - check if it exists without filter
|
||||
model_without_tenant = ModelConfigRepository.get_by_id(db, model_id, tenant_id=None)
|
||||
|
||||
if model_without_tenant:
|
||||
# Model exists but belongs to different tenant
|
||||
logger.warning(
|
||||
@@ -208,8 +209,11 @@ def validate_embedding_model(
|
||||
db: Session,
|
||||
tenant_id: Optional[UUID] = None,
|
||||
workspace_id: Optional[UUID] = None
|
||||
) -> UUID:
|
||||
"""Validate that embedding model is available and return its UUID.
|
||||
) -> tuple[UUID, str]:
|
||||
"""Validate that embedding model is available and return its UUID and name.
|
||||
|
||||
Returns:
|
||||
Tuple of (embedding_uuid, embedding_name)
|
||||
|
||||
Raises:
|
||||
InvalidConfigError: If embedding_id is not provided or invalid
|
||||
@@ -225,14 +229,19 @@ def validate_embedding_model(
|
||||
workspace_id=workspace_id
|
||||
)
|
||||
|
||||
embedding_uuid, _ = validate_and_resolve_model_id(
|
||||
embedding_uuid, embedding_name = validate_and_resolve_model_id(
|
||||
embedding_id, "embedding", db, tenant_id, required=True,
|
||||
config_id=config_id, workspace_id=workspace_id
|
||||
)
|
||||
print(100*'-')
|
||||
print(embedding_uuid)
|
||||
print(_)
|
||||
print(100*'-')
|
||||
|
||||
logger.debug(
|
||||
"Embedding model validated",
|
||||
extra={
|
||||
"embedding_uuid": str(embedding_uuid),
|
||||
"embedding_name": embedding_name,
|
||||
"config_id": config_id
|
||||
}
|
||||
)
|
||||
|
||||
if embedding_uuid is None:
|
||||
raise InvalidConfigError(
|
||||
@@ -243,7 +252,7 @@ def validate_embedding_model(
|
||||
workspace_id=workspace_id
|
||||
)
|
||||
|
||||
return embedding_uuid
|
||||
return embedding_uuid, embedding_name
|
||||
|
||||
|
||||
def validate_llm_model(
|
||||
|
||||
Reference in New Issue
Block a user