mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Feat: add Langfuse APIs (#6460)
### What problem does this PR solve? Add Langfuse APIs ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -34,13 +34,23 @@ class TenantLangfuseService(CommonService):
|
||||
@classmethod
|
||||
@DB.connection_context()
|
||||
def filter_by_tenant(cls, tenant_id):
|
||||
fields = [cls.model.host, cls.model.secret_key, cls.model.public_key]
|
||||
fields = [cls.model.tenant_id, cls.model.host, cls.model.secret_key, cls.model.public_key]
|
||||
try:
|
||||
keys = cls.model.select(*fields).where(cls.model.tenant_id == tenant_id).first()
|
||||
return keys
|
||||
except peewee.DoesNotExist:
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
@DB.connection_context()
|
||||
def filter_by_tenant_with_info(cls, tenant_id):
|
||||
fields = [cls.model.tenant_id, cls.model.host, cls.model.secret_key, cls.model.public_key]
|
||||
try:
|
||||
keys = cls.model.select(*fields).where(cls.model.tenant_id == tenant_id).dicts().first()
|
||||
return keys
|
||||
except peewee.DoesNotExist:
|
||||
return None
|
||||
|
||||
@classmethod
|
||||
def update_by_tenant(cls, tenant_id, langfuse_keys):
|
||||
langfuse_keys["update_time"] = current_timestamp()
|
||||
@ -55,3 +65,7 @@ class TenantLangfuseService(CommonService):
|
||||
kwargs["update_date"] = datetime_format(datetime.now())
|
||||
obj = cls.model.create(**kwargs)
|
||||
return obj
|
||||
|
||||
@classmethod
|
||||
def delete_model(cls, langfuse_model):
|
||||
langfuse_model.delete_instance()
|
||||
|
||||
Reference in New Issue
Block a user