mirror of
https://github.com/FunnyWolf/agentic-soc-platform.git
synced 2026-08-22 13:12:56 +02:00
more pydantic
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
from enum import Enum
|
||||
from typing import Optional, Union, Dict, Any
|
||||
from typing import Any
|
||||
|
||||
from langchain_core.messages import HumanMessage
|
||||
from langgraph.graph import StateGraph
|
||||
@@ -37,9 +37,9 @@ class AnalyzeResult(BaseModel):
|
||||
original_severity: Severity = Field(description="Original alert severity")
|
||||
new_severity: Severity = Field(description="Recommended new severity level")
|
||||
confidence: ConfidenceLevel = Field(description="Confidence score, only one of 'Low', 'Medium', or 'High'")
|
||||
analysis_rationale: str = Field(description="Analysis process and reasons", default=None)
|
||||
current_attack_stage: Optional[Union[str, Dict[str, Any]]] = Field(description="e.g., 'T1059 - Command and Control', 'Lateral Movement'", default=None)
|
||||
recommended_actions: Optional[Union[str, Dict[str, Any]]] = Field(description="e.g., 'Isolate host 10.1.1.5'", default=None)
|
||||
analysis_rationale: str | None = Field(description="Analysis process and reasons", default=None)
|
||||
current_attack_stage: str | dict[str, Any] | None = Field(description="e.g., 'T1059 - Command and Control', 'Lateral Movement'", default=None)
|
||||
recommended_actions: str | dict[str, Any] | None = Field(description="e.g., 'Isolate host 10.1.1.5'", default=None)
|
||||
|
||||
|
||||
class Playbook(LanggraphPlaybook):
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import json
|
||||
import operator
|
||||
from typing import Annotated, Dict, List, Union
|
||||
from typing import Annotated, Dict, List
|
||||
|
||||
from langchain_core.messages import AnyMessage, ToolMessage, AIMessage
|
||||
from langgraph.graph import StateGraph, START, END
|
||||
@@ -38,7 +38,7 @@ class PlanningRecord(BaseModel):
|
||||
|
||||
class AnalystOutput(BaseModel):
|
||||
answer: str = Field(description="对调查问题的最终、简洁的回答")
|
||||
reasoning: Union[str, List[str]] = Field(description="支持最终结论的详细推理过程和关键证据。")
|
||||
reasoning: str | List[str] = Field(description="支持最终结论的详细推理过程和关键证据。")
|
||||
|
||||
|
||||
# 定义 Planner 的结构化输出
|
||||
@@ -51,7 +51,7 @@ class HuntingPlan(BaseModel):
|
||||
class Finding(BaseModel):
|
||||
question: str = Field(description="需要调查的问题")
|
||||
answer: str = Field(description="调查得到的答案")
|
||||
reasoning: Union[str, List[str]] = Field(description="调查的推理过程")
|
||||
reasoning: str | List[str] = Field(description="调查的推理过程")
|
||||
tool_calls: List = Field(default_factory=list, description="工具调用记录")
|
||||
|
||||
def to_markdown(self) -> str:
|
||||
@@ -98,7 +98,7 @@ class AnalystState(BaseModel):
|
||||
)
|
||||
|
||||
# 输出:推理过程
|
||||
reasoning: Union[str, List[str]] = Field(
|
||||
reasoning: str | List[str] = Field(
|
||||
default="",
|
||||
description="得出结论的详细推理步骤及证据。"
|
||||
)
|
||||
|
||||
@@ -182,7 +182,7 @@ class CMDB(object):
|
||||
|
||||
def fuzzy_search_ci(self,
|
||||
partial_hostname: Annotated[Optional[str], "部分主机名片段,例如 'prod-'。如果提供,将进行部分匹配。"] = None,
|
||||
regex_pattern: Annotated[Optional[str], "用于高级匹配的正则表达式,例如 'aws-\d+'。与 partial_hostname 二选一。"] = None
|
||||
regex_pattern: Annotated[Optional[str], "用于高级匹配的正则表达式"] = None
|
||||
) -> Annotated[List[Dict[str, Any]], "匹配到的CI列表,仅返回 CI ID、CI 类型、主机名和业务关键性。"]:
|
||||
"""
|
||||
[B. 模糊/部分匹配检索]:根据部分主机名或正则表达式检索匹配的配置项(CI)列表。
|
||||
|
||||
Reference in New Issue
Block a user