mirror of
https://github.com/langgenius/dify.git
synced 2026-05-04 17:38:04 +08:00
feat: agent log
This commit is contained in:
@ -1163,6 +1163,10 @@ class MessageAgentThought(db.Model):
|
||||
else:
|
||||
return []
|
||||
|
||||
@property
|
||||
def tools(self) -> list[str]:
|
||||
return self.tool.split(";") if self.tool else []
|
||||
|
||||
@property
|
||||
def tool_labels(self) -> dict:
|
||||
try:
|
||||
@ -1182,6 +1186,55 @@ class MessageAgentThought(db.Model):
|
||||
return {}
|
||||
except Exception as e:
|
||||
return {}
|
||||
|
||||
@property
|
||||
def tool_inputs_dict(self) -> dict:
|
||||
tools = self.tools
|
||||
try:
|
||||
if self.tool_input:
|
||||
data = json.loads(self.tool_input)
|
||||
result = {}
|
||||
for tool in tools:
|
||||
if tool in data:
|
||||
result[tool] = data[tool]
|
||||
else:
|
||||
if len(tools) == 1:
|
||||
result[tool] = data
|
||||
else:
|
||||
result[tool] = {}
|
||||
return result
|
||||
else:
|
||||
return {
|
||||
tool: {} for tool in tools
|
||||
}
|
||||
except Exception as e:
|
||||
return {}
|
||||
|
||||
@property
|
||||
def tool_outputs_dict(self) -> dict:
|
||||
tools = self.tools
|
||||
try:
|
||||
if self.observation:
|
||||
data = json.loads(self.observation)
|
||||
result = {}
|
||||
for tool in tools:
|
||||
if tool in data:
|
||||
result[tool] = data[tool]
|
||||
else:
|
||||
if len(tools) == 1:
|
||||
result[tool] = data
|
||||
else:
|
||||
result[tool] = {}
|
||||
return result
|
||||
else:
|
||||
return {
|
||||
tool: {} for tool in tools
|
||||
}
|
||||
except Exception as e:
|
||||
if self.observation:
|
||||
return {
|
||||
tool: self.observation for tool in tools
|
||||
}
|
||||
|
||||
class DatasetRetrieverResource(db.Model):
|
||||
__tablename__ = 'dataset_retriever_resources'
|
||||
|
||||
Reference in New Issue
Block a user