Spaces:
Running
Running
Commit
·
1d4dcf3
1
Parent(s):
b7aa617
add
Browse files
agentgraph/methods/production/openai_structured_extractor.py
CHANGED
|
@@ -59,15 +59,19 @@ class OpenAIStructuredExtractor:
|
|
| 59 |
|
| 60 |
Your task is to extract structured knowledge graphs from agent execution traces. You identify entities (Agents, Tasks, Tools, Inputs, Outputs, Humans) and their relationships, providing precise content references when line markers are available.
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
You always return a complete knowledge graph with meaningful entities, logical relationships, and accurate metadata."""
|
| 63 |
|
| 64 |
# User prompt - specific instructions with few-shot example and data
|
| 65 |
user_prompt = f"""Analyze this agent system trace and extract a knowledge graph with the following specifications:
|
| 66 |
|
| 67 |
-
|
| 68 |
-
Here's
|
| 69 |
-
|
| 70 |
-
Expected output structure:
|
| 71 |
{{
|
| 72 |
"system_name": "California Great America Ticket Analysis System",
|
| 73 |
"system_summary": "This system helps analyze the cost-saving potential of purchasing season passes versus individual daily tickets at California's Great America in San Jose. The process starts with an inquiry regarding savings from the Inquiry about Savings from Season Pass vs Daily Tickets (input_001), which is consumed by the Verification Expert (agent_002), who performs the Verify Cost of Daily Ticket and Season Pass in 2024 (task_001).",
|
|
@@ -249,6 +253,21 @@ IMPORTANT: Only create content references when you see explicit <L#> line marker
|
|
| 249 |
|
| 250 |
Also provide system_name and system_summary for the overall system.
|
| 251 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 252 |
TRACE DATA:
|
| 253 |
{input_data}"""
|
| 254 |
|
|
|
|
| 59 |
|
| 60 |
Your task is to extract structured knowledge graphs from agent execution traces. You identify entities (Agents, Tasks, Tools, Inputs, Outputs, Humans) and their relationships, providing precise content references when line markers are available.
|
| 61 |
|
| 62 |
+
CRITICAL PRINCIPLES:
|
| 63 |
+
1. COMPREHENSIVENESS: Include ALL entities that play any role in the system, no matter how minor
|
| 64 |
+
2. CONSISTENCY: Follow the example's level of detail and thoroughness
|
| 65 |
+
3. COMPLETENESS: Every named agent, tool, task, input, and output should be captured
|
| 66 |
+
4. ACCURACY: Match entity types and relationships to the actual trace content
|
| 67 |
+
|
| 68 |
You always return a complete knowledge graph with meaningful entities, logical relationships, and accurate metadata."""
|
| 69 |
|
| 70 |
# User prompt - specific instructions with few-shot example and data
|
| 71 |
user_prompt = f"""Analyze this agent system trace and extract a knowledge graph with the following specifications:
|
| 72 |
|
| 73 |
+
EXAMPLE OUTPUT STRUCTURE:
|
| 74 |
+
Here's the expected knowledge graph structure for multi-agent collaboration traces:
|
|
|
|
|
|
|
| 75 |
{{
|
| 76 |
"system_name": "California Great America Ticket Analysis System",
|
| 77 |
"system_summary": "This system helps analyze the cost-saving potential of purchasing season passes versus individual daily tickets at California's Great America in San Jose. The process starts with an inquiry regarding savings from the Inquiry about Savings from Season Pass vs Daily Tickets (input_001), which is consumed by the Verification Expert (agent_002), who performs the Verify Cost of Daily Ticket and Season Pass in 2024 (task_001).",
|
|
|
|
| 253 |
|
| 254 |
Also provide system_name and system_summary for the overall system.
|
| 255 |
|
| 256 |
+
EXTRACTION GUIDELINES:
|
| 257 |
+
1. AGENT IDENTIFICATION: Include every named agent, expert, assistant, or role mentioned in the trace
|
| 258 |
+
2. TOOL DISCOVERY: Capture all computational tools, terminals, systems, analyzers, or utilities
|
| 259 |
+
3. TASK MAPPING: Identify all tasks, objectives, goals, verification steps, and subtasks
|
| 260 |
+
4. INTERACTION TRACKING: Include all inputs, outputs, intermediate results, and data flows
|
| 261 |
+
5. STAKEHOLDER INCLUSION: Identify all human users, requesters, and beneficiaries
|
| 262 |
+
|
| 263 |
+
QUALITY STANDARDS:
|
| 264 |
+
- Match the example's thoroughness and attention to detail
|
| 265 |
+
- Include entities even if they appear briefly or seem minor
|
| 266 |
+
- Ensure every significant component of the system is represented
|
| 267 |
+
- Create meaningful relationships that reflect actual interactions
|
| 268 |
+
|
| 269 |
+
Apply these principles to extract a comprehensive knowledge graph from the following trace data.
|
| 270 |
+
|
| 271 |
TRACE DATA:
|
| 272 |
{input_data}"""
|
| 273 |
|