mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-15 05:46:52 +08:00
chore(api/core): apply ruff reformatting (#7624)
This commit is contained in:
@@ -4,14 +4,15 @@ from pydantic import BaseModel, ValidationInfo, field_validator
|
||||
|
||||
|
||||
class TracingProviderEnum(Enum):
|
||||
LANGFUSE = 'langfuse'
|
||||
LANGSMITH = 'langsmith'
|
||||
LANGFUSE = "langfuse"
|
||||
LANGSMITH = "langsmith"
|
||||
|
||||
|
||||
class BaseTracingConfig(BaseModel):
|
||||
"""
|
||||
Base model class for tracing
|
||||
"""
|
||||
|
||||
...
|
||||
|
||||
|
||||
@@ -19,16 +20,17 @@ class LangfuseConfig(BaseTracingConfig):
|
||||
"""
|
||||
Model class for Langfuse tracing config.
|
||||
"""
|
||||
|
||||
public_key: str
|
||||
secret_key: str
|
||||
host: str = 'https://api.langfuse.com'
|
||||
host: str = "https://api.langfuse.com"
|
||||
|
||||
@field_validator("host")
|
||||
def set_value(cls, v, info: ValidationInfo):
|
||||
if v is None or v == "":
|
||||
v = 'https://api.langfuse.com'
|
||||
if not v.startswith('https://') and not v.startswith('http://'):
|
||||
raise ValueError('host must start with https:// or http://')
|
||||
v = "https://api.langfuse.com"
|
||||
if not v.startswith("https://") and not v.startswith("http://"):
|
||||
raise ValueError("host must start with https:// or http://")
|
||||
|
||||
return v
|
||||
|
||||
@@ -37,15 +39,16 @@ class LangSmithConfig(BaseTracingConfig):
|
||||
"""
|
||||
Model class for Langsmith tracing config.
|
||||
"""
|
||||
|
||||
api_key: str
|
||||
project: str
|
||||
endpoint: str = 'https://api.smith.langchain.com'
|
||||
endpoint: str = "https://api.smith.langchain.com"
|
||||
|
||||
@field_validator("endpoint")
|
||||
def set_value(cls, v, info: ValidationInfo):
|
||||
if v is None or v == "":
|
||||
v = 'https://api.smith.langchain.com'
|
||||
if not v.startswith('https://'):
|
||||
raise ValueError('endpoint must start with https://')
|
||||
v = "https://api.smith.langchain.com"
|
||||
if not v.startswith("https://"):
|
||||
raise ValueError("endpoint must start with https://")
|
||||
|
||||
return v
|
||||
|
||||
@@ -23,6 +23,7 @@ class BaseTraceInfo(BaseModel):
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
class WorkflowTraceInfo(BaseTraceInfo):
|
||||
workflow_data: Any
|
||||
conversation_id: Optional[str] = None
|
||||
@@ -98,23 +99,24 @@ class GenerateNameTraceInfo(BaseTraceInfo):
|
||||
conversation_id: Optional[str] = None
|
||||
tenant_id: str
|
||||
|
||||
|
||||
trace_info_info_map = {
|
||||
'WorkflowTraceInfo': WorkflowTraceInfo,
|
||||
'MessageTraceInfo': MessageTraceInfo,
|
||||
'ModerationTraceInfo': ModerationTraceInfo,
|
||||
'SuggestedQuestionTraceInfo': SuggestedQuestionTraceInfo,
|
||||
'DatasetRetrievalTraceInfo': DatasetRetrievalTraceInfo,
|
||||
'ToolTraceInfo': ToolTraceInfo,
|
||||
'GenerateNameTraceInfo': GenerateNameTraceInfo,
|
||||
"WorkflowTraceInfo": WorkflowTraceInfo,
|
||||
"MessageTraceInfo": MessageTraceInfo,
|
||||
"ModerationTraceInfo": ModerationTraceInfo,
|
||||
"SuggestedQuestionTraceInfo": SuggestedQuestionTraceInfo,
|
||||
"DatasetRetrievalTraceInfo": DatasetRetrievalTraceInfo,
|
||||
"ToolTraceInfo": ToolTraceInfo,
|
||||
"GenerateNameTraceInfo": GenerateNameTraceInfo,
|
||||
}
|
||||
|
||||
|
||||
class TraceTaskName(str, Enum):
|
||||
CONVERSATION_TRACE = 'conversation'
|
||||
WORKFLOW_TRACE = 'workflow'
|
||||
MESSAGE_TRACE = 'message'
|
||||
MODERATION_TRACE = 'moderation'
|
||||
SUGGESTED_QUESTION_TRACE = 'suggested_question'
|
||||
DATASET_RETRIEVAL_TRACE = 'dataset_retrieval'
|
||||
TOOL_TRACE = 'tool'
|
||||
GENERATE_NAME_TRACE = 'generate_conversation_name'
|
||||
CONVERSATION_TRACE = "conversation"
|
||||
WORKFLOW_TRACE = "workflow"
|
||||
MESSAGE_TRACE = "message"
|
||||
MODERATION_TRACE = "moderation"
|
||||
SUGGESTED_QUESTION_TRACE = "suggested_question"
|
||||
DATASET_RETRIEVAL_TRACE = "dataset_retrieval"
|
||||
TOOL_TRACE = "tool"
|
||||
GENERATE_NAME_TRACE = "generate_conversation_name"
|
||||
|
||||
Reference in New Issue
Block a user