mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
Fix: v0.26.1 model provider (#16073)
### What problem does this PR solve? Fix: - Pass session_id to langfuse. - Get correct status for add model_type. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -24,7 +24,7 @@ logger = logging.getLogger(__name__)
|
||||
from datetime import datetime
|
||||
from functools import partial
|
||||
from timeit import default_timer as timer
|
||||
from langfuse import Langfuse
|
||||
from langfuse import Langfuse, propagate_attributes
|
||||
from peewee import fn
|
||||
from api.db.services.file_service import FileService
|
||||
from common.constants import LLMType, ParserType, StatusEnum
|
||||
@@ -875,8 +875,10 @@ async def async_chat(dialog, messages, stream=True, **kwargs):
|
||||
"input": {"prompt": prompt, "prompt4citation": prompt4citation, "messages": msg},
|
||||
}
|
||||
if session_id:
|
||||
observation_kwargs["session_id"] = session_id
|
||||
langfuse_generation = langfuse_tracer.start_observation(**observation_kwargs)
|
||||
with propagate_attributes(session_id=session_id):
|
||||
langfuse_generation = langfuse_tracer.start_observation(**observation_kwargs)
|
||||
else:
|
||||
langfuse_generation = langfuse_tracer.start_observation(**observation_kwargs)
|
||||
except Exception as e: # noqa: BLE001 - tracing must not break chat flow
|
||||
logger.warning("Langfuse start_observation failed; continuing without tracing: %s", e)
|
||||
langfuse_tracer = None
|
||||
|
||||
@@ -22,6 +22,8 @@ import threading
|
||||
from functools import partial
|
||||
from typing import Generator
|
||||
|
||||
from langfuse import propagate_attributes
|
||||
|
||||
from api.db.db_models import LLM
|
||||
from api.db.services.common_service import CommonService
|
||||
from api.db.services.tenant_llm_service import LLM4Tenant
|
||||
@@ -88,7 +90,8 @@ class LLMBundle(LLM4Tenant):
|
||||
|
||||
def _start_langfuse_observation(self, **kwargs):
|
||||
if self.langfuse_session_id:
|
||||
kwargs["session_id"] = self.langfuse_session_id
|
||||
with propagate_attributes(session_id=self.langfuse_session_id):
|
||||
return self.langfuse.start_observation(**kwargs)
|
||||
return self.langfuse.start_observation(**kwargs)
|
||||
|
||||
def close(self):
|
||||
|
||||
@@ -83,7 +83,7 @@ class TenantModelService(CommonService):
|
||||
extra="{}"
|
||||
)
|
||||
return len(operation.get("add", [])) + len(operation.get("delete", []))
|
||||
model_record_example = [model_record for model_record in model_type_records if model_record.status != ActiveStatusEnum.UNSUPPORTED]
|
||||
model_record_example = [model_record for model_record in model_type_records if model_record.status != ActiveStatusEnum.UNSUPPORTED.value]
|
||||
extra_fields = model_record_example[0].extra if model_record_example else "{}"
|
||||
model_status = model_record_example[0].status if model_record_example else ActiveStatusEnum.ACTIVE.value
|
||||
type_record_map = {record.model_type: record for record in model_type_records}
|
||||
|
||||
Reference in New Issue
Block a user