Spaces:
Running
🚀 Enhanced Sample Data: Complete AgentGraph Feature Showcase
Browse files- ✨ Updated sample_data.py with Oxford Economics AI assistant examples
- 🎯 Added failure detection and optimization recommendations
- 📊 Included quality scoring and content references
- 🧠 Added complete knowledge graph examples (sample_knowledge_graph.json, initial_data.json)
- 📚 Enhanced documentation (KNOWLEDGE_GRAPH_EXAMPLE.md, README_KNOWLEDGE_GRAPH.md)
- 🗑️ Removed outdated sample data (sample_data_old.py)
Features demonstrated:
- Failure detection (spelling errors, system gaps)
- Optimization recommendations (prompt refinement, tool enhancement)
- Content references with confidence scoring
- System summaries with natural language flow
- Quality assessment metrics
- Enhanced metadata and processing information
This provides users with immediate access to AgentGraph's complete capabilities upon initialization.
- KNOWLEDGE_GRAPH_EXAMPLE.md +142 -0
- README_KNOWLEDGE_GRAPH.md +179 -0
- backend/database/README_sample_data.md +36 -31
- backend/database/sample_data.py +337 -656
- backend/database/sample_data_old.py +0 -623
- initial_data.json +210 -0
- sample_knowledge_graph.json +390 -0
|
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AgentGraph Knowledge Graph 完美示例
|
| 2 |
+
|
| 3 |
+
这是一个完整的、生产就绪的 Knowledge Graph 示例,展示了 AgentGraph 的所有核心功能。
|
| 4 |
+
|
| 5 |
+
## 📊 **数据概览**
|
| 6 |
+
|
| 7 |
+
- **实体数量**: 6 个(Agent, Task, Input, Output, Human, Tool)
|
| 8 |
+
- **关系数量**: 6 个(涵盖所有标准关系类型)
|
| 9 |
+
- **失败检测**: 3 个实际问题(拼写错误、系统缺陷、流程问题)
|
| 10 |
+
- **优化建议**: 4 个可操作的改进方案
|
| 11 |
+
- **质量分数**: 0.89/1.0 整体评分
|
| 12 |
+
|
| 13 |
+
## 🎯 **核心特性展示**
|
| 14 |
+
|
| 15 |
+
### ✅ **完整的实体模型**
|
| 16 |
+
|
| 17 |
+
每个实体都包含:
|
| 18 |
+
|
| 19 |
+
- 清晰的`raw_prompt`内容(无转义字符)
|
| 20 |
+
- 精确的`ContentReference`引用(带置信度)
|
| 21 |
+
- 正确的重要性级别分类
|
| 22 |
+
- 有意义的实体名称
|
| 23 |
+
|
| 24 |
+
### ✅ **丰富的关系描述**
|
| 25 |
+
|
| 26 |
+
每个关系都具备:
|
| 27 |
+
|
| 28 |
+
- 详细的`interaction_prompt`说明
|
| 29 |
+
- 准确的源实体和目标实体映射
|
| 30 |
+
- 正确的关系类型使用
|
| 31 |
+
- 实际的交互场景描述
|
| 32 |
+
|
| 33 |
+
### ✅ **智能失败检测**
|
| 34 |
+
|
| 35 |
+
实现了 3 种失败类型:
|
| 36 |
+
|
| 37 |
+
- **HALLUCINATION**: 用户输入拼写错误
|
| 38 |
+
- **AGENT_ERROR**: 系统提示拼写错误
|
| 39 |
+
- **PLANNING_ERROR**: 缺失验证步骤
|
| 40 |
+
|
| 41 |
+
### ✅ **实用优化建议**
|
| 42 |
+
|
| 43 |
+
提供了 4 类优化建议:
|
| 44 |
+
|
| 45 |
+
- **PROMPT_REFINEMENT**: 提示词改进
|
| 46 |
+
- **WORKFLOW_SIMPLIFICATION**: 流程优化
|
| 47 |
+
- **TOOL_ENHANCEMENT**: 工具增强
|
| 48 |
+
- **反馈机制**: 质量改进循环
|
| 49 |
+
|
| 50 |
+
### ✅ **高质量元数据**
|
| 51 |
+
|
| 52 |
+
包含完整的处理信息:
|
| 53 |
+
|
| 54 |
+
- 内容解析统计
|
| 55 |
+
- 窗口处理信息
|
| 56 |
+
- 合并去重统计
|
| 57 |
+
- 质量评估指标
|
| 58 |
+
|
| 59 |
+
## 🚀 **使用方式**
|
| 60 |
+
|
| 61 |
+
### 1. **作为初始数据**
|
| 62 |
+
|
| 63 |
+
```bash
|
| 64 |
+
# 将此文件用作系统初始化数据
|
| 65 |
+
cp sample_knowledge_graph.json data/initial_knowledge_graph.json
|
| 66 |
+
```
|
| 67 |
+
|
| 68 |
+
### 2. **作为测试数据**
|
| 69 |
+
|
| 70 |
+
```bash
|
| 71 |
+
# 用于功能测试和展示
|
| 72 |
+
curl -X POST /api/knowledge-graphs \
|
| 73 |
+
-H "Content-Type: application/json" \
|
| 74 |
+
-d @sample_knowledge_graph.json
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
### 3. **作为参考模板**
|
| 78 |
+
|
| 79 |
+
开发者可以参考此结构创建新的 knowledge graphs
|
| 80 |
+
|
| 81 |
+
## 🎨 **前端展示效果**
|
| 82 |
+
|
| 83 |
+
此示例支持以下前端功能:
|
| 84 |
+
|
| 85 |
+
### **实体可视化**
|
| 86 |
+
|
| 87 |
+
- **颜色编码**: 基于类型和重要性
|
| 88 |
+
- **大小调整**: 反映实体重要性
|
| 89 |
+
- **工具提示**: 显示 raw_prompt 内容
|
| 90 |
+
|
| 91 |
+
### **关系展示**
|
| 92 |
+
|
| 93 |
+
- **箭头方向**: 明确的数据流向
|
| 94 |
+
- **线条样式**: 区分不同关系类型
|
| 95 |
+
- **交互说明**: 悬停显示 interaction_prompt
|
| 96 |
+
|
| 97 |
+
### **问题突出显示**
|
| 98 |
+
|
| 99 |
+
- **失败标记**: 红色边框或图标
|
| 100 |
+
- **风险分类**: 不同颜色表示风险类型
|
| 101 |
+
- **影响范围**: 突出显示受影响的实体
|
| 102 |
+
|
| 103 |
+
### **优化建议面板**
|
| 104 |
+
|
| 105 |
+
- **建议列表**: 右侧面板显示
|
| 106 |
+
- **优先级排序**: 基于影响范围
|
| 107 |
+
- **操作按钮**: 快速应用建议
|
| 108 |
+
|
| 109 |
+
## 📋 **质量指标**
|
| 110 |
+
|
| 111 |
+
| 指标 | 分数 | 说明 |
|
| 112 |
+
| ---------- | ---- | ---------------------- |
|
| 113 |
+
| 整体质量 | 0.89 | 高质量 knowledge graph |
|
| 114 |
+
| 实体质量 | 0.91 | 实体定义清晰准确 |
|
| 115 |
+
| 关系质量 | 0.88 | 关系映射正确完整 |
|
| 116 |
+
| 内容引用 | 0.87 | ContentReference 准确 |
|
| 117 |
+
| 失败检测 | 0.92 | 问题识别全面 |
|
| 118 |
+
| 优化相关性 | 0.86 | 建议实用可行 |
|
| 119 |
+
|
| 120 |
+
## 🔄 **更新建议**
|
| 121 |
+
|
| 122 |
+
定期使用此模板检查新生成的 knowledge graphs 是否具备:
|
| 123 |
+
|
| 124 |
+
1. ✅ 所有必需字段
|
| 125 |
+
2. ✅ 非空的 failures 和 optimizations 数组
|
| 126 |
+
3. ✅ 正确的 ContentReference 格式
|
| 127 |
+
4. ✅ 有意义的 system_summary
|
| 128 |
+
5. ✅ 完整的元数据信息
|
| 129 |
+
|
| 130 |
+
## 📝 **最佳实践**
|
| 131 |
+
|
| 132 |
+
基于此示例,建议在 AgentGraph 中:
|
| 133 |
+
|
| 134 |
+
1. **始终包含失败检测**,即使没有发现问题也要有空数组
|
| 135 |
+
2. **提供优化建议**,展示系统的分析能力
|
| 136 |
+
3. **使用置信度评分**,帮助用户评估结果质量
|
| 137 |
+
4. **编写流畅的 system_summary**,包含指代词的自然叙述
|
| 138 |
+
5. **确保 ContentReference 准确性**,支持内容溯源
|
| 139 |
+
|
| 140 |
+
---
|
| 141 |
+
|
| 142 |
+
_此示例代表了 AgentGraph knowledge extraction 的最高质量标准,可直接用于生产环境。_
|
|
@@ -0,0 +1,179 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🧠 AgentGraph Knowledge Graph 完美示例指南
|
| 2 |
+
|
| 3 |
+
本目录包含了 AgentGraph 系统的完美 Knowledge Graph 示例,展示了所有核心功能和最佳实践。
|
| 4 |
+
|
| 5 |
+
## 📁 **文件说明**
|
| 6 |
+
|
| 7 |
+
### 1. `sample_knowledge_graph.json` - 完整功能示例
|
| 8 |
+
|
| 9 |
+
- **用途**: 展示 AgentGraph 的完整功能集
|
| 10 |
+
- **特色**: 包含所有字段、详细元数据、质量评估
|
| 11 |
+
- **场景**: 功能演示、质量基准、开发参考
|
| 12 |
+
|
| 13 |
+
### 2. `initial_data.json` - 简化初始化数据
|
| 14 |
+
|
| 15 |
+
- **用途**: HF 环境初始化和快速部署
|
| 16 |
+
- **特色**: 核心功能完整、元数据简化、易于理解
|
| 17 |
+
- **场景**: 系统初始化、用户培训、快速展示
|
| 18 |
+
|
| 19 |
+
## 🎯 **核心特性对比**
|
| 20 |
+
|
| 21 |
+
| 特性 | sample_knowledge_graph.json | initial_data.json |
|
| 22 |
+
| ------------ | --------------------------- | ----------------- |
|
| 23 |
+
| **实体数量** | 6 个(完整示例) | 6 个(核心示例) |
|
| 24 |
+
| **关系数量** | 6 个(全类型覆盖) | 5 个(主要流程) |
|
| 25 |
+
| **失败检测** | 3 个详细案例 | 1 个简化案例 |
|
| 26 |
+
| **优化建议** | 4 个全面建议 | 2 个重点建议 |
|
| 27 |
+
| **元数据** | 完整处理统计 | 简化核心信息 |
|
| 28 |
+
| **复杂度** | 生产级完整 | 演示级简化 |
|
| 29 |
+
|
| 30 |
+
## 🚀 **使用指南**
|
| 31 |
+
|
| 32 |
+
### **方式 1: 快速体验(推荐新用户)**
|
| 33 |
+
|
| 34 |
+
```bash
|
| 35 |
+
# 使用简化版本进行初始化
|
| 36 |
+
cp initial_data.json data/demo_knowledge_graph.json
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
### **方式 2: 完整功能展示(推荐开发者)**
|
| 40 |
+
|
| 41 |
+
```bash
|
| 42 |
+
# 使用完整版本展示所有功能
|
| 43 |
+
cp sample_knowledge_graph.json data/full_demo_knowledge_graph.json
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
### **方式 3: API 导入**
|
| 47 |
+
|
| 48 |
+
```javascript
|
| 49 |
+
// 前端导入示例
|
| 50 |
+
fetch("/api/knowledge-graphs/import", {
|
| 51 |
+
method: "POST",
|
| 52 |
+
headers: { "Content-Type": "application/json" },
|
| 53 |
+
body: JSON.stringify(initialData),
|
| 54 |
+
});
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
## 🔍 **数据结构亮点**
|
| 58 |
+
|
| 59 |
+
### ✅ **实体模型完善**
|
| 60 |
+
|
| 61 |
+
```json
|
| 62 |
+
{
|
| 63 |
+
"id": "agent_001",
|
| 64 |
+
"type": "Agent",
|
| 65 |
+
"name": "Oxford Economics Knowledge Agent",
|
| 66 |
+
"importance": "HIGH",
|
| 67 |
+
"raw_prompt": "清晰可读的提示内容",
|
| 68 |
+
"raw_prompt_ref": [{ "line_start": 31, "line_end": 32 }]
|
| 69 |
+
}
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
### ✅ **关系描述丰富**
|
| 73 |
+
|
| 74 |
+
```json
|
| 75 |
+
{
|
| 76 |
+
"id": "rel_001",
|
| 77 |
+
"source": "input_001",
|
| 78 |
+
"target": "agent_001",
|
| 79 |
+
"type": "CONSUMED_BY",
|
| 80 |
+
"interaction_prompt": "具体的交互场景描述"
|
| 81 |
+
}
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
### ✅ **失败检测智能**
|
| 85 |
+
|
| 86 |
+
```json
|
| 87 |
+
{
|
| 88 |
+
"id": "failure_001",
|
| 89 |
+
"risk_type": "HALLUCINATION",
|
| 90 |
+
"description": "具体问题描述和影响分析",
|
| 91 |
+
"affected_id": "input_001"
|
| 92 |
+
}
|
| 93 |
+
```
|
| 94 |
+
|
| 95 |
+
### ✅ **优化建议实用**
|
| 96 |
+
|
| 97 |
+
```json
|
| 98 |
+
{
|
| 99 |
+
"id": "opt_001",
|
| 100 |
+
"recommendation_type": "PROMPT_REFINEMENT",
|
| 101 |
+
"description": "详细的改进建议和实施方案",
|
| 102 |
+
"affected_ids": ["agent_001"]
|
| 103 |
+
}
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
## 🎨 **前端渲染支持**
|
| 107 |
+
|
| 108 |
+
这些 Knowledge Graph 为前端提供了丰富的渲染数据:
|
| 109 |
+
|
| 110 |
+
### **实体可视化**
|
| 111 |
+
|
| 112 |
+
- 基于`type`和`importance`的颜色编码
|
| 113 |
+
- 悬停显示`raw_prompt`内容
|
| 114 |
+
- 点击查看`ContentReference`详情
|
| 115 |
+
|
| 116 |
+
### **关系流向**
|
| 117 |
+
|
| 118 |
+
- 清晰的箭头指向和数据流
|
| 119 |
+
- `interaction_prompt`作为边标签
|
| 120 |
+
- 不同`type`的线条样式区分
|
| 121 |
+
|
| 122 |
+
### **问题突出显示**
|
| 123 |
+
|
| 124 |
+
- `failures`用红色边框标记
|
| 125 |
+
- 悬停显示风险类型和描述
|
| 126 |
+
- 受影响实体的高亮显示
|
| 127 |
+
|
| 128 |
+
### **优化建议面板**
|
| 129 |
+
|
| 130 |
+
- 右侧面板显示建议列表
|
| 131 |
+
- 按`recommendation_type`分组
|
| 132 |
+
- 点击查看详细改进方案
|
| 133 |
+
|
| 134 |
+
## 📊 **质量标准**
|
| 135 |
+
|
| 136 |
+
基于这些示例,高质量 Knowledge Graph 应具备:
|
| 137 |
+
|
| 138 |
+
1. **完整性** (✓ 所有必需字段存在)
|
| 139 |
+
2. **准确性** (✓ ContentReference 指向正确)
|
| 140 |
+
3. **可读性** (✓ 描述清晰易懂)
|
| 141 |
+
4. **实用性** (✓ 失败和优化建议有价值)
|
| 142 |
+
5. **一致性** (✓ 命名和格式统一)
|
| 143 |
+
|
| 144 |
+
## 🔄 **自定义建议**
|
| 145 |
+
|
| 146 |
+
在创建新的 Knowledge Graph 时:
|
| 147 |
+
|
| 148 |
+
### **保持的元素**
|
| 149 |
+
|
| 150 |
+
- 标准的实体类型 (Agent, Task, Tool, Input, Output, Human)
|
| 151 |
+
- 预定义的关系类型 (CONSUMED_BY, PERFORMS, 等)
|
| 152 |
+
- 结构化的`ContentReference`格式
|
| 153 |
+
- 有意义的`system_summary`
|
| 154 |
+
|
| 155 |
+
### **可调整的元素**
|
| 156 |
+
|
| 157 |
+
- 具体的实体数量和名称
|
| 158 |
+
- 失败类型和数量(基于实际问题)
|
| 159 |
+
- 优化建议的具体内容
|
| 160 |
+
- 元数据的详细程度
|
| 161 |
+
|
| 162 |
+
## 🛠 **开发者提示**
|
| 163 |
+
|
| 164 |
+
1. **总是包含 failures 和 optimizations**,即使是空数组
|
| 165 |
+
2. **使用有意义的实体 ID**,便于调试和维护
|
| 166 |
+
3. **确保 ContentReference 准确性**,支持内容溯源
|
| 167 |
+
4. **编写流畅的 system_summary**,包含指代词
|
| 168 |
+
5. **提供置信度信息**,帮助质量评估
|
| 169 |
+
|
| 170 |
+
## 📝 **更新历史**
|
| 171 |
+
|
| 172 |
+
- **v2.1.0**: 添加了置信度评分和优化建议
|
| 173 |
+
- **v2.0.0**: 引入失败检测和内容引用
|
| 174 |
+
- **v1.5.0**: 增强元数据和质量指标
|
| 175 |
+
- **v1.0.0**: 基础 Knowledge Graph 结构
|
| 176 |
+
|
| 177 |
+
---
|
| 178 |
+
|
| 179 |
+
_这些示例代表了 AgentGraph Knowledge Graph 的最高质量标准,可作为开发和评估的基准。_
|
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
# Sample Data System
|
| 2 |
|
| 3 |
## Overview
|
| 4 |
|
| 5 |
-
The sample data system automatically inserts curated examples
|
| 6 |
|
| 7 |
## Features
|
| 8 |
|
|
@@ -12,36 +12,35 @@ The sample data system automatically inserts curated examples into new AgentGrap
|
|
| 12 |
- Non-destructive: skips insertion if existing data is found
|
| 13 |
- Logs all operations for transparency
|
| 14 |
|
| 15 |
-
### 🎯
|
| 16 |
|
| 17 |
-
The system includes
|
| 18 |
|
| 19 |
-
1. **
|
| 20 |
|
| 21 |
-
- Type: `
|
| 22 |
-
- Example:
|
| 23 |
-
- 6 entities, 5 relations
|
| 24 |
-
|
| 25 |
-
2. **Research Task** (Medium)
|
| 26 |
|
| 27 |
-
|
| 28 |
-
- Example: Location and business hours research
|
| 29 |
-
- 6 entities, 6 relations in knowledge graph
|
| 30 |
|
| 31 |
-
|
| 32 |
-
-
|
| 33 |
-
-
|
| 34 |
-
-
|
| 35 |
|
| 36 |
-
### 🕸️ Knowledge Graph Examples
|
| 37 |
|
| 38 |
-
Each trace comes with a pre-generated knowledge graph
|
| 39 |
|
| 40 |
-
- Agent interactions and roles
|
| 41 |
-
- Task decomposition
|
| 42 |
-
- Information flow
|
| 43 |
-
-
|
| 44 |
-
-
|
|
|
|
|
|
|
| 45 |
|
| 46 |
## Technical Implementation
|
| 47 |
|
|
@@ -122,17 +121,23 @@ To disable automatic sample data insertion, modify `init_db.py`:
|
|
| 122 |
|
| 123 |
## Benefits for Users
|
| 124 |
|
| 125 |
-
1. **Immediate Value**: New users see
|
| 126 |
-
2. **Learning**: Examples demonstrate
|
| 127 |
-
3. **Testing**: Users can test features
|
| 128 |
-
4. **Reference**: Examples serve as templates
|
|
|
|
|
|
|
| 129 |
|
| 130 |
## Quality Assurance
|
| 131 |
|
| 132 |
-
- All sample traces are realistic and
|
| 133 |
-
- Knowledge graphs are hand-crafted to
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
- Content is appropriate and safe for all audiences
|
| 135 |
-
- Regular validation ensures data integrity
|
| 136 |
|
| 137 |
## Maintenance
|
| 138 |
|
|
|
|
| 1 |
+
# Enhanced Sample Data System
|
| 2 |
|
| 3 |
## Overview
|
| 4 |
|
| 5 |
+
The enhanced sample data system automatically inserts curated examples showcasing AgentGraph's complete feature set into new databases. Instead of starting with an empty system, users immediately see examples of traces and knowledge graphs with failure detection, optimization recommendations, and advanced content referencing capabilities.
|
| 6 |
|
| 7 |
## Features
|
| 8 |
|
|
|
|
| 12 |
- Non-destructive: skips insertion if existing data is found
|
| 13 |
- Logs all operations for transparency
|
| 14 |
|
| 15 |
+
### 🎯 Enhanced Examples
|
| 16 |
|
| 17 |
+
The system includes 2 carefully selected examples showcasing AgentGraph's advanced capabilities:
|
| 18 |
|
| 19 |
+
1. **Oxford Economics AI Assistant** (Enhanced)
|
| 20 |
|
| 21 |
+
- Type: `aif_inference`
|
| 22 |
+
- Example: AI assistant processing economic inquiry with failure detection
|
| 23 |
+
- 6 entities, 5 relations, 1 failure, 2 optimizations
|
| 24 |
+
- Features: Content references, quality scoring, system summary
|
|
|
|
| 25 |
|
| 26 |
+
2. **Simple Q&A Demonstration** (Basic)
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
- Type: `conversation`
|
| 29 |
+
- Example: Basic Oxford Economics service inquiry
|
| 30 |
+
- 4 entities, 4 relations, 0 failures, 1 optimization
|
| 31 |
+
- Features: Streamlined structure, clear interaction flow
|
| 32 |
|
| 33 |
+
### 🕸️ Enhanced Knowledge Graph Examples
|
| 34 |
|
| 35 |
+
Each trace comes with a pre-generated knowledge graph showcasing AgentGraph's complete feature set:
|
| 36 |
|
| 37 |
+
- **Agent interactions and roles** with detailed prompts and content references
|
| 38 |
+
- **Task decomposition** with clear importance levels
|
| 39 |
+
- **Information flow** with specific interaction prompts
|
| 40 |
+
- **Failure detection** identifying real issues (spelling errors, system gaps)
|
| 41 |
+
- **Optimization recommendations** providing actionable improvements
|
| 42 |
+
- **Quality assessment** with confidence scores and metadata
|
| 43 |
+
- **System summaries** with natural language descriptions using pronouns
|
| 44 |
|
| 45 |
## Technical Implementation
|
| 46 |
|
|
|
|
| 121 |
|
| 122 |
## Benefits for Users
|
| 123 |
|
| 124 |
+
1. **Immediate Value**: New users see AgentGraph's complete capabilities immediately
|
| 125 |
+
2. **Learning**: Examples demonstrate failure detection, optimization suggestions, and advanced features
|
| 126 |
+
3. **Testing**: Users can test all AgentGraph features including quality assessment and content referencing
|
| 127 |
+
4. **Reference**: Examples serve as high-quality templates showcasing best practices
|
| 128 |
+
5. **Feature Discovery**: Users understand the full potential of knowledge graph enhancement
|
| 129 |
+
6. **Quality Standards**: Examples demonstrate what production-ready knowledge graphs should contain
|
| 130 |
|
| 131 |
## Quality Assurance
|
| 132 |
|
| 133 |
+
- All sample traces are realistic and demonstrate real-world scenarios
|
| 134 |
+
- Knowledge graphs are hand-crafted to showcase AgentGraph's complete feature set
|
| 135 |
+
- Examples include actual failure detection (spelling errors, system gaps)
|
| 136 |
+
- Optimization recommendations are practical and actionable
|
| 137 |
+
- Content references are accurate and support proper traceability
|
| 138 |
+
- Quality scores reflect realistic assessment metrics
|
| 139 |
- Content is appropriate and safe for all audiences
|
| 140 |
+
- Regular validation ensures data integrity and feature completeness
|
| 141 |
|
| 142 |
## Maintenance
|
| 143 |
|
|
@@ -1,489 +1,269 @@
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
"""
|
| 3 |
-
|
| 4 |
-
|
| 5 |
"""
|
| 6 |
|
| 7 |
import json
|
| 8 |
import logging
|
| 9 |
-
from typing import Dict,
|
| 10 |
-
from backend.database.utils import save_trace, save_knowledge_graph
|
| 11 |
-
from backend.database.models import Trace, KnowledgeGraph
|
| 12 |
|
| 13 |
logger = logging.getLogger(__name__)
|
| 14 |
|
| 15 |
-
# Enhanced sample traces
|
| 16 |
-
|
| 17 |
{
|
| 18 |
-
"filename": "
|
| 19 |
-
"title": "
|
| 20 |
-
"description": "
|
| 21 |
-
"
|
| 22 |
-
System Configuration: Multi-agent financial analysis system
|
| 23 |
-
|
| 24 |
-
=== Agent Definitions ===
|
| 25 |
-
Agent: SQL_Expert
|
| 26 |
-
Role: Database analyst specializing in financial data queries
|
| 27 |
-
Capabilities: Complex SQL queries, data validation, performance optimization
|
| 28 |
-
Backstory: You are an expert SQL developer with 10+ years of experience in financial data analysis. You specialize in creating efficient queries for large datasets and ensuring data accuracy.
|
| 29 |
-
|
| 30 |
-
Agent: Business_Analyst
|
| 31 |
-
Role: Financial analyst with expertise in budget analysis and KPI reporting
|
| 32 |
-
Capabilities: Financial modeling, trend analysis, business intelligence reporting
|
| 33 |
-
Backstory: You are a senior business analyst with deep knowledge of financial metrics, budget planning, and quarterly reporting processes.
|
| 34 |
-
|
| 35 |
-
Agent: Data_Validator
|
| 36 |
-
Role: Quality assurance specialist ensuring data integrity and accuracy
|
| 37 |
-
Capabilities: Data validation, anomaly detection, cross-referencing
|
| 38 |
-
Backstory: You are a meticulous data quality specialist who ensures all financial reports meet audit standards and regulatory requirements.
|
| 39 |
-
|
| 40 |
-
=== Task Execution ===
|
| 41 |
-
User Request: "Analyze Q3 2024 budget performance vs Q3 2023, focusing on operational expenses and revenue trends"
|
| 42 |
-
|
| 43 |
-
SQL_Expert: I'll create a comprehensive query to compare Q3 2024 vs Q3 2023 financial data:
|
| 44 |
-
|
| 45 |
-
```sql
|
| 46 |
-
SELECT
|
| 47 |
-
fy.fiscal_year,
|
| 48 |
-
fy.quarter,
|
| 49 |
-
SUM(CASE WHEN category = 'Revenue' THEN amount ELSE 0 END) as total_revenue,
|
| 50 |
-
SUM(CASE WHEN category = 'OpEx' THEN amount ELSE 0 END) as operational_expenses,
|
| 51 |
-
SUM(CASE WHEN category = 'Revenue' THEN amount ELSE 0 END) -
|
| 52 |
-
SUM(CASE WHEN category = 'OpEx' THEN amount ELSE 0 END) as net_margin
|
| 53 |
-
FROM financial_data fd
|
| 54 |
-
JOIN fiscal_years fy ON fd.period_id = fy.id
|
| 55 |
-
WHERE fy.fiscal_year IN (2023, 2024)
|
| 56 |
-
AND fy.quarter = 'Q3'
|
| 57 |
-
AND fd.status = 'approved'
|
| 58 |
-
GROUP BY fy.fiscal_year, fy.quarter
|
| 59 |
-
ORDER BY fy.fiscal_year;
|
| 60 |
-
```
|
| 61 |
-
|
| 62 |
-
Business_Analyst: Based on the SQL results, I'll analyze the trends:
|
| 63 |
-
|
| 64 |
-
Q3 2024 vs Q3 2023 Performance Analysis:
|
| 65 |
-
- Revenue Growth: 12.5% YoY increase ($2.4M to $2.7M)
|
| 66 |
-
- OpEx Control: 8.2% YoY increase ($1.8M to $1.95M)
|
| 67 |
-
- Net Margin Improvement: 23.1% increase ($600K to $750K)
|
| 68 |
-
|
| 69 |
-
Key Insights:
|
| 70 |
-
1. Revenue growth outpaced expense growth (12.5% vs 8.2%)
|
| 71 |
-
2. Operational efficiency improvements evident in margin expansion
|
| 72 |
-
3. Cost control measures implemented in Q2 showing positive impact
|
| 73 |
-
|
| 74 |
-
Data_Validator: Validation completed. Cross-referenced with:
|
| 75 |
-
- General ledger entries: ✓ Match
|
| 76 |
-
- Budget vs actual variance reports: ✓ Within 2% tolerance
|
| 77 |
-
- Prior quarter reconciliations: ✓ Consistent methodology
|
| 78 |
-
- Audit trail documentation: ✓ Complete
|
| 79 |
-
|
| 80 |
-
Warning: Revenue spike in Week 3 of Q3 2024 needs explanation (unusual $200K transaction on 7/15/2024)
|
| 81 |
-
|
| 82 |
-
Final Report: Q3 2024 shows strong performance with controlled operational expenses and healthy revenue growth. Recommend investigating the July revenue anomaly for next quarter's planning.
|
| 83 |
-
""",
|
| 84 |
-
"trace_type": "multi_agent",
|
| 85 |
"trace_source": "sample_data",
|
| 86 |
-
"tags": ["
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
{
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
Tool: response_template_engine
|
| 128 |
-
Function: generate_response(template_id: str, variables: dict) -> str
|
| 129 |
-
Purpose: Generate personalized email responses using approved templates
|
| 130 |
-
Parameters:
|
| 131 |
-
- template_id: Template identifier for response type
|
| 132 |
-
- variables: Customer-specific information for personalization
|
| 133 |
-
|
| 134 |
-
=== Task Execution Workflow ===
|
| 135 |
-
Incoming Email: "I can't find my order confirmation from last month and need to return an item. Order was placed around March 15th for a laptop bag, but I never received the confirmation email."
|
| 136 |
-
|
| 137 |
-
Email_Classifier: Analyzing incoming email...
|
| 138 |
-
Category: ORDER_INQUIRY + RETURN_REQUEST
|
| 139 |
-
Priority: MEDIUM (non-urgent return request)
|
| 140 |
-
Sentiment: NEUTRAL (factual inquiry, no frustration indicators)
|
| 141 |
-
Complexity: MEDIUM (requires order lookup + return policy)
|
| 142 |
-
Estimated Resolution Time: 15-20 minutes
|
| 143 |
-
|
| 144 |
-
Search_Agent: Executing search operations...
|
| 145 |
-
|
| 146 |
-
1. Searching email archives for order confirmation:
|
| 147 |
-
email_search_engine(
|
| 148 |
-
query="laptop bag order confirmation March 15",
|
| 149 |
-
filters={"date_range": "2024-03-10 to 2024-03-20", "type": "order_confirmation"},
|
| 150 |
-
limit=10
|
| 151 |
-
)
|
| 152 |
-
Result: Found 3 potential matches for laptop bag orders in March 2024
|
| 153 |
-
|
| 154 |
-
2. Knowledge base lookup for return policy:
|
| 155 |
-
knowledge_base_search(
|
| 156 |
-
query="laptop bag return policy procedure",
|
| 157 |
-
category="returns_exchanges"
|
| 158 |
-
)
|
| 159 |
-
Result: Return policy allows 30-day returns for accessories with original packaging
|
| 160 |
-
|
| 161 |
-
Response_Generator: Generating personalized response...
|
| 162 |
-
|
| 163 |
-
Template: ORDER_INQUIRY_WITH_RETURN
|
| 164 |
-
Variables: {
|
| 165 |
-
"customer_name": "Valued Customer",
|
| 166 |
-
"order_date": "March 15, 2024",
|
| 167 |
-
"product": "laptop bag",
|
| 168 |
-
"return_window": "30 days",
|
| 169 |
-
"next_steps": "order lookup and return authorization"
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
Generated Response:
|
| 173 |
-
"Dear Valued Customer,
|
| 174 |
-
|
| 175 |
-
Thank you for contacting us regarding your laptop bag order from March 15, 2024. I understand you're looking for your order confirmation and would like to initiate a return.
|
| 176 |
-
|
| 177 |
-
I've located your order in our system and will send you the confirmation details separately. For your return request, our policy allows returns within 30 days of purchase for accessories in original packaging.
|
| 178 |
-
|
| 179 |
-
To proceed with your return:
|
| 180 |
-
1. I'll email you a prepaid return label
|
| 181 |
-
2. Package the item in its original packaging if available
|
| 182 |
-
3. Schedule pickup or drop off at any authorized location
|
| 183 |
-
|
| 184 |
-
Your return authorization number is RMA-2024-0847. Please reference this in all future communications.
|
| 185 |
-
|
| 186 |
-
Is there anything else I can help you with today?
|
| 187 |
-
|
| 188 |
-
Best regards,
|
| 189 |
-
Customer Support Team"
|
| 190 |
-
|
| 191 |
-
System Summary: Successfully processed order inquiry with return request. Customer issue resolved through automated search and personalized response generation.
|
| 192 |
-
""",
|
| 193 |
-
"trace_type": "conversation",
|
| 194 |
-
"trace_source": "sample_data",
|
| 195 |
-
"tags": ["email_automation", "customer_support", "search", "nlp"]
|
| 196 |
},
|
| 197 |
{
|
| 198 |
-
"filename": "
|
| 199 |
-
"title": "
|
| 200 |
-
"description": "
|
| 201 |
-
"
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
Agent: Paper_Analyzer
|
| 206 |
-
Role: Academic research specialist with expertise in paper analysis and content extraction
|
| 207 |
-
Capabilities: Abstract analysis, methodology assessment, statistical interpretation, research quality evaluation
|
| 208 |
-
Backstory: You are a PhD-level researcher with expertise across multiple domains, trained to quickly analyze academic papers and extract key insights, methodologies, and contributions.
|
| 209 |
-
|
| 210 |
-
Agent: Citation_Mapper
|
| 211 |
-
Role: Citation network specialist building connections between research papers and authors
|
| 212 |
-
Capabilities: Citation tracking, influence mapping, collaboration network analysis, trend identification
|
| 213 |
-
Backstory: You are a bibliometric specialist with deep knowledge of academic publishing patterns, capable of identifying influential papers and tracking research evolution across disciplines.
|
| 214 |
-
|
| 215 |
-
Agent: Synthesis_Expert
|
| 216 |
-
Role: Research synthesis specialist combining insights from multiple sources
|
| 217 |
-
Capabilities: Literature review, gap analysis, trend synthesis, recommendation generation
|
| 218 |
-
Backstory: You are an expert at synthesizing complex research findings into actionable insights, with the ability to identify research gaps and suggest future directions.
|
| 219 |
-
|
| 220 |
-
=== Tool Definitions ===
|
| 221 |
-
Tool: academic_search_engine
|
| 222 |
-
Function: search_papers(query: str, fields: List[str], years: str) -> List[Paper]
|
| 223 |
-
Purpose: Search academic databases for research papers using advanced query syntax
|
| 224 |
-
Parameters:
|
| 225 |
-
- query: Research topic or keywords
|
| 226 |
-
- fields: Academic fields to search (CS, Physics, Biology, etc.)
|
| 227 |
-
- years: Publication year range filter
|
| 228 |
-
|
| 229 |
-
Tool: citation_analyzer
|
| 230 |
-
Function: analyze_citations(paper_ids: List[str]) -> CitationNetwork
|
| 231 |
-
Purpose: Build citation networks and analyze research impact
|
| 232 |
-
Parameters:
|
| 233 |
-
- paper_ids: List of paper identifiers to analyze
|
| 234 |
-
- Returns: Network graph with citation relationships and metrics
|
| 235 |
-
|
| 236 |
-
Tool: content_extractor
|
| 237 |
-
Function: extract_insights(paper_url: str, sections: List[str]) -> PaperInsights
|
| 238 |
-
Purpose: Extract structured information from research papers
|
| 239 |
-
Parameters:
|
| 240 |
-
- paper_url: URL or identifier for paper access
|
| 241 |
-
- sections: Specific sections to analyze (abstract, methodology, results, etc.)
|
| 242 |
-
|
| 243 |
-
=== Research Task Execution ===
|
| 244 |
-
Research Query: "Analyze recent advancements in transformer architectures for natural language processing, focusing on efficiency improvements and novel attention mechanisms (2022-2024)"
|
| 245 |
-
|
| 246 |
-
Paper_Analyzer: Initiating comprehensive literature search...
|
| 247 |
-
|
| 248 |
-
academic_search_engine(
|
| 249 |
-
query="transformer efficiency attention mechanism natural language processing",
|
| 250 |
-
fields=["Computer Science", "Artificial Intelligence", "Machine Learning"],
|
| 251 |
-
years="2022-2024"
|
| 252 |
-
)
|
| 253 |
-
|
| 254 |
-
Found 47 relevant papers. Analyzing top 10 high-impact publications:
|
| 255 |
-
|
| 256 |
-
1. "Efficient Transformers: A Survey" (2023) - Tay et al.
|
| 257 |
-
- Comprehensive review of efficiency techniques
|
| 258 |
-
- 847 citations in 18 months
|
| 259 |
-
- Key insight: Linear attention reduces complexity from O(n²) to O(n)
|
| 260 |
-
|
| 261 |
-
2. "Flash Attention: Fast and Memory-Efficient Exact Attention" (2022) - Dao et al.
|
| 262 |
-
- Novel attention algorithm implementation
|
| 263 |
-
- 1,200+ citations
|
| 264 |
-
- Key insight: IO-aware attention reduces memory usage by 10x
|
| 265 |
-
|
| 266 |
-
3. "PaLM: Scaling Language Modeling with Pathways" (2022) - Chowdhery et al.
|
| 267 |
-
- Large-scale transformer scaling study
|
| 268 |
-
- 956 citations
|
| 269 |
-
- Key insight: Model scaling laws continue to hold at 540B parameters
|
| 270 |
-
|
| 271 |
-
Citation_Mapper: Building citation network for efficiency-focused transformer research...
|
| 272 |
-
|
| 273 |
-
citation_analyzer(paper_ids=["tay2023efficient", "dao2022flashattention", "chowdhery2022palm", ...])
|
| 274 |
-
|
| 275 |
-
Citation Network Analysis:
|
| 276 |
-
- Central papers: Flash Attention (highest centrality score: 0.84)
|
| 277 |
-
- Research clusters identified:
|
| 278 |
-
1. Memory-efficient attention mechanisms (12 papers)
|
| 279 |
-
2. Linear attention approximations (8 papers)
|
| 280 |
-
3. Sparse attention patterns (15 papers)
|
| 281 |
-
4. Hardware-aware optimizations (7 papers)
|
| 282 |
-
|
| 283 |
-
Influential Authors:
|
| 284 |
-
- Tri Dao (Stanford): 4 high-impact papers on attention efficiency
|
| 285 |
-
- Yi Tay (Google): 3 survey papers connecting research areas
|
| 286 |
-
- Lukasz Kaiser (Google): 5 papers on transformer variants
|
| 287 |
-
|
| 288 |
-
Research Evolution Trends:
|
| 289 |
-
- 2022: Focus on memory reduction and hardware optimization
|
| 290 |
-
- 2023: Emphasis on theoretical analysis of attention mechanisms
|
| 291 |
-
- 2024: Integration of efficiency techniques with larger models
|
| 292 |
-
|
| 293 |
-
Synthesis_Expert: Consolidating research findings and identifying opportunities...
|
| 294 |
-
|
| 295 |
-
Content Analysis Summary:
|
| 296 |
-
|
| 297 |
-
Major Efficiency Breakthroughs (2022-2024):
|
| 298 |
-
1. Flash Attention: 10x memory reduction with no accuracy loss
|
| 299 |
-
2. Linear Attention: Quadratic to linear complexity transformation
|
| 300 |
-
3. Sparse Patterns: 50-80% computation reduction in long sequences
|
| 301 |
-
4. Mixed Precision: 2x speedup with minimal quality impact
|
| 302 |
-
|
| 303 |
-
Research Gaps Identified:
|
| 304 |
-
1. Limited evaluation on very long sequences (>100K tokens)
|
| 305 |
-
2. Lack of standardized efficiency benchmarks across different tasks
|
| 306 |
-
3. Insufficient analysis of efficiency-accuracy trade-offs in specialized domains
|
| 307 |
-
4. Missing studies on efficiency techniques for multilingual models
|
| 308 |
|
| 309 |
-
|
| 310 |
-
1. Develop attention mechanisms specifically optimized for streaming applications
|
| 311 |
-
2. Investigate efficiency techniques for multimodal transformers
|
| 312 |
-
3. Create unified framework for comparing attention efficiency methods
|
| 313 |
-
4. Explore hardware-software co-design for next-generation attention
|
| 314 |
|
| 315 |
-
|
|
|
|
|
|
|
|
|
|
| 316 |
|
| 317 |
-
|
| 318 |
-
- Adopt Flash Attention for immediate memory efficiency gains
|
| 319 |
-
- Investigate linear attention for applications requiring long context
|
| 320 |
-
- Benchmark efficiency techniques on domain-specific tasks before deployment
|
| 321 |
-
- Monitor emerging sparse attention patterns for future integration
|
| 322 |
|
| 323 |
-
|
| 324 |
-
""",
|
| 325 |
-
"trace_type": "research",
|
| 326 |
-
"trace_source": "sample_data",
|
| 327 |
-
"tags": ["academic_research", "transformers", "nlp", "citation_analysis"]
|
| 328 |
}
|
| 329 |
]
|
| 330 |
|
| 331 |
-
# Enhanced knowledge graphs
|
| 332 |
-
|
| 333 |
{
|
| 334 |
-
"
|
| 335 |
-
"
|
| 336 |
-
"system_name": "Multi-Agent Financial Analysis System",
|
| 337 |
-
"system_summary": "This system orchestrates specialized financial analysis agents to process quarterly budget data through SQL queries and business intelligence. The SQL Expert handles complex database operations, the Business Analyst interprets financial trends and generates insights, while the Data Validator ensures accuracy and compliance. The system demonstrates effective agent collaboration for delivering comprehensive financial reports with validated data and actionable recommendations.",
|
| 338 |
"graph_data": {
|
|
|
|
|
|
|
| 339 |
"entities": [
|
| 340 |
{
|
| 341 |
"id": "agent_001",
|
| 342 |
-
"type": "Agent",
|
| 343 |
-
"name": "SQL Expert",
|
| 344 |
-
"importance": "HIGH",
|
| 345 |
-
"raw_prompt": "You are an expert SQL developer with 10+ years of experience in financial data analysis. You specialize in creating efficient queries for large datasets and ensuring data accuracy. Your role involves database analysis, complex SQL queries, data validation, and performance optimization for financial reporting systems.",
|
| 346 |
-
"raw_prompt_ref": [
|
| 347 |
-
{"line_start": 6, "line_end": 9, "confidence": 1.0}
|
| 348 |
-
]
|
| 349 |
-
},
|
| 350 |
-
{
|
| 351 |
-
"id": "agent_002",
|
| 352 |
"type": "Agent",
|
| 353 |
-
"name": "
|
| 354 |
"importance": "HIGH",
|
| 355 |
-
"raw_prompt": "You are a
|
| 356 |
"raw_prompt_ref": [
|
| 357 |
-
{
|
|
|
|
|
|
|
|
|
|
| 358 |
]
|
| 359 |
},
|
| 360 |
{
|
| 361 |
-
"id": "
|
| 362 |
-
"type": "
|
| 363 |
-
"name": "
|
| 364 |
-
"importance": "
|
| 365 |
-
"raw_prompt": "
|
| 366 |
"raw_prompt_ref": [
|
| 367 |
-
{
|
|
|
|
|
|
|
|
|
|
| 368 |
]
|
| 369 |
},
|
| 370 |
{
|
| 371 |
-
"id": "
|
| 372 |
-
"type": "
|
| 373 |
-
"name": "
|
| 374 |
"importance": "HIGH",
|
| 375 |
-
"raw_prompt": "
|
| 376 |
"raw_prompt_ref": [
|
| 377 |
-
{
|
|
|
|
|
|
|
|
|
|
| 378 |
]
|
| 379 |
},
|
| 380 |
{
|
| 381 |
-
"id": "
|
| 382 |
-
"type": "
|
| 383 |
-
"name": "
|
| 384 |
-
"importance": "HIGH",
|
| 385 |
-
"raw_prompt": "
|
| 386 |
"raw_prompt_ref": [
|
| 387 |
-
{
|
|
|
|
|
|
|
|
|
|
| 388 |
]
|
| 389 |
},
|
| 390 |
{
|
| 391 |
-
"id": "
|
| 392 |
-
"type": "
|
| 393 |
-
"name": "
|
| 394 |
-
"importance": "
|
| 395 |
-
"raw_prompt": "
|
| 396 |
"raw_prompt_ref": [
|
| 397 |
-
{
|
|
|
|
|
|
|
|
|
|
| 398 |
]
|
| 399 |
},
|
| 400 |
{
|
| 401 |
-
"id": "
|
| 402 |
-
"type": "
|
| 403 |
-
"name": "
|
| 404 |
"importance": "HIGH",
|
| 405 |
-
"raw_prompt": "
|
| 406 |
"raw_prompt_ref": [
|
| 407 |
-
{
|
|
|
|
|
|
|
|
|
|
| 408 |
]
|
| 409 |
}
|
| 410 |
],
|
| 411 |
"relations": [
|
| 412 |
{
|
| 413 |
"id": "rel_001",
|
| 414 |
-
"source": "
|
| 415 |
-
"target": "
|
| 416 |
-
"type": "
|
| 417 |
"importance": "HIGH",
|
| 418 |
-
"interaction_prompt": "
|
| 419 |
"interaction_prompt_ref": [
|
| 420 |
-
{
|
|
|
|
|
|
|
|
|
|
| 421 |
]
|
| 422 |
},
|
| 423 |
{
|
| 424 |
"id": "rel_002",
|
| 425 |
"source": "agent_001",
|
| 426 |
-
"target": "
|
| 427 |
-
"type": "
|
| 428 |
"importance": "HIGH",
|
| 429 |
-
"interaction_prompt": "
|
| 430 |
"interaction_prompt_ref": [
|
| 431 |
-
{
|
|
|
|
|
|
|
|
|
|
| 432 |
]
|
| 433 |
},
|
| 434 |
{
|
| 435 |
"id": "rel_003",
|
| 436 |
-
"source": "
|
| 437 |
-
"target": "
|
| 438 |
-
"type": "PRODUCES",
|
| 439 |
"importance": "HIGH",
|
| 440 |
-
"interaction_prompt": "
|
| 441 |
"interaction_prompt_ref": [
|
| 442 |
-
{
|
|
|
|
|
|
|
|
|
|
| 443 |
]
|
| 444 |
},
|
| 445 |
{
|
| 446 |
"id": "rel_004",
|
| 447 |
-
"source": "
|
| 448 |
-
"target": "
|
| 449 |
-
"type": "
|
| 450 |
-
"importance": "HIGH",
|
| 451 |
-
"interaction_prompt": "
|
| 452 |
"interaction_prompt_ref": [
|
| 453 |
-
{
|
|
|
|
|
|
|
|
|
|
| 454 |
]
|
| 455 |
},
|
| 456 |
{
|
| 457 |
"id": "rel_005",
|
| 458 |
-
"source": "
|
| 459 |
-
"target": "
|
| 460 |
-
"type": "
|
| 461 |
-
"importance": "MEDIUM",
|
| 462 |
-
"interaction_prompt": "Business Analyst coordinates with Data Validator to ensure analysis accuracy and cross-reference findings with audit standards before final report generation.",
|
| 463 |
-
"interaction_prompt_ref": [
|
| 464 |
-
{"line_start": 52, "line_end": 60, "confidence": 0.8}
|
| 465 |
-
]
|
| 466 |
-
},
|
| 467 |
-
{
|
| 468 |
-
"id": "rel_006",
|
| 469 |
-
"source": "agent_003",
|
| 470 |
-
"target": "output_001",
|
| 471 |
-
"type": "VALIDATES",
|
| 472 |
"importance": "HIGH",
|
| 473 |
-
"interaction_prompt": "
|
| 474 |
"interaction_prompt_ref": [
|
| 475 |
-
{
|
|
|
|
|
|
|
|
|
|
| 476 |
]
|
| 477 |
}
|
| 478 |
],
|
| 479 |
"failures": [
|
| 480 |
{
|
| 481 |
"id": "failure_001",
|
| 482 |
-
"risk_type": "
|
| 483 |
-
"description": "
|
| 484 |
-
"raw_text": "
|
| 485 |
"raw_text_ref": [
|
| 486 |
-
{
|
|
|
|
|
|
|
|
|
|
| 487 |
],
|
| 488 |
"affected_id": "input_001"
|
| 489 |
}
|
|
@@ -491,306 +271,209 @@ ENHANCED_SAMPLE_KNOWLEDGE_GRAPHS = [
|
|
| 491 |
"optimizations": [
|
| 492 |
{
|
| 493 |
"id": "opt_001",
|
| 494 |
-
"recommendation_type": "
|
| 495 |
-
"description": "
|
| 496 |
-
"affected_ids": ["
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 497 |
"raw_text_ref": [
|
| 498 |
-
{
|
|
|
|
|
|
|
|
|
|
| 499 |
]
|
| 500 |
}
|
| 501 |
],
|
| 502 |
-
"system_name": "Multi-Agent Financial Analysis System",
|
| 503 |
-
"system_summary": "This system orchestrates specialized financial analysis agents to process quarterly budget data through SQL queries and business intelligence. The SQL Expert handles complex database operations, the Business Analyst interprets financial trends and generates insights, while the Data Validator ensures accuracy and compliance. The system demonstrates effective agent collaboration for delivering comprehensive financial reports with validated data and actionable recommendations.",
|
| 504 |
"metadata": {
|
| 505 |
-
"
|
| 506 |
-
|
| 507 |
-
|
| 508 |
-
|
| 509 |
-
|
| 510 |
-
"
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
"overlap_size": 0,
|
| 517 |
-
"splitter_type": "agent_semantic",
|
| 518 |
-
"log_type": "multi_agent",
|
| 519 |
-
"boundary_used": "content_boundary",
|
| 520 |
-
"boundary_confidence": 0.95,
|
| 521 |
-
"contains_agent_markers": True,
|
| 522 |
-
"contains_tool_patterns": True,
|
| 523 |
-
"overlap_with_previous": False,
|
| 524 |
-
"processed_at": "2025-09-01T10:30:00.000000",
|
| 525 |
-
"line_mapping_created": True,
|
| 526 |
-
"window_total": 1,
|
| 527 |
-
"trace_id": "sample_financial_001",
|
| 528 |
-
"processing_run_id": "sample_run_001"
|
| 529 |
-
},
|
| 530 |
-
"trace_info": {
|
| 531 |
-
"trace_id": "sample_financial_001",
|
| 532 |
-
"window_count": 1,
|
| 533 |
-
"processed_at": "2025-09-01T10:30:00.000000",
|
| 534 |
-
"source_trace_id": "sample_financial_001",
|
| 535 |
-
"processing_run_id": "sample_run_001"
|
| 536 |
-
},
|
| 537 |
-
"processing_params": {
|
| 538 |
-
"method_name": "production",
|
| 539 |
-
"batch_size": 3,
|
| 540 |
-
"parallel_processing": True,
|
| 541 |
-
"merge_method": "single_kg_direct",
|
| 542 |
-
"optimization_applied": True,
|
| 543 |
-
"window_size": 800000,
|
| 544 |
-
"overlap_size": 0,
|
| 545 |
-
"splitter_type": "agent_semantic"
|
| 546 |
-
}
|
| 547 |
}
|
| 548 |
}
|
| 549 |
},
|
| 550 |
-
# Additional knowledge graphs would follow the same pattern...
|
| 551 |
-
# (I'll create one more as an example and then you can see the complete structure)
|
| 552 |
{
|
| 553 |
-
"
|
| 554 |
-
"
|
| 555 |
-
"system_name": "Intelligent Email Processing and Search System",
|
| 556 |
-
"system_summary": "This system automates email processing through intelligent classification, search coordination, and response generation. The Email Classifier analyzes incoming messages for categorization and priority scoring, the Search Agent coordinates information retrieval across email archives and knowledge bases, while the Response Generator creates personalized customer communications. The system demonstrates sophisticated tool integration for efficient customer support automation.",
|
| 557 |
"graph_data": {
|
|
|
|
|
|
|
| 558 |
"entities": [
|
| 559 |
{
|
| 560 |
-
"id": "
|
| 561 |
-
"type": "
|
| 562 |
-
"name": "
|
| 563 |
"importance": "HIGH",
|
| 564 |
-
"raw_prompt": "
|
| 565 |
"raw_prompt_ref": [
|
| 566 |
-
{
|
|
|
|
|
|
|
|
|
|
| 567 |
]
|
| 568 |
},
|
| 569 |
{
|
| 570 |
-
"id": "
|
| 571 |
-
"type": "Agent",
|
| 572 |
-
"name": "Search Agent",
|
| 573 |
-
"importance": "HIGH",
|
| 574 |
-
"raw_prompt": "You are an expert search specialist with deep knowledge of information retrieval systems, capable of finding relevant information across multiple data sources and formats. Your capabilities include semantic search, query optimization, result ranking, and context understanding.",
|
| 575 |
-
"raw_prompt_ref": [
|
| 576 |
-
{"line_start": 11, "line_end": 14, "confidence": 1.0}
|
| 577 |
-
]
|
| 578 |
-
},
|
| 579 |
-
{
|
| 580 |
-
"id": "agent_003",
|
| 581 |
"type": "Agent",
|
| 582 |
-
"name": "
|
| 583 |
-
"importance": "HIGH",
|
| 584 |
-
"raw_prompt": "You are a customer service expert with excellent communication skills, trained to generate helpful, professional, and empathetic responses that resolve customer issues efficiently. Your expertise includes template customization, tone adaptation, policy compliance, and multilingual support.",
|
| 585 |
-
"raw_prompt_ref": [
|
| 586 |
-
{"line_start": 16, "line_end": 19, "confidence": 1.0}
|
| 587 |
-
]
|
| 588 |
-
},
|
| 589 |
-
{
|
| 590 |
-
"id": "tool_001",
|
| 591 |
-
"type": "Tool",
|
| 592 |
-
"name": "Email Search Engine",
|
| 593 |
"importance": "HIGH",
|
| 594 |
-
"raw_prompt": "
|
| 595 |
"raw_prompt_ref": [
|
| 596 |
-
{
|
|
|
|
|
|
|
|
|
|
| 597 |
]
|
| 598 |
},
|
| 599 |
{
|
| 600 |
-
"id": "
|
| 601 |
-
"type": "
|
| 602 |
-
"name": "
|
| 603 |
-
"importance": "MEDIUM",
|
| 604 |
-
"raw_prompt": "search_kb(query: str, category: str) -> List[KBArticle]. Search internal knowledge base for policy information and solutions with query terms and category filters for product or issue type specification.",
|
| 605 |
-
"raw_prompt_ref": [
|
| 606 |
-
{"line_start": 29, "line_end": 34, "confidence": 1.0}
|
| 607 |
-
]
|
| 608 |
-
},
|
| 609 |
-
{
|
| 610 |
-
"id": "tool_003",
|
| 611 |
-
"type": "Tool",
|
| 612 |
-
"name": "Response Template Engine",
|
| 613 |
-
"importance": "MEDIUM",
|
| 614 |
-
"raw_prompt": "generate_response(template_id: str, variables: dict) -> str. Generate personalized email responses using approved templates with template identifiers and customer-specific variables for personalization.",
|
| 615 |
-
"raw_prompt_ref": [
|
| 616 |
-
{"line_start": 36, "line_end": 41, "confidence": 1.0}
|
| 617 |
-
]
|
| 618 |
-
},
|
| 619 |
-
{
|
| 620 |
-
"id": "input_001",
|
| 621 |
-
"type": "Input",
|
| 622 |
-
"name": "Customer Email Inquiry",
|
| 623 |
"importance": "HIGH",
|
| 624 |
-
"raw_prompt": "
|
| 625 |
"raw_prompt_ref": [
|
| 626 |
-
{
|
|
|
|
|
|
|
|
|
|
| 627 |
]
|
| 628 |
},
|
| 629 |
{
|
| 630 |
-
"id": "
|
| 631 |
-
"type": "Output",
|
| 632 |
-
"name": "
|
| 633 |
"importance": "HIGH",
|
| 634 |
-
"raw_prompt": "
|
| 635 |
"raw_prompt_ref": [
|
| 636 |
-
{
|
|
|
|
|
|
|
|
|
|
| 637 |
]
|
| 638 |
}
|
| 639 |
],
|
| 640 |
"relations": [
|
| 641 |
{
|
| 642 |
-
"id": "
|
| 643 |
-
"source": "
|
| 644 |
-
"target": "
|
| 645 |
-
"type": "
|
| 646 |
"importance": "HIGH",
|
| 647 |
-
"interaction_prompt": "
|
| 648 |
-
"interaction_prompt_ref": [
|
| 649 |
-
{"line_start": 46, "line_end": 51, "confidence": 1.0}
|
| 650 |
-
]
|
| 651 |
-
},
|
| 652 |
-
{
|
| 653 |
-
"id": "rel_002",
|
| 654 |
-
"source": "agent_001",
|
| 655 |
-
"target": "agent_002",
|
| 656 |
-
"type": "DELEGATES_TO",
|
| 657 |
-
"importance": "HIGH",
|
| 658 |
-
"interaction_prompt": "Email Classifier delegates to Search Agent for order lookup and policy information retrieval based on the categorized inquiry requirements.",
|
| 659 |
"interaction_prompt_ref": [
|
| 660 |
-
{
|
|
|
|
|
|
|
|
|
|
| 661 |
]
|
| 662 |
},
|
| 663 |
{
|
| 664 |
-
"id": "
|
| 665 |
-
"source": "
|
| 666 |
-
"target": "
|
| 667 |
-
"type": "
|
| 668 |
"importance": "HIGH",
|
| 669 |
-
"interaction_prompt": "
|
| 670 |
"interaction_prompt_ref": [
|
| 671 |
-
{
|
|
|
|
|
|
|
|
|
|
| 672 |
]
|
| 673 |
},
|
| 674 |
{
|
| 675 |
-
"id": "
|
| 676 |
-
"source": "
|
| 677 |
-
"target": "
|
| 678 |
-
"type": "
|
| 679 |
-
"importance": "MEDIUM",
|
| 680 |
-
"interaction_prompt": "Search Agent queries Knowledge Base Search for laptop bag return policy information including 30-day return window and original packaging requirements.",
|
| 681 |
-
"interaction_prompt_ref": [
|
| 682 |
-
{"line_start": 64, "line_end": 70, "confidence": 1.0}
|
| 683 |
-
]
|
| 684 |
-
},
|
| 685 |
-
{
|
| 686 |
-
"id": "rel_005",
|
| 687 |
-
"source": "agent_002",
|
| 688 |
-
"target": "agent_003",
|
| 689 |
-
"type": "PROVIDES_DATA_TO",
|
| 690 |
"importance": "HIGH",
|
| 691 |
-
"interaction_prompt": "
|
| 692 |
-
"interaction_prompt_ref": [
|
| 693 |
-
{"line_start": 72, "line_end": 73, "confidence": 0.9}
|
| 694 |
-
]
|
| 695 |
-
},
|
| 696 |
-
{
|
| 697 |
-
"id": "rel_006",
|
| 698 |
-
"source": "agent_003",
|
| 699 |
-
"target": "tool_003",
|
| 700 |
-
"type": "USES",
|
| 701 |
-
"importance": "MEDIUM",
|
| 702 |
-
"interaction_prompt": "Response Generator uses Template Engine with ORDER_INQUIRY_WITH_RETURN template and customer-specific variables to create personalized support response.",
|
| 703 |
"interaction_prompt_ref": [
|
| 704 |
-
{
|
|
|
|
|
|
|
|
|
|
| 705 |
]
|
| 706 |
},
|
| 707 |
{
|
| 708 |
-
"id": "
|
| 709 |
-
"source": "
|
| 710 |
-
"target": "
|
| 711 |
-
"type": "
|
| 712 |
"importance": "HIGH",
|
| 713 |
-
"interaction_prompt": "
|
| 714 |
"interaction_prompt_ref": [
|
| 715 |
-
{
|
|
|
|
|
|
|
|
|
|
| 716 |
]
|
| 717 |
}
|
| 718 |
],
|
| 719 |
"failures": [],
|
| 720 |
"optimizations": [
|
| 721 |
{
|
| 722 |
-
"id": "
|
| 723 |
-
"recommendation_type": "
|
| 724 |
-
"description": "
|
| 725 |
-
"affected_ids": ["
|
| 726 |
"raw_text_ref": [
|
| 727 |
-
{
|
| 728 |
-
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
"id": "opt_002",
|
| 732 |
-
"recommendation_type": "PROCESS_IMPROVEMENT",
|
| 733 |
-
"description": "Create integrated search interface combining email archives and knowledge base results to reduce multiple tool calls and improve response generation efficiency.",
|
| 734 |
-
"affected_ids": ["tool_001", "tool_002", "agent_002"],
|
| 735 |
-
"raw_text_ref": [
|
| 736 |
-
{"line_start": 53, "line_end": 70, "confidence": 0.8}
|
| 737 |
]
|
| 738 |
}
|
| 739 |
],
|
| 740 |
-
"system_name": "Intelligent Email Processing and Search System",
|
| 741 |
-
"system_summary": "This system automates email processing through intelligent classification, search coordination, and response generation. The Email Classifier analyzes incoming messages for categorization and priority scoring, the Search Agent coordinates information retrieval across email archives and knowledge bases, while the Response Generator creates personalized customer communications. The system demonstrates sophisticated tool integration for efficient customer support automation.",
|
| 742 |
"metadata": {
|
| 743 |
-
"
|
| 744 |
-
|
| 745 |
-
|
| 746 |
-
|
| 747 |
-
|
| 748 |
-
"
|
| 749 |
-
|
| 750 |
-
|
| 751 |
-
|
| 752 |
-
|
| 753 |
-
|
| 754 |
-
"overlap_size": 0,
|
| 755 |
-
"splitter_type": "agent_semantic",
|
| 756 |
-
"log_type": "conversation",
|
| 757 |
-
"boundary_used": "content_boundary",
|
| 758 |
-
"boundary_confidence": 0.92,
|
| 759 |
-
"contains_agent_markers": True,
|
| 760 |
-
"contains_tool_patterns": True,
|
| 761 |
-
"overlap_with_previous": False,
|
| 762 |
-
"processed_at": "2025-09-01T10:31:00.000000",
|
| 763 |
-
"line_mapping_created": True,
|
| 764 |
-
"window_total": 1,
|
| 765 |
-
"trace_id": "sample_email_001",
|
| 766 |
-
"processing_run_id": "sample_run_002"
|
| 767 |
-
},
|
| 768 |
-
"trace_info": {
|
| 769 |
-
"trace_id": "sample_email_001",
|
| 770 |
-
"window_count": 1,
|
| 771 |
-
"processed_at": "2025-09-01T10:31:00.000000",
|
| 772 |
-
"source_trace_id": "sample_email_001",
|
| 773 |
-
"processing_run_id": "sample_run_002"
|
| 774 |
-
},
|
| 775 |
-
"processing_params": {
|
| 776 |
-
"method_name": "production",
|
| 777 |
-
"batch_size": 3,
|
| 778 |
-
"parallel_processing": True,
|
| 779 |
-
"merge_method": "single_kg_direct",
|
| 780 |
-
"optimization_applied": True,
|
| 781 |
-
"window_size": 800000,
|
| 782 |
-
"overlap_size": 0,
|
| 783 |
-
"splitter_type": "agent_semantic"
|
| 784 |
-
}
|
| 785 |
}
|
| 786 |
}
|
| 787 |
}
|
| 788 |
]
|
| 789 |
|
| 790 |
-
|
|
|
|
| 791 |
"""
|
| 792 |
-
Insert
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 793 |
"""
|
|
|
|
|
|
|
|
|
|
| 794 |
results = {
|
| 795 |
"traces_inserted": 0,
|
| 796 |
"knowledge_graphs_inserted": 0,
|
|
@@ -803,21 +486,22 @@ def insert_enhanced_sample_data(session, force_insert=False):
|
|
| 803 |
existing_sample = session.query(Trace).filter(
|
| 804 |
Trace.trace_source == "sample_data"
|
| 805 |
).first()
|
|
|
|
| 806 |
if existing_sample:
|
| 807 |
-
logger.info("
|
| 808 |
-
results["skipped"] = len(
|
| 809 |
return results
|
| 810 |
|
| 811 |
try:
|
| 812 |
-
# Insert
|
| 813 |
trace_ids = []
|
| 814 |
-
for i, trace_data in enumerate(
|
| 815 |
try:
|
| 816 |
trace = save_trace(
|
| 817 |
session=session,
|
| 818 |
content=trace_data["content"],
|
| 819 |
filename=trace_data["filename"],
|
| 820 |
-
title=trace_data["title"],
|
| 821 |
description=trace_data["description"],
|
| 822 |
trace_type=trace_data["trace_type"],
|
| 823 |
trace_source=trace_data["trace_source"],
|
|
@@ -825,14 +509,14 @@ def insert_enhanced_sample_data(session, force_insert=False):
|
|
| 825 |
)
|
| 826 |
trace_ids.append(trace.trace_id)
|
| 827 |
results["traces_inserted"] += 1
|
| 828 |
-
logger.info(f"Inserted
|
| 829 |
except Exception as e:
|
| 830 |
-
error_msg = f"Error inserting
|
| 831 |
logger.error(error_msg)
|
| 832 |
results["errors"].append(error_msg)
|
| 833 |
|
| 834 |
-
# Insert corresponding
|
| 835 |
-
for kg_data in
|
| 836 |
try:
|
| 837 |
trace_index = kg_data["trace_index"]
|
| 838 |
if trace_index < len(trace_ids):
|
|
@@ -842,42 +526,39 @@ def insert_enhanced_sample_data(session, force_insert=False):
|
|
| 842 |
graph_data=kg_data["graph_data"],
|
| 843 |
trace_id=trace_ids[trace_index],
|
| 844 |
window_index=None, # None for final KG
|
| 845 |
-
window_total=1, # Not None to indicate processed final KG
|
| 846 |
is_original=True
|
| 847 |
)
|
| 848 |
results["knowledge_graphs_inserted"] += 1
|
| 849 |
-
logger.info(f"Inserted
|
| 850 |
except Exception as e:
|
| 851 |
-
error_msg = f"Error inserting
|
| 852 |
logger.error(error_msg)
|
| 853 |
results["errors"].append(error_msg)
|
| 854 |
|
| 855 |
-
logger.info(f"
|
| 856 |
|
| 857 |
except Exception as e:
|
| 858 |
-
error_msg = f"Fatal error during
|
| 859 |
logger.error(error_msg)
|
| 860 |
results["errors"].append(error_msg)
|
| 861 |
raise # Re-raise to trigger rollback in calling code
|
| 862 |
|
| 863 |
return results
|
| 864 |
|
| 865 |
-
|
|
|
|
| 866 |
"""
|
| 867 |
-
|
|
|
|
|
|
|
|
|
|
| 868 |
"""
|
| 869 |
return {
|
| 870 |
-
"
|
| 871 |
-
"
|
| 872 |
-
"trace_types": list(set(
|
| 873 |
-
"
|
| 874 |
-
"
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
"Error handling and failures",
|
| 878 |
-
"Process optimization recommendations",
|
| 879 |
-
"Content reference mapping",
|
| 880 |
-
"System-level summaries",
|
| 881 |
-
"Comprehensive metadata"
|
| 882 |
-
]
|
| 883 |
-
}
|
|
|
|
| 1 |
#!/usr/bin/env python
|
| 2 |
"""
|
| 3 |
+
Sample data for database initialization.
|
| 4 |
+
Provides curated examples of traces and knowledge graphs for new users.
|
| 5 |
"""
|
| 6 |
|
| 7 |
import json
|
| 8 |
import logging
|
| 9 |
+
from typing import Dict, List, Any
|
|
|
|
|
|
|
| 10 |
|
| 11 |
logger = logging.getLogger(__name__)
|
| 12 |
|
| 13 |
+
# Enhanced sample traces showcasing AgentGraph's full capabilities
|
| 14 |
+
SAMPLE_TRACES = [
|
| 15 |
{
|
| 16 |
+
"filename": "oxford_economics_inquiry.json",
|
| 17 |
+
"title": "Oxford Economics AI Assistant Demo",
|
| 18 |
+
"description": "Enhanced example showing AI assistant processing economic inquiry with failure detection and optimization suggestions",
|
| 19 |
+
"trace_type": "aif_inference",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
"trace_source": "sample_data",
|
| 21 |
+
"tags": ["economics", "ai_assistant", "enhanced", "failure_detection", "optimization"],
|
| 22 |
+
"content": """{
|
| 23 |
+
"id": "aif_trace_demo_001",
|
| 24 |
+
"timestamp": "2025-01-27T00:00:00",
|
| 25 |
+
"metadata": {
|
| 26 |
+
"source": "AgentGraph_Demo",
|
| 27 |
+
"row_index": 0,
|
| 28 |
+
"converted_at": "2025-01-27T12:00:00.000000"
|
| 29 |
+
},
|
| 30 |
+
"data": {
|
| 31 |
+
"total_observations": 1,
|
| 32 |
+
"summary": "Oxford Economics inquiry with AI assistant response"
|
| 33 |
+
},
|
| 34 |
+
"observations": [
|
| 35 |
{
|
| 36 |
+
"id": "demo_obs_001",
|
| 37 |
+
"type": "inference",
|
| 38 |
+
"timestamp": "2025-01-27T00:00:00",
|
| 39 |
+
"input": "You are a knowledgeable assistant on Oxford Economics designed to answer questions accurately based on the provided context. Use the information in the documents below to respond concisely and correctly.\\n\\n### Context:\\n['Oxford Economics contact: Mateusz Urban - murban@oxfordeconomics.com', 'Oxford Economics research and analysis services', 'Economic forecasting and consultancy expertise']\\n\\n### Question:\\nwhat does oxford economics present?\\n\\n### Answer:",
|
| 40 |
+
"output": "Oxford Economics provides economic analysis, forecasting, and consultancy services.",
|
| 41 |
+
"metadata": {
|
| 42 |
+
"request_date": "2025-01-27T00:00:00",
|
| 43 |
+
"databricks_request_id": "demo-request-001",
|
| 44 |
+
"request_time": "2025-01-27T12:00:00.000",
|
| 45 |
+
"status_code": 200,
|
| 46 |
+
"sampling_fraction": 1,
|
| 47 |
+
"request_raw": "{\"messages\":[{\"role\":\"system\",\"content\":\"You are a knowledgeable assistant on Oxford Economics\"},{\"role\":\"user\",\"content\":\"You are a knowledgeable assistant on Oxford Economics designed to answer questions accurately based on the provided context. Use the information in the documents below to respond concisely and correctly.\\\\n\\\\n### Context:\\\\n['Oxford Economics contact: Mateusz Urban - murban@oxfordeconomics.com', 'Oxford Economics research and analysis services', 'Economic forecasting and consultancy expertise']\\\\n\\\\n### Question:\\\\nwhat does oxford economics present?\\\\n\\\\n### Answer:\"}]}",
|
| 48 |
+
"response_raw": "{\"choices\":[{\"content_filter_results\":{\"hate\":{\"filtered\":false,\"severity\":\"safe\"},\"self_harm\":{\"filtered\":false,\"severity\":\"safe\"},\"sexual\":{\"filtered\":false,\"severity\":\"safe\"},\"violence\":{\"filtered\":false,\"severity\":\"safe\"}},\"finish_reason\":\"stop\",\"index\":0,\"logprobs\":null,\"message\":{\"content\":\"Oxford Economics provides economic analysis, forecasting, and consultancy services.\",\"refusal\":null,\"role\":\"assistant\"}}],\"created\":1737979200,\"id\":\"chatcmpl-DEMO001\",\"model\":\"gpt-4o-2024-11-20\",\"object\":\"chat.completion\",\"system_fingerprint\":\"fp_demo_001\",\"usage\":{\"completion_tokens\":13,\"completion_tokens_details\":{\"accepted_prediction_tokens\":0,\"audio_tokens\":0,\"reasoning_tokens\":0,\"rejected_prediction_tokens\":0},\"prompt_tokens\":162,\"prompt_tokens_details\":{\"audio_tokens\":0,\"cached_tokens\":0},\"total_tokens\":175}}",
|
| 49 |
+
"served_entity_id": "demo-entity-001",
|
| 50 |
+
"logging_error_codes": "[]",
|
| 51 |
+
"requester": "demo-user-001"
|
| 52 |
+
},
|
| 53 |
+
"latency": 0.531,
|
| 54 |
+
"usage": {
|
| 55 |
+
"completion_tokens": 13,
|
| 56 |
+
"completion_tokens_details": {
|
| 57 |
+
"accepted_prediction_tokens": 0,
|
| 58 |
+
"audio_tokens": 0,
|
| 59 |
+
"reasoning_tokens": 0,
|
| 60 |
+
"rejected_prediction_tokens": 0
|
| 61 |
+
},
|
| 62 |
+
"prompt_tokens": 162,
|
| 63 |
+
"prompt_tokens_details": {
|
| 64 |
+
"audio_tokens": 0,
|
| 65 |
+
"cached_tokens": 0
|
| 66 |
+
},
|
| 67 |
+
"total_tokens": 175
|
| 68 |
+
},
|
| 69 |
+
"model": "gpt-4o-2024-11-20"
|
| 70 |
+
}
|
| 71 |
+
]
|
| 72 |
+
}"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
},
|
| 74 |
{
|
| 75 |
+
"filename": "simple_qa_demonstration.txt",
|
| 76 |
+
"title": "Simple Q&A: Basic Interaction",
|
| 77 |
+
"description": "Streamlined example showing basic agent-human interaction with clear knowledge graph structure",
|
| 78 |
+
"trace_type": "conversation",
|
| 79 |
+
"trace_source": "sample_data",
|
| 80 |
+
"tags": ["simple", "qa", "basic", "demonstration"],
|
| 81 |
+
"content": """User: Hello, can you help me understand what services Oxford Economics provides?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
+
Assistant: Certainly! Oxford Economics is a leading economic consultancy that provides:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
+
1. **Economic Analysis & Forecasting**: Comprehensive economic research and predictive modeling
|
| 86 |
+
2. **Consultancy Services**: Strategic advice for businesses, governments, and institutions
|
| 87 |
+
3. **Industry Analysis**: Sector-specific insights and market intelligence
|
| 88 |
+
4. **Policy Impact Assessment**: Evaluation of economic policies and their implications
|
| 89 |
|
| 90 |
+
They specialize in data-driven insights that help organizations make informed decisions about their economic environment and strategic planning.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
+
Is there a specific aspect of their services you'd like to know more about?"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
}
|
| 94 |
]
|
| 95 |
|
| 96 |
+
# Enhanced knowledge graphs demonstrating AgentGraph's complete feature set
|
| 97 |
+
SAMPLE_KNOWLEDGE_GRAPHS = [
|
| 98 |
{
|
| 99 |
+
"filename": "kg_oxford_economics_enhanced.json",
|
| 100 |
+
"trace_index": 0, # Links to first trace
|
|
|
|
|
|
|
| 101 |
"graph_data": {
|
| 102 |
+
"system_name": "Oxford Economics AI Assistant",
|
| 103 |
+
"system_summary": "This intelligent assistant processes user inquiries about Oxford Economics through a streamlined workflow. When users submit questions, the knowledgeable agent analyzes them using advanced language models and delivers accurate, contextual responses about economic analysis and forecasting services.",
|
| 104 |
"entities": [
|
| 105 |
{
|
| 106 |
"id": "agent_001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
"type": "Agent",
|
| 108 |
+
"name": "Oxford Economics Knowledge Agent",
|
| 109 |
"importance": "HIGH",
|
| 110 |
+
"raw_prompt": "You are a knowledgeable assistant on Oxford Economics designed to answer questions accurately based on the provided context. Use the information in the documents below to respond concisely and correctly.",
|
| 111 |
"raw_prompt_ref": [
|
| 112 |
+
{
|
| 113 |
+
"line_start": 31,
|
| 114 |
+
"line_end": 32
|
| 115 |
+
}
|
| 116 |
]
|
| 117 |
},
|
| 118 |
{
|
| 119 |
+
"id": "task_001",
|
| 120 |
+
"type": "Task",
|
| 121 |
+
"name": "Economic Inquiry Processing",
|
| 122 |
+
"importance": "HIGH",
|
| 123 |
+
"raw_prompt": "Process user inquiry about Oxford Economics and generate an accurate, contextual response based on available information and company expertise.",
|
| 124 |
"raw_prompt_ref": [
|
| 125 |
+
{
|
| 126 |
+
"line_start": 26,
|
| 127 |
+
"line_end": 28
|
| 128 |
+
}
|
| 129 |
]
|
| 130 |
},
|
| 131 |
{
|
| 132 |
+
"id": "input_001",
|
| 133 |
+
"type": "Input",
|
| 134 |
+
"name": "User Economic Query",
|
| 135 |
"importance": "HIGH",
|
| 136 |
+
"raw_prompt": "what does oxford economics present?",
|
| 137 |
"raw_prompt_ref": [
|
| 138 |
+
{
|
| 139 |
+
"line_start": 19,
|
| 140 |
+
"line_end": 19
|
| 141 |
+
}
|
| 142 |
]
|
| 143 |
},
|
| 144 |
{
|
| 145 |
+
"id": "output_001",
|
| 146 |
+
"type": "Output",
|
| 147 |
+
"name": "Economic Services Overview",
|
| 148 |
+
"importance": "HIGH",
|
| 149 |
+
"raw_prompt": "Oxford Economics provides economic analysis, forecasting, and consultancy services.",
|
| 150 |
"raw_prompt_ref": [
|
| 151 |
+
{
|
| 152 |
+
"line_start": 20,
|
| 153 |
+
"line_end": 20
|
| 154 |
+
}
|
| 155 |
]
|
| 156 |
},
|
| 157 |
{
|
| 158 |
+
"id": "human_001",
|
| 159 |
+
"type": "Human",
|
| 160 |
+
"name": "Business User",
|
| 161 |
+
"importance": "MEDIUM",
|
| 162 |
+
"raw_prompt": "Professional seeking economic insights and analysis",
|
| 163 |
"raw_prompt_ref": [
|
| 164 |
+
{
|
| 165 |
+
"line_start": 31,
|
| 166 |
+
"line_end": 31
|
| 167 |
+
}
|
| 168 |
]
|
| 169 |
},
|
| 170 |
{
|
| 171 |
+
"id": "tool_001",
|
| 172 |
+
"type": "Tool",
|
| 173 |
+
"name": "GPT-4o Language Model",
|
| 174 |
"importance": "HIGH",
|
| 175 |
+
"raw_prompt": "Advanced AI language model with economic domain knowledge and structured response capabilities.",
|
| 176 |
"raw_prompt_ref": [
|
| 177 |
+
{
|
| 178 |
+
"line_start": 49,
|
| 179 |
+
"line_end": 49
|
| 180 |
+
}
|
| 181 |
]
|
| 182 |
}
|
| 183 |
],
|
| 184 |
"relations": [
|
| 185 |
{
|
| 186 |
"id": "rel_001",
|
| 187 |
+
"source": "input_001",
|
| 188 |
+
"target": "agent_001",
|
| 189 |
+
"type": "CONSUMED_BY",
|
| 190 |
"importance": "HIGH",
|
| 191 |
+
"interaction_prompt": "User query received and processed by the economic knowledge agent",
|
| 192 |
"interaction_prompt_ref": [
|
| 193 |
+
{
|
| 194 |
+
"line_start": 19,
|
| 195 |
+
"line_end": 19
|
| 196 |
+
}
|
| 197 |
]
|
| 198 |
},
|
| 199 |
{
|
| 200 |
"id": "rel_002",
|
| 201 |
"source": "agent_001",
|
| 202 |
+
"target": "task_001",
|
| 203 |
+
"type": "PERFORMS",
|
| 204 |
"importance": "HIGH",
|
| 205 |
+
"interaction_prompt": "Agent executes economic inquiry processing task",
|
| 206 |
"interaction_prompt_ref": [
|
| 207 |
+
{
|
| 208 |
+
"line_start": 26,
|
| 209 |
+
"line_end": 28
|
| 210 |
+
}
|
| 211 |
]
|
| 212 |
},
|
| 213 |
{
|
| 214 |
"id": "rel_003",
|
| 215 |
+
"source": "task_001",
|
| 216 |
+
"target": "output_001",
|
| 217 |
+
"type": "PRODUCES",
|
| 218 |
"importance": "HIGH",
|
| 219 |
+
"interaction_prompt": "Processing task generates comprehensive economic services response",
|
| 220 |
"interaction_prompt_ref": [
|
| 221 |
+
{
|
| 222 |
+
"line_start": 20,
|
| 223 |
+
"line_end": 20
|
| 224 |
+
}
|
| 225 |
]
|
| 226 |
},
|
| 227 |
{
|
| 228 |
"id": "rel_004",
|
| 229 |
+
"source": "output_001",
|
| 230 |
+
"target": "human_001",
|
| 231 |
+
"type": "DELIVERS_TO",
|
| 232 |
+
"importance": "HIGH",
|
| 233 |
+
"interaction_prompt": "Economic analysis delivered to requesting business user",
|
| 234 |
"interaction_prompt_ref": [
|
| 235 |
+
{
|
| 236 |
+
"line_start": 20,
|
| 237 |
+
"line_end": 20
|
| 238 |
+
}
|
| 239 |
]
|
| 240 |
},
|
| 241 |
{
|
| 242 |
"id": "rel_005",
|
| 243 |
+
"source": "agent_001",
|
| 244 |
+
"target": "tool_001",
|
| 245 |
+
"type": "USES",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
"importance": "HIGH",
|
| 247 |
+
"interaction_prompt": "Agent leverages language model for natural language understanding and generation",
|
| 248 |
"interaction_prompt_ref": [
|
| 249 |
+
{
|
| 250 |
+
"line_start": 49,
|
| 251 |
+
"line_end": 49
|
| 252 |
+
}
|
| 253 |
]
|
| 254 |
}
|
| 255 |
],
|
| 256 |
"failures": [
|
| 257 |
{
|
| 258 |
"id": "failure_001",
|
| 259 |
+
"risk_type": "HALLUCINATION",
|
| 260 |
+
"description": "Minor spelling inconsistency in user query may affect search precision.",
|
| 261 |
+
"raw_text": "what does oxford economics present?",
|
| 262 |
"raw_text_ref": [
|
| 263 |
+
{
|
| 264 |
+
"line_start": 19,
|
| 265 |
+
"line_end": 19
|
| 266 |
+
}
|
| 267 |
],
|
| 268 |
"affected_id": "input_001"
|
| 269 |
}
|
|
|
|
| 271 |
"optimizations": [
|
| 272 |
{
|
| 273 |
"id": "opt_001",
|
| 274 |
+
"recommendation_type": "PROMPT_REFINEMENT",
|
| 275 |
+
"description": "Enhance the agent prompt to include spell-checking and query normalization capabilities for improved accuracy and user experience.",
|
| 276 |
+
"affected_ids": ["agent_001"],
|
| 277 |
+
"raw_text_ref": [
|
| 278 |
+
{
|
| 279 |
+
"line_start": 31,
|
| 280 |
+
"line_end": 32
|
| 281 |
+
}
|
| 282 |
+
]
|
| 283 |
+
},
|
| 284 |
+
{
|
| 285 |
+
"id": "opt_002",
|
| 286 |
+
"recommendation_type": "TOOL_ENHANCEMENT",
|
| 287 |
+
"description": "Integrate Oxford Economics knowledge base with the language model to provide more specific and detailed responses about services and capabilities.",
|
| 288 |
+
"affected_ids": ["tool_001"],
|
| 289 |
"raw_text_ref": [
|
| 290 |
+
{
|
| 291 |
+
"line_start": 49,
|
| 292 |
+
"line_end": 49
|
| 293 |
+
}
|
| 294 |
]
|
| 295 |
}
|
| 296 |
],
|
|
|
|
|
|
|
| 297 |
"metadata": {
|
| 298 |
+
"creation_timestamp": "2025-01-27T12:00:00Z",
|
| 299 |
+
"schema_version": "2.1.0",
|
| 300 |
+
"quality_score": 0.89,
|
| 301 |
+
"entity_count": 6,
|
| 302 |
+
"relation_count": 5,
|
| 303 |
+
"failure_count": 1,
|
| 304 |
+
"optimization_count": 2,
|
| 305 |
+
"processing_method": "production_enhanced",
|
| 306 |
+
"content_source": "aif_inference_trace",
|
| 307 |
+
"language": "en",
|
| 308 |
+
"domain": "economics_consulting"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 309 |
}
|
| 310 |
}
|
| 311 |
},
|
|
|
|
|
|
|
| 312 |
{
|
| 313 |
+
"filename": "kg_simple_qa_demo.json",
|
| 314 |
+
"trace_index": 1, # Links to second trace
|
|
|
|
|
|
|
| 315 |
"graph_data": {
|
| 316 |
+
"system_name": "Oxford Economics Q&A Assistant",
|
| 317 |
+
"system_summary": "A streamlined question-answering system designed to provide clear information about Oxford Economics services. The system processes user questions and delivers comprehensive responses about economic analysis and consulting capabilities.",
|
| 318 |
"entities": [
|
| 319 |
{
|
| 320 |
+
"id": "user_001",
|
| 321 |
+
"type": "Human",
|
| 322 |
+
"name": "User",
|
| 323 |
"importance": "HIGH",
|
| 324 |
+
"raw_prompt": "Hello, can you help me understand what services Oxford Economics provides?",
|
| 325 |
"raw_prompt_ref": [
|
| 326 |
+
{
|
| 327 |
+
"line_start": 1,
|
| 328 |
+
"line_end": 1
|
| 329 |
+
}
|
| 330 |
]
|
| 331 |
},
|
| 332 |
{
|
| 333 |
+
"id": "assistant_001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 334 |
"type": "Agent",
|
| 335 |
+
"name": "Q&A Assistant",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
"importance": "HIGH",
|
| 337 |
+
"raw_prompt": "Helpful assistant specialized in providing information about Oxford Economics services and capabilities.",
|
| 338 |
"raw_prompt_ref": [
|
| 339 |
+
{
|
| 340 |
+
"line_start": 3,
|
| 341 |
+
"line_end": 3
|
| 342 |
+
}
|
| 343 |
]
|
| 344 |
},
|
| 345 |
{
|
| 346 |
+
"id": "inquiry_task",
|
| 347 |
+
"type": "Task",
|
| 348 |
+
"name": "Service Information Request",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 349 |
"importance": "HIGH",
|
| 350 |
+
"raw_prompt": "Process user inquiry about Oxford Economics services and provide comprehensive response.",
|
| 351 |
"raw_prompt_ref": [
|
| 352 |
+
{
|
| 353 |
+
"line_start": 1,
|
| 354 |
+
"line_end": 1
|
| 355 |
+
}
|
| 356 |
]
|
| 357 |
},
|
| 358 |
{
|
| 359 |
+
"id": "response_output",
|
| 360 |
+
"type": "Output",
|
| 361 |
+
"name": "Service Overview Response",
|
| 362 |
"importance": "HIGH",
|
| 363 |
+
"raw_prompt": "Certainly! Oxford Economics is a leading economic consultancy that provides: 1. Economic Analysis & Forecasting 2. Consultancy Services 3. Industry Analysis 4. Policy Impact Assessment",
|
| 364 |
"raw_prompt_ref": [
|
| 365 |
+
{
|
| 366 |
+
"line_start": 3,
|
| 367 |
+
"line_end": 10
|
| 368 |
+
}
|
| 369 |
]
|
| 370 |
}
|
| 371 |
],
|
| 372 |
"relations": [
|
| 373 |
{
|
| 374 |
+
"id": "user_inquiry",
|
| 375 |
+
"source": "user_001",
|
| 376 |
+
"target": "assistant_001",
|
| 377 |
+
"type": "CONSUMED_BY",
|
| 378 |
"importance": "HIGH",
|
| 379 |
+
"interaction_prompt": "User asks about Oxford Economics services",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
"interaction_prompt_ref": [
|
| 381 |
+
{
|
| 382 |
+
"line_start": 1,
|
| 383 |
+
"line_end": 1
|
| 384 |
+
}
|
| 385 |
]
|
| 386 |
},
|
| 387 |
{
|
| 388 |
+
"id": "assistant_processes",
|
| 389 |
+
"source": "assistant_001",
|
| 390 |
+
"target": "inquiry_task",
|
| 391 |
+
"type": "PERFORMS",
|
| 392 |
"importance": "HIGH",
|
| 393 |
+
"interaction_prompt": "Assistant processes the service information request",
|
| 394 |
"interaction_prompt_ref": [
|
| 395 |
+
{
|
| 396 |
+
"line_start": 3,
|
| 397 |
+
"line_end": 3
|
| 398 |
+
}
|
| 399 |
]
|
| 400 |
},
|
| 401 |
{
|
| 402 |
+
"id": "task_generates",
|
| 403 |
+
"source": "inquiry_task",
|
| 404 |
+
"target": "response_output",
|
| 405 |
+
"type": "PRODUCES",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 406 |
"importance": "HIGH",
|
| 407 |
+
"interaction_prompt": "Task generates comprehensive service overview",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 408 |
"interaction_prompt_ref": [
|
| 409 |
+
{
|
| 410 |
+
"line_start": 3,
|
| 411 |
+
"line_end": 10
|
| 412 |
+
}
|
| 413 |
]
|
| 414 |
},
|
| 415 |
{
|
| 416 |
+
"id": "response_delivered",
|
| 417 |
+
"source": "response_output",
|
| 418 |
+
"target": "user_001",
|
| 419 |
+
"type": "DELIVERS_TO",
|
| 420 |
"importance": "HIGH",
|
| 421 |
+
"interaction_prompt": "Comprehensive service information delivered to user",
|
| 422 |
"interaction_prompt_ref": [
|
| 423 |
+
{
|
| 424 |
+
"line_start": 3,
|
| 425 |
+
"line_end": 10
|
| 426 |
+
}
|
| 427 |
]
|
| 428 |
}
|
| 429 |
],
|
| 430 |
"failures": [],
|
| 431 |
"optimizations": [
|
| 432 |
{
|
| 433 |
+
"id": "opt_simple_001",
|
| 434 |
+
"recommendation_type": "PROMPT_REFINEMENT",
|
| 435 |
+
"description": "Consider adding interactive follow-up capabilities to allow users to ask for more specific information about any of the mentioned service areas.",
|
| 436 |
+
"affected_ids": ["assistant_001"],
|
| 437 |
"raw_text_ref": [
|
| 438 |
+
{
|
| 439 |
+
"line_start": 12,
|
| 440 |
+
"line_end": 12
|
| 441 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 442 |
]
|
| 443 |
}
|
| 444 |
],
|
|
|
|
|
|
|
| 445 |
"metadata": {
|
| 446 |
+
"creation_timestamp": "2025-01-27T12:00:00Z",
|
| 447 |
+
"schema_version": "2.1.0",
|
| 448 |
+
"quality_score": 0.92,
|
| 449 |
+
"entity_count": 4,
|
| 450 |
+
"relation_count": 4,
|
| 451 |
+
"failure_count": 0,
|
| 452 |
+
"optimization_count": 1,
|
| 453 |
+
"processing_method": "simplified_demonstration",
|
| 454 |
+
"content_source": "conversation_trace",
|
| 455 |
+
"language": "en",
|
| 456 |
+
"domain": "economics_consulting"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 457 |
}
|
| 458 |
}
|
| 459 |
}
|
| 460 |
]
|
| 461 |
|
| 462 |
+
|
| 463 |
+
def insert_sample_data(session, force_insert=False):
|
| 464 |
"""
|
| 465 |
+
Insert sample traces and knowledge graphs into the database.
|
| 466 |
+
|
| 467 |
+
Args:
|
| 468 |
+
session: Database session
|
| 469 |
+
force_insert: If True, insert even if data already exists
|
| 470 |
+
|
| 471 |
+
Returns:
|
| 472 |
+
Dict with insertion results
|
| 473 |
"""
|
| 474 |
+
from backend.database.utils import save_trace, save_knowledge_graph
|
| 475 |
+
from backend.database.models import Trace, KnowledgeGraph
|
| 476 |
+
|
| 477 |
results = {
|
| 478 |
"traces_inserted": 0,
|
| 479 |
"knowledge_graphs_inserted": 0,
|
|
|
|
| 486 |
existing_sample = session.query(Trace).filter(
|
| 487 |
Trace.trace_source == "sample_data"
|
| 488 |
).first()
|
| 489 |
+
|
| 490 |
if existing_sample:
|
| 491 |
+
logger.info("Sample data already exists, skipping insertion")
|
| 492 |
+
results["skipped"] = len(SAMPLE_TRACES)
|
| 493 |
return results
|
| 494 |
|
| 495 |
try:
|
| 496 |
+
# Insert sample traces
|
| 497 |
trace_ids = []
|
| 498 |
+
for i, trace_data in enumerate(SAMPLE_TRACES):
|
| 499 |
try:
|
| 500 |
trace = save_trace(
|
| 501 |
session=session,
|
| 502 |
content=trace_data["content"],
|
| 503 |
filename=trace_data["filename"],
|
| 504 |
+
title=trace_data["title"],
|
| 505 |
description=trace_data["description"],
|
| 506 |
trace_type=trace_data["trace_type"],
|
| 507 |
trace_source=trace_data["trace_source"],
|
|
|
|
| 509 |
)
|
| 510 |
trace_ids.append(trace.trace_id)
|
| 511 |
results["traces_inserted"] += 1
|
| 512 |
+
logger.info(f"Inserted sample trace: {trace_data['title']}")
|
| 513 |
except Exception as e:
|
| 514 |
+
error_msg = f"Error inserting trace {i}: {str(e)}"
|
| 515 |
logger.error(error_msg)
|
| 516 |
results["errors"].append(error_msg)
|
| 517 |
|
| 518 |
+
# Insert corresponding knowledge graphs
|
| 519 |
+
for kg_data in SAMPLE_KNOWLEDGE_GRAPHS:
|
| 520 |
try:
|
| 521 |
trace_index = kg_data["trace_index"]
|
| 522 |
if trace_index < len(trace_ids):
|
|
|
|
| 526 |
graph_data=kg_data["graph_data"],
|
| 527 |
trace_id=trace_ids[trace_index],
|
| 528 |
window_index=None, # None for final KG
|
| 529 |
+
window_total=1, # Not None to indicate it's a processed final KG
|
| 530 |
is_original=True
|
| 531 |
)
|
| 532 |
results["knowledge_graphs_inserted"] += 1
|
| 533 |
+
logger.info(f"Inserted sample knowledge graph: {kg_data['filename']}")
|
| 534 |
except Exception as e:
|
| 535 |
+
error_msg = f"Error inserting knowledge graph {kg_data['filename']}: {str(e)}"
|
| 536 |
logger.error(error_msg)
|
| 537 |
results["errors"].append(error_msg)
|
| 538 |
|
| 539 |
+
logger.info(f"Sample data insertion completed: {results}")
|
| 540 |
|
| 541 |
except Exception as e:
|
| 542 |
+
error_msg = f"Fatal error during sample data insertion: {str(e)}"
|
| 543 |
logger.error(error_msg)
|
| 544 |
results["errors"].append(error_msg)
|
| 545 |
raise # Re-raise to trigger rollback in calling code
|
| 546 |
|
| 547 |
return results
|
| 548 |
|
| 549 |
+
|
| 550 |
+
def get_sample_data_info():
|
| 551 |
"""
|
| 552 |
+
Get information about the available sample data.
|
| 553 |
+
|
| 554 |
+
Returns:
|
| 555 |
+
Dict with sample data statistics
|
| 556 |
"""
|
| 557 |
return {
|
| 558 |
+
"traces_count": len(SAMPLE_TRACES),
|
| 559 |
+
"knowledge_graphs_count": len(SAMPLE_KNOWLEDGE_GRAPHS),
|
| 560 |
+
"trace_types": list(set(t["trace_type"] for t in SAMPLE_TRACES)),
|
| 561 |
+
"complexity_levels": ["enhanced", "simple"],
|
| 562 |
+
"features": ["failure_detection", "optimization_recommendations", "content_references", "quality_scoring"],
|
| 563 |
+
"description": "Enhanced AgentGraph examples showcasing Oxford Economics AI assistant with complete failure detection, optimization suggestions, and advanced knowledge graph features"
|
| 564 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1,623 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python
|
| 2 |
-
"""
|
| 3 |
-
Sample data for database initialization.
|
| 4 |
-
Provides curated examples of traces and knowledge graphs for new users.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
import json
|
| 8 |
-
import logging
|
| 9 |
-
from typing import Dict, List, Any
|
| 10 |
-
|
| 11 |
-
logger = logging.getLogger(__name__)
|
| 12 |
-
|
| 13 |
-
# Sample traces with increasing complexity
|
| 14 |
-
SAMPLE_TRACES = [
|
| 15 |
-
{
|
| 16 |
-
"filename": "sample_basic_question.txt",
|
| 17 |
-
"title": "Basic Q&A: California Great America Season Pass",
|
| 18 |
-
"description": "Simple arithmetic calculation comparing season pass vs daily tickets",
|
| 19 |
-
"trace_type": "conversation",
|
| 20 |
-
"trace_source": "sample_data",
|
| 21 |
-
"tags": ["arithmetic", "simple", "calculation"],
|
| 22 |
-
"content": """User: How much did I save by purchasing a season pass instead of daily tickets for California's Great America in San Jose, if I planned to visit once a month in June, July, August, and September during the summer of 2024?
|
| 23 |
-
|
| 24 |
-
Assistant: I'd be happy to help you calculate your savings! To give you an accurate answer, I need to find the current ticket prices for California's Great America.
|
| 25 |
-
|
| 26 |
-
Let me break this down:
|
| 27 |
-
- You planned to visit once a month for 4 months (June, July, August, September)
|
| 28 |
-
- So you need 4 daily tickets total
|
| 29 |
-
|
| 30 |
-
Based on 2024 pricing:
|
| 31 |
-
- Daily ticket: approximately $60
|
| 32 |
-
- Season pass: approximately $120
|
| 33 |
-
|
| 34 |
-
Calculation:
|
| 35 |
-
- Cost of 4 daily tickets: 4 × $60 = $240
|
| 36 |
-
- Cost of season pass: $120
|
| 37 |
-
- Your savings: $240 - $120 = $120
|
| 38 |
-
|
| 39 |
-
You saved $120 by purchasing the season pass instead of individual daily tickets!
|
| 40 |
-
|
| 41 |
-
The season pass was definitely the smart choice for 4+ visits."""
|
| 42 |
-
},
|
| 43 |
-
{
|
| 44 |
-
"filename": "sample_research_question.txt",
|
| 45 |
-
"title": "Research Task: Restaurant Near State Park",
|
| 46 |
-
"description": "Multi-step research involving location search and business hours verification",
|
| 47 |
-
"trace_type": "research",
|
| 48 |
-
"trace_source": "sample_data",
|
| 49 |
-
"tags": ["research", "location", "business_hours"],
|
| 50 |
-
"content": """User: What is the closest eatery to Harkness Memorial State Park that is still open at 11pm on Wednesdays?
|
| 51 |
-
|
| 52 |
-
Assistant: I'll help you find the closest eatery to Harkness Memorial State Park in Waterford, Connecticut that stays open until 11pm on Wednesdays.
|
| 53 |
-
|
| 54 |
-
Let me research this step by step:
|
| 55 |
-
|
| 56 |
-
1. **Location**: Harkness Memorial State Park is located at 275 Great Neck Rd, Waterford, CT 06385
|
| 57 |
-
|
| 58 |
-
2. **Nearby eateries**: Searching for restaurants within a reasonable distance...
|
| 59 |
-
|
| 60 |
-
3. **Wednesday hours verification**: Checking which places stay open until 11pm on Wednesdays...
|
| 61 |
-
|
| 62 |
-
After researching local eateries and their hours:
|
| 63 |
-
|
| 64 |
-
**Answer: McDonald's** (located at 1465 Hartford Turnpike, Waterford, CT)
|
| 65 |
-
- Distance: Approximately 3.2 miles from Harkness Memorial State Park
|
| 66 |
-
- Wednesday hours: Open 24 hours
|
| 67 |
-
- This is the closest eatery that meets your 11pm requirement
|
| 68 |
-
|
| 69 |
-
Most local restaurants in the Waterford area close by 9pm on weekdays, making McDonald's the most reliable option for late dining near the park."""
|
| 70 |
-
},
|
| 71 |
-
{
|
| 72 |
-
"filename": "sample_complex_task.txt",
|
| 73 |
-
"title": "Complex Analysis: Multi-Agent Collaboration",
|
| 74 |
-
"description": "Advanced task showing multi-agent collaboration with tool usage and reasoning",
|
| 75 |
-
"trace_type": "multi_agent",
|
| 76 |
-
"trace_source": "sample_data",
|
| 77 |
-
"tags": ["complex", "multi_agent", "collaboration", "tools"],
|
| 78 |
-
"content": """User: Analyze the efficiency of different sorting algorithms for a dataset of 10,000 random integers.
|
| 79 |
-
|
| 80 |
-
Planning Agent: I'll break this task into components:
|
| 81 |
-
1. Generate test data (10,000 random integers)
|
| 82 |
-
2. Implement multiple sorting algorithms
|
| 83 |
-
3. Measure performance metrics
|
| 84 |
-
4. Compare and analyze results
|
| 85 |
-
|
| 86 |
-
Code Agent: ```python
|
| 87 |
-
import random
|
| 88 |
-
import time
|
| 89 |
-
import sys
|
| 90 |
-
|
| 91 |
-
# Generate test data
|
| 92 |
-
test_data = [random.randint(1, 100000) for _ in range(10000)]
|
| 93 |
-
|
| 94 |
-
# Bubble Sort
|
| 95 |
-
def bubble_sort(arr):
|
| 96 |
-
n = len(arr)
|
| 97 |
-
for i in range(n):
|
| 98 |
-
for j in range(0, n-i-1):
|
| 99 |
-
if arr[j] > arr[j+1]:
|
| 100 |
-
arr[j], arr[j+1] = arr[j+1], arr[j]
|
| 101 |
-
return arr
|
| 102 |
-
|
| 103 |
-
# Quick Sort
|
| 104 |
-
def quick_sort(arr):
|
| 105 |
-
if len(arr) <= 1:
|
| 106 |
-
return arr
|
| 107 |
-
pivot = arr[len(arr) // 2]
|
| 108 |
-
left = [x for x in arr if x < pivot]
|
| 109 |
-
middle = [x for x in arr if x == pivot]
|
| 110 |
-
right = [x for x in arr if x > pivot]
|
| 111 |
-
return quick_sort(left) + middle + quick_sort(right)
|
| 112 |
-
|
| 113 |
-
# Merge Sort
|
| 114 |
-
def merge_sort(arr):
|
| 115 |
-
if len(arr) <= 1:
|
| 116 |
-
return arr
|
| 117 |
-
mid = len(arr) // 2
|
| 118 |
-
left = merge_sort(arr[:mid])
|
| 119 |
-
right = merge_sort(arr[mid:])
|
| 120 |
-
return merge(left, right)
|
| 121 |
-
|
| 122 |
-
def merge(left, right):
|
| 123 |
-
result = []
|
| 124 |
-
i = j = 0
|
| 125 |
-
while i < len(left) and j < len(right):
|
| 126 |
-
if left[i] <= right[j]:
|
| 127 |
-
result.append(left[i])
|
| 128 |
-
i += 1
|
| 129 |
-
else:
|
| 130 |
-
result.append(right[j])
|
| 131 |
-
j += 1
|
| 132 |
-
result.extend(left[i:])
|
| 133 |
-
result.extend(right[j:])
|
| 134 |
-
return result
|
| 135 |
-
```
|
| 136 |
-
|
| 137 |
-
Testing Agent: Running performance tests...
|
| 138 |
-
|
| 139 |
-
Results:
|
| 140 |
-
- **Python Built-in Sort**: 0.003 seconds
|
| 141 |
-
- **Merge Sort**: 0.045 seconds
|
| 142 |
-
- **Quick Sort**: 0.032 seconds
|
| 143 |
-
- **Bubble Sort**: 12.456 seconds (extremely slow for 10k elements)
|
| 144 |
-
|
| 145 |
-
Analysis Agent: **Performance Analysis:**
|
| 146 |
-
|
| 147 |
-
1. **Winner: Python's built-in sort** (Timsort)
|
| 148 |
-
- Highly optimized hybrid algorithm
|
| 149 |
-
- Best for real-world usage
|
| 150 |
-
|
| 151 |
-
2. **Quick Sort**: Good general-purpose algorithm
|
| 152 |
-
- Average O(n log n), worst-case O(n²)
|
| 153 |
-
- Fast for random data
|
| 154 |
-
|
| 155 |
-
3. **Merge Sort**: Consistent performance
|
| 156 |
-
- Always O(n log n)
|
| 157 |
-
- Stable sort, good for linked lists
|
| 158 |
-
|
| 159 |
-
4. **Bubble Sort**: Educational only
|
| 160 |
-
- O(n²) complexity makes it impractical
|
| 161 |
-
- 4000x slower than optimized algorithms
|
| 162 |
-
|
| 163 |
-
**Recommendation**: Use Python's built-in `sorted()` or `.sort()` for production code, as it's specifically optimized for real-world data patterns."""
|
| 164 |
-
}
|
| 165 |
-
]
|
| 166 |
-
|
| 167 |
-
# Sample knowledge graphs corresponding to the traces
|
| 168 |
-
SAMPLE_KNOWLEDGE_GRAPHS = [
|
| 169 |
-
{
|
| 170 |
-
"filename": "kg_basic_question_001.json",
|
| 171 |
-
"trace_index": 0, # Links to first trace
|
| 172 |
-
"graph_data": {
|
| 173 |
-
"entities": [
|
| 174 |
-
{
|
| 175 |
-
"id": "user",
|
| 176 |
-
"type": "agent",
|
| 177 |
-
"name": "User",
|
| 178 |
-
"properties": {"role": "question_asker"}
|
| 179 |
-
},
|
| 180 |
-
{
|
| 181 |
-
"id": "assistant",
|
| 182 |
-
"type": "agent",
|
| 183 |
-
"name": "Assistant",
|
| 184 |
-
"properties": {"role": "problem_solver"}
|
| 185 |
-
},
|
| 186 |
-
{
|
| 187 |
-
"id": "california_great_america",
|
| 188 |
-
"type": "location",
|
| 189 |
-
"name": "California's Great America",
|
| 190 |
-
"properties": {"city": "San Jose", "type": "amusement_park"}
|
| 191 |
-
},
|
| 192 |
-
{
|
| 193 |
-
"id": "season_pass",
|
| 194 |
-
"type": "product",
|
| 195 |
-
"name": "Season Pass",
|
| 196 |
-
"properties": {"price": "$120", "validity": "full_season"}
|
| 197 |
-
},
|
| 198 |
-
{
|
| 199 |
-
"id": "daily_ticket",
|
| 200 |
-
"type": "product",
|
| 201 |
-
"name": "Daily Ticket",
|
| 202 |
-
"properties": {"price": "$60", "validity": "single_day"}
|
| 203 |
-
},
|
| 204 |
-
{
|
| 205 |
-
"id": "calculation_task",
|
| 206 |
-
"type": "task",
|
| 207 |
-
"name": "Price Comparison Calculation",
|
| 208 |
-
"properties": {"type": "arithmetic", "complexity": "simple"}
|
| 209 |
-
}
|
| 210 |
-
],
|
| 211 |
-
"relations": [
|
| 212 |
-
{
|
| 213 |
-
"id": "asks_question",
|
| 214 |
-
"source": "user",
|
| 215 |
-
"target": "assistant",
|
| 216 |
-
"type": "asks",
|
| 217 |
-
"properties": {"question_type": "calculation"}
|
| 218 |
-
},
|
| 219 |
-
{
|
| 220 |
-
"id": "performs_calculation",
|
| 221 |
-
"source": "assistant",
|
| 222 |
-
"target": "calculation_task",
|
| 223 |
-
"type": "executes",
|
| 224 |
-
"properties": {"method": "arithmetic"}
|
| 225 |
-
},
|
| 226 |
-
{
|
| 227 |
-
"id": "compares_products",
|
| 228 |
-
"source": "calculation_task",
|
| 229 |
-
"target": "season_pass",
|
| 230 |
-
"type": "compares",
|
| 231 |
-
"properties": {"comparison_type": "cost_benefit"}
|
| 232 |
-
},
|
| 233 |
-
{
|
| 234 |
-
"id": "compares_products_alt",
|
| 235 |
-
"source": "calculation_task",
|
| 236 |
-
"target": "daily_ticket",
|
| 237 |
-
"type": "compares",
|
| 238 |
-
"properties": {"comparison_type": "cost_benefit"}
|
| 239 |
-
},
|
| 240 |
-
{
|
| 241 |
-
"id": "relates_to_location",
|
| 242 |
-
"source": "season_pass",
|
| 243 |
-
"target": "california_great_america",
|
| 244 |
-
"type": "valid_at",
|
| 245 |
-
"properties": {"access_type": "unlimited"}
|
| 246 |
-
}
|
| 247 |
-
]
|
| 248 |
-
}
|
| 249 |
-
},
|
| 250 |
-
{
|
| 251 |
-
"filename": "kg_research_question_001.json",
|
| 252 |
-
"trace_index": 1, # Links to second trace
|
| 253 |
-
"graph_data": {
|
| 254 |
-
"entities": [
|
| 255 |
-
{
|
| 256 |
-
"id": "user",
|
| 257 |
-
"type": "agent",
|
| 258 |
-
"name": "User",
|
| 259 |
-
"properties": {"role": "information_seeker"}
|
| 260 |
-
},
|
| 261 |
-
{
|
| 262 |
-
"id": "assistant",
|
| 263 |
-
"type": "agent",
|
| 264 |
-
"name": "Assistant",
|
| 265 |
-
"properties": {"role": "researcher"}
|
| 266 |
-
},
|
| 267 |
-
{
|
| 268 |
-
"id": "harkness_park",
|
| 269 |
-
"type": "location",
|
| 270 |
-
"name": "Harkness Memorial State Park",
|
| 271 |
-
"properties": {"address": "275 Great Neck Rd, Waterford, CT 06385", "type": "state_park"}
|
| 272 |
-
},
|
| 273 |
-
{
|
| 274 |
-
"id": "mcdonalds",
|
| 275 |
-
"type": "business",
|
| 276 |
-
"name": "McDonald's",
|
| 277 |
-
"properties": {"address": "1465 Hartford Turnpike, Waterford, CT", "hours": "24/7", "type": "restaurant"}
|
| 278 |
-
},
|
| 279 |
-
{
|
| 280 |
-
"id": "research_task",
|
| 281 |
-
"type": "task",
|
| 282 |
-
"name": "Location and Hours Research",
|
| 283 |
-
"properties": {"type": "multi_step_research", "complexity": "medium"}
|
| 284 |
-
},
|
| 285 |
-
{
|
| 286 |
-
"id": "time_constraint",
|
| 287 |
-
"type": "constraint",
|
| 288 |
-
"name": "11pm Wednesday Hours",
|
| 289 |
-
"properties": {"day": "Wednesday", "time": "11:00 PM"}
|
| 290 |
-
}
|
| 291 |
-
],
|
| 292 |
-
"relations": [
|
| 293 |
-
{
|
| 294 |
-
"id": "requests_research",
|
| 295 |
-
"source": "user",
|
| 296 |
-
"target": "assistant",
|
| 297 |
-
"type": "requests",
|
| 298 |
-
"properties": {"request_type": "location_research"}
|
| 299 |
-
},
|
| 300 |
-
{
|
| 301 |
-
"id": "conducts_research",
|
| 302 |
-
"source": "assistant",
|
| 303 |
-
"target": "research_task",
|
| 304 |
-
"type": "executes",
|
| 305 |
-
"properties": {"method": "systematic_search"}
|
| 306 |
-
},
|
| 307 |
-
{
|
| 308 |
-
"id": "research_focuses_on",
|
| 309 |
-
"source": "research_task",
|
| 310 |
-
"target": "harkness_park",
|
| 311 |
-
"type": "focuses_on",
|
| 312 |
-
"properties": {"search_radius": "nearby_area"}
|
| 313 |
-
},
|
| 314 |
-
{
|
| 315 |
-
"id": "applies_constraint",
|
| 316 |
-
"source": "research_task",
|
| 317 |
-
"target": "time_constraint",
|
| 318 |
-
"type": "applies",
|
| 319 |
-
"properties": {"filter_type": "business_hours"}
|
| 320 |
-
},
|
| 321 |
-
{
|
| 322 |
-
"id": "identifies_result",
|
| 323 |
-
"source": "research_task",
|
| 324 |
-
"target": "mcdonalds",
|
| 325 |
-
"type": "identifies",
|
| 326 |
-
"properties": {"match_type": "best_option"}
|
| 327 |
-
},
|
| 328 |
-
{
|
| 329 |
-
"id": "is_near",
|
| 330 |
-
"source": "mcdonalds",
|
| 331 |
-
"target": "harkness_park",
|
| 332 |
-
"type": "located_near",
|
| 333 |
-
"properties": {"distance": "3.2 miles"}
|
| 334 |
-
}
|
| 335 |
-
]
|
| 336 |
-
}
|
| 337 |
-
},
|
| 338 |
-
{
|
| 339 |
-
"filename": "kg_complex_task_001.json",
|
| 340 |
-
"trace_index": 2, # Links to third trace
|
| 341 |
-
"graph_data": {
|
| 342 |
-
"entities": [
|
| 343 |
-
{
|
| 344 |
-
"id": "user",
|
| 345 |
-
"type": "agent",
|
| 346 |
-
"name": "User",
|
| 347 |
-
"properties": {"role": "task_requester"}
|
| 348 |
-
},
|
| 349 |
-
{
|
| 350 |
-
"id": "planning_agent",
|
| 351 |
-
"type": "agent",
|
| 352 |
-
"name": "Planning Agent",
|
| 353 |
-
"properties": {"role": "task_decomposer", "specialization": "planning"}
|
| 354 |
-
},
|
| 355 |
-
{
|
| 356 |
-
"id": "code_agent",
|
| 357 |
-
"type": "agent",
|
| 358 |
-
"name": "Code Agent",
|
| 359 |
-
"properties": {"role": "implementer", "specialization": "programming"}
|
| 360 |
-
},
|
| 361 |
-
{
|
| 362 |
-
"id": "testing_agent",
|
| 363 |
-
"type": "agent",
|
| 364 |
-
"name": "Testing Agent",
|
| 365 |
-
"properties": {"role": "evaluator", "specialization": "performance_testing"}
|
| 366 |
-
},
|
| 367 |
-
{
|
| 368 |
-
"id": "analysis_agent",
|
| 369 |
-
"type": "agent",
|
| 370 |
-
"name": "Analysis Agent",
|
| 371 |
-
"properties": {"role": "analyzer", "specialization": "result_interpretation"}
|
| 372 |
-
},
|
| 373 |
-
{
|
| 374 |
-
"id": "sorting_analysis_task",
|
| 375 |
-
"type": "task",
|
| 376 |
-
"name": "Sorting Algorithm Analysis",
|
| 377 |
-
"properties": {"type": "algorithm_comparison", "complexity": "high", "dataset_size": "10000"}
|
| 378 |
-
},
|
| 379 |
-
{
|
| 380 |
-
"id": "bubble_sort",
|
| 381 |
-
"type": "algorithm",
|
| 382 |
-
"name": "Bubble Sort",
|
| 383 |
-
"properties": {"complexity": "O(n²)", "performance": "12.456s", "category": "comparison_sort"}
|
| 384 |
-
},
|
| 385 |
-
{
|
| 386 |
-
"id": "quick_sort",
|
| 387 |
-
"type": "algorithm",
|
| 388 |
-
"name": "Quick Sort",
|
| 389 |
-
"properties": {"complexity": "O(n log n)", "performance": "0.032s", "category": "divide_conquer"}
|
| 390 |
-
},
|
| 391 |
-
{
|
| 392 |
-
"id": "merge_sort",
|
| 393 |
-
"type": "algorithm",
|
| 394 |
-
"name": "Merge Sort",
|
| 395 |
-
"properties": {"complexity": "O(n log n)", "performance": "0.045s", "category": "divide_conquer"}
|
| 396 |
-
},
|
| 397 |
-
{
|
| 398 |
-
"id": "python_sort",
|
| 399 |
-
"type": "algorithm",
|
| 400 |
-
"name": "Python Built-in Sort (Timsort)",
|
| 401 |
-
"properties": {"complexity": "O(n log n)", "performance": "0.003s", "category": "hybrid_optimized"}
|
| 402 |
-
}
|
| 403 |
-
],
|
| 404 |
-
"relations": [
|
| 405 |
-
{
|
| 406 |
-
"id": "requests_analysis",
|
| 407 |
-
"source": "user",
|
| 408 |
-
"target": "planning_agent",
|
| 409 |
-
"type": "requests",
|
| 410 |
-
"properties": {"request_type": "algorithm_analysis"}
|
| 411 |
-
},
|
| 412 |
-
{
|
| 413 |
-
"id": "decomposes_task",
|
| 414 |
-
"source": "planning_agent",
|
| 415 |
-
"target": "sorting_analysis_task",
|
| 416 |
-
"type": "decomposes",
|
| 417 |
-
"properties": {"decomposition_type": "step_by_step"}
|
| 418 |
-
},
|
| 419 |
-
{
|
| 420 |
-
"id": "delegates_implementation",
|
| 421 |
-
"source": "planning_agent",
|
| 422 |
-
"target": "code_agent",
|
| 423 |
-
"type": "delegates",
|
| 424 |
-
"properties": {"task_type": "algorithm_implementation"}
|
| 425 |
-
},
|
| 426 |
-
{
|
| 427 |
-
"id": "implements_algorithms",
|
| 428 |
-
"source": "code_agent",
|
| 429 |
-
"target": "bubble_sort",
|
| 430 |
-
"type": "implements",
|
| 431 |
-
"properties": {"language": "python"}
|
| 432 |
-
},
|
| 433 |
-
{
|
| 434 |
-
"id": "implements_algorithms_2",
|
| 435 |
-
"source": "code_agent",
|
| 436 |
-
"target": "quick_sort",
|
| 437 |
-
"type": "implements",
|
| 438 |
-
"properties": {"language": "python"}
|
| 439 |
-
},
|
| 440 |
-
{
|
| 441 |
-
"id": "implements_algorithms_3",
|
| 442 |
-
"source": "code_agent",
|
| 443 |
-
"target": "merge_sort",
|
| 444 |
-
"type": "implements",
|
| 445 |
-
"properties": {"language": "python"}
|
| 446 |
-
},
|
| 447 |
-
{
|
| 448 |
-
"id": "delegates_testing",
|
| 449 |
-
"source": "planning_agent",
|
| 450 |
-
"target": "testing_agent",
|
| 451 |
-
"type": "delegates",
|
| 452 |
-
"properties": {"task_type": "performance_evaluation"}
|
| 453 |
-
},
|
| 454 |
-
{
|
| 455 |
-
"id": "tests_performance",
|
| 456 |
-
"source": "testing_agent",
|
| 457 |
-
"target": "bubble_sort",
|
| 458 |
-
"type": "tests",
|
| 459 |
-
"properties": {"metric": "execution_time"}
|
| 460 |
-
},
|
| 461 |
-
{
|
| 462 |
-
"id": "tests_performance_2",
|
| 463 |
-
"source": "testing_agent",
|
| 464 |
-
"target": "quick_sort",
|
| 465 |
-
"type": "tests",
|
| 466 |
-
"properties": {"metric": "execution_time"}
|
| 467 |
-
},
|
| 468 |
-
{
|
| 469 |
-
"id": "tests_performance_3",
|
| 470 |
-
"source": "testing_agent",
|
| 471 |
-
"target": "merge_sort",
|
| 472 |
-
"type": "tests",
|
| 473 |
-
"properties": {"metric": "execution_time"}
|
| 474 |
-
},
|
| 475 |
-
{
|
| 476 |
-
"id": "tests_performance_4",
|
| 477 |
-
"source": "testing_agent",
|
| 478 |
-
"target": "python_sort",
|
| 479 |
-
"type": "tests",
|
| 480 |
-
"properties": {"metric": "execution_time"}
|
| 481 |
-
},
|
| 482 |
-
{
|
| 483 |
-
"id": "delegates_analysis",
|
| 484 |
-
"source": "planning_agent",
|
| 485 |
-
"target": "analysis_agent",
|
| 486 |
-
"type": "delegates",
|
| 487 |
-
"properties": {"task_type": "result_interpretation"}
|
| 488 |
-
},
|
| 489 |
-
{
|
| 490 |
-
"id": "analyzes_results",
|
| 491 |
-
"source": "analysis_agent",
|
| 492 |
-
"target": "sorting_analysis_task",
|
| 493 |
-
"type": "analyzes",
|
| 494 |
-
"properties": {"analysis_type": "comparative_performance"}
|
| 495 |
-
},
|
| 496 |
-
{
|
| 497 |
-
"id": "outperforms",
|
| 498 |
-
"source": "python_sort",
|
| 499 |
-
"target": "quick_sort",
|
| 500 |
-
"type": "outperforms",
|
| 501 |
-
"properties": {"factor": "10x_faster"}
|
| 502 |
-
},
|
| 503 |
-
{
|
| 504 |
-
"id": "outperforms_2",
|
| 505 |
-
"source": "python_sort",
|
| 506 |
-
"target": "merge_sort",
|
| 507 |
-
"type": "outperforms",
|
| 508 |
-
"properties": {"factor": "15x_faster"}
|
| 509 |
-
},
|
| 510 |
-
{
|
| 511 |
-
"id": "outperforms_3",
|
| 512 |
-
"source": "python_sort",
|
| 513 |
-
"target": "bubble_sort",
|
| 514 |
-
"type": "outperforms",
|
| 515 |
-
"properties": {"factor": "4000x_faster"}
|
| 516 |
-
}
|
| 517 |
-
]
|
| 518 |
-
}
|
| 519 |
-
}
|
| 520 |
-
]
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
def insert_sample_data(session, force_insert=False):
|
| 524 |
-
"""
|
| 525 |
-
Insert sample traces and knowledge graphs into the database.
|
| 526 |
-
|
| 527 |
-
Args:
|
| 528 |
-
session: Database session
|
| 529 |
-
force_insert: If True, insert even if data already exists
|
| 530 |
-
|
| 531 |
-
Returns:
|
| 532 |
-
Dict with insertion results
|
| 533 |
-
"""
|
| 534 |
-
from backend.database.utils import save_trace, save_knowledge_graph
|
| 535 |
-
from backend.database.models import Trace, KnowledgeGraph
|
| 536 |
-
|
| 537 |
-
results = {
|
| 538 |
-
"traces_inserted": 0,
|
| 539 |
-
"knowledge_graphs_inserted": 0,
|
| 540 |
-
"skipped": 0,
|
| 541 |
-
"errors": []
|
| 542 |
-
}
|
| 543 |
-
|
| 544 |
-
# Check if sample data already exists
|
| 545 |
-
if not force_insert:
|
| 546 |
-
existing_sample = session.query(Trace).filter(
|
| 547 |
-
Trace.trace_source == "sample_data"
|
| 548 |
-
).first()
|
| 549 |
-
|
| 550 |
-
if existing_sample:
|
| 551 |
-
logger.info("Sample data already exists, skipping insertion")
|
| 552 |
-
results["skipped"] = len(SAMPLE_TRACES)
|
| 553 |
-
return results
|
| 554 |
-
|
| 555 |
-
try:
|
| 556 |
-
# Insert sample traces
|
| 557 |
-
trace_ids = []
|
| 558 |
-
for i, trace_data in enumerate(SAMPLE_TRACES):
|
| 559 |
-
try:
|
| 560 |
-
trace = save_trace(
|
| 561 |
-
session=session,
|
| 562 |
-
content=trace_data["content"],
|
| 563 |
-
filename=trace_data["filename"],
|
| 564 |
-
title=trace_data["title"],
|
| 565 |
-
description=trace_data["description"],
|
| 566 |
-
trace_type=trace_data["trace_type"],
|
| 567 |
-
trace_source=trace_data["trace_source"],
|
| 568 |
-
tags=trace_data["tags"]
|
| 569 |
-
)
|
| 570 |
-
trace_ids.append(trace.trace_id)
|
| 571 |
-
results["traces_inserted"] += 1
|
| 572 |
-
logger.info(f"Inserted sample trace: {trace_data['title']}")
|
| 573 |
-
except Exception as e:
|
| 574 |
-
error_msg = f"Error inserting trace {i}: {str(e)}"
|
| 575 |
-
logger.error(error_msg)
|
| 576 |
-
results["errors"].append(error_msg)
|
| 577 |
-
|
| 578 |
-
# Insert corresponding knowledge graphs
|
| 579 |
-
for kg_data in SAMPLE_KNOWLEDGE_GRAPHS:
|
| 580 |
-
try:
|
| 581 |
-
trace_index = kg_data["trace_index"]
|
| 582 |
-
if trace_index < len(trace_ids):
|
| 583 |
-
save_knowledge_graph(
|
| 584 |
-
session=session,
|
| 585 |
-
filename=kg_data["filename"],
|
| 586 |
-
graph_data=kg_data["graph_data"],
|
| 587 |
-
trace_id=trace_ids[trace_index],
|
| 588 |
-
window_index=None, # None for final KG
|
| 589 |
-
window_total=1, # Not None to indicate it's a processed final KG
|
| 590 |
-
is_original=True
|
| 591 |
-
)
|
| 592 |
-
results["knowledge_graphs_inserted"] += 1
|
| 593 |
-
logger.info(f"Inserted sample knowledge graph: {kg_data['filename']}")
|
| 594 |
-
except Exception as e:
|
| 595 |
-
error_msg = f"Error inserting knowledge graph {kg_data['filename']}: {str(e)}"
|
| 596 |
-
logger.error(error_msg)
|
| 597 |
-
results["errors"].append(error_msg)
|
| 598 |
-
|
| 599 |
-
logger.info(f"Sample data insertion completed: {results}")
|
| 600 |
-
|
| 601 |
-
except Exception as e:
|
| 602 |
-
error_msg = f"Fatal error during sample data insertion: {str(e)}"
|
| 603 |
-
logger.error(error_msg)
|
| 604 |
-
results["errors"].append(error_msg)
|
| 605 |
-
raise # Re-raise to trigger rollback in calling code
|
| 606 |
-
|
| 607 |
-
return results
|
| 608 |
-
|
| 609 |
-
|
| 610 |
-
def get_sample_data_info():
|
| 611 |
-
"""
|
| 612 |
-
Get information about the available sample data.
|
| 613 |
-
|
| 614 |
-
Returns:
|
| 615 |
-
Dict with sample data statistics
|
| 616 |
-
"""
|
| 617 |
-
return {
|
| 618 |
-
"traces_count": len(SAMPLE_TRACES),
|
| 619 |
-
"knowledge_graphs_count": len(SAMPLE_KNOWLEDGE_GRAPHS),
|
| 620 |
-
"trace_types": list(set(t["trace_type"] for t in SAMPLE_TRACES)),
|
| 621 |
-
"complexity_levels": ["simple", "medium", "high"],
|
| 622 |
-
"description": "Curated examples showing basic Q&A, research tasks, and multi-agent collaboration"
|
| 623 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"system_name": "Oxford Economics AI Assistant",
|
| 3 |
+
"system_summary": "This intelligent assistant processes user inquiries about Oxford Economics through a streamlined workflow. When users submit questions, the knowledgeable agent analyzes them using advanced language models and delivers accurate, contextual responses about economic analysis and forecasting services.",
|
| 4 |
+
"entities": [
|
| 5 |
+
{
|
| 6 |
+
"id": "agent_001",
|
| 7 |
+
"type": "Agent",
|
| 8 |
+
"name": "Oxford Economics Knowledge Agent",
|
| 9 |
+
"importance": "HIGH",
|
| 10 |
+
"raw_prompt": "You are a knowledgeable assistant on Oxford Economics designed to answer questions accurately based on the provided context. Use the information in the documents below to respond concisely and correctly.",
|
| 11 |
+
"raw_prompt_ref": [
|
| 12 |
+
{
|
| 13 |
+
"line_start": 31,
|
| 14 |
+
"line_end": 32
|
| 15 |
+
}
|
| 16 |
+
]
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"id": "task_001",
|
| 20 |
+
"type": "Task",
|
| 21 |
+
"name": "Economic Inquiry Processing",
|
| 22 |
+
"importance": "HIGH",
|
| 23 |
+
"raw_prompt": "Process user inquiry about Oxford Economics and generate an accurate, contextual response based on available information and company expertise.",
|
| 24 |
+
"raw_prompt_ref": [
|
| 25 |
+
{
|
| 26 |
+
"line_start": 26,
|
| 27 |
+
"line_end": 28
|
| 28 |
+
}
|
| 29 |
+
]
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"id": "input_001",
|
| 33 |
+
"type": "Input",
|
| 34 |
+
"name": "User Economic Query",
|
| 35 |
+
"importance": "HIGH",
|
| 36 |
+
"raw_prompt": "what does oxford economics present?",
|
| 37 |
+
"raw_prompt_ref": [
|
| 38 |
+
{
|
| 39 |
+
"line_start": 19,
|
| 40 |
+
"line_end": 19
|
| 41 |
+
}
|
| 42 |
+
]
|
| 43 |
+
},
|
| 44 |
+
{
|
| 45 |
+
"id": "output_001",
|
| 46 |
+
"type": "Output",
|
| 47 |
+
"name": "Economic Services Overview",
|
| 48 |
+
"importance": "HIGH",
|
| 49 |
+
"raw_prompt": "Oxford Economics provides economic analysis, forecasting, and consultancy services.",
|
| 50 |
+
"raw_prompt_ref": [
|
| 51 |
+
{
|
| 52 |
+
"line_start": 20,
|
| 53 |
+
"line_end": 20
|
| 54 |
+
}
|
| 55 |
+
]
|
| 56 |
+
},
|
| 57 |
+
{
|
| 58 |
+
"id": "human_001",
|
| 59 |
+
"type": "Human",
|
| 60 |
+
"name": "Business User",
|
| 61 |
+
"importance": "MEDIUM",
|
| 62 |
+
"raw_prompt": "Professional seeking economic insights and analysis",
|
| 63 |
+
"raw_prompt_ref": [
|
| 64 |
+
{
|
| 65 |
+
"line_start": 31,
|
| 66 |
+
"line_end": 31
|
| 67 |
+
}
|
| 68 |
+
]
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"id": "tool_001",
|
| 72 |
+
"type": "Tool",
|
| 73 |
+
"name": "GPT-4o Language Model",
|
| 74 |
+
"importance": "HIGH",
|
| 75 |
+
"raw_prompt": "Advanced AI language model with economic domain knowledge and structured response capabilities.",
|
| 76 |
+
"raw_prompt_ref": [
|
| 77 |
+
{
|
| 78 |
+
"line_start": 49,
|
| 79 |
+
"line_end": 49
|
| 80 |
+
}
|
| 81 |
+
]
|
| 82 |
+
}
|
| 83 |
+
],
|
| 84 |
+
"relations": [
|
| 85 |
+
{
|
| 86 |
+
"id": "rel_001",
|
| 87 |
+
"source": "input_001",
|
| 88 |
+
"target": "agent_001",
|
| 89 |
+
"type": "CONSUMED_BY",
|
| 90 |
+
"importance": "HIGH",
|
| 91 |
+
"interaction_prompt": "User query received and processed by the economic knowledge agent",
|
| 92 |
+
"interaction_prompt_ref": [
|
| 93 |
+
{
|
| 94 |
+
"line_start": 19,
|
| 95 |
+
"line_end": 19
|
| 96 |
+
}
|
| 97 |
+
]
|
| 98 |
+
},
|
| 99 |
+
{
|
| 100 |
+
"id": "rel_002",
|
| 101 |
+
"source": "agent_001",
|
| 102 |
+
"target": "task_001",
|
| 103 |
+
"type": "PERFORMS",
|
| 104 |
+
"importance": "HIGH",
|
| 105 |
+
"interaction_prompt": "Agent executes economic inquiry processing task",
|
| 106 |
+
"interaction_prompt_ref": [
|
| 107 |
+
{
|
| 108 |
+
"line_start": 26,
|
| 109 |
+
"line_end": 28
|
| 110 |
+
}
|
| 111 |
+
]
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"id": "rel_003",
|
| 115 |
+
"source": "task_001",
|
| 116 |
+
"target": "output_001",
|
| 117 |
+
"type": "PRODUCES",
|
| 118 |
+
"importance": "HIGH",
|
| 119 |
+
"interaction_prompt": "Processing task generates comprehensive economic services response",
|
| 120 |
+
"interaction_prompt_ref": [
|
| 121 |
+
{
|
| 122 |
+
"line_start": 20,
|
| 123 |
+
"line_end": 20
|
| 124 |
+
}
|
| 125 |
+
]
|
| 126 |
+
},
|
| 127 |
+
{
|
| 128 |
+
"id": "rel_004",
|
| 129 |
+
"source": "output_001",
|
| 130 |
+
"target": "human_001",
|
| 131 |
+
"type": "DELIVERS_TO",
|
| 132 |
+
"importance": "HIGH",
|
| 133 |
+
"interaction_prompt": "Economic analysis delivered to requesting business user",
|
| 134 |
+
"interaction_prompt_ref": [
|
| 135 |
+
{
|
| 136 |
+
"line_start": 20,
|
| 137 |
+
"line_end": 20
|
| 138 |
+
}
|
| 139 |
+
]
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"id": "rel_005",
|
| 143 |
+
"source": "agent_001",
|
| 144 |
+
"target": "tool_001",
|
| 145 |
+
"type": "USES",
|
| 146 |
+
"importance": "HIGH",
|
| 147 |
+
"interaction_prompt": "Agent leverages language model for natural language understanding and generation",
|
| 148 |
+
"interaction_prompt_ref": [
|
| 149 |
+
{
|
| 150 |
+
"line_start": 49,
|
| 151 |
+
"line_end": 49
|
| 152 |
+
}
|
| 153 |
+
]
|
| 154 |
+
}
|
| 155 |
+
],
|
| 156 |
+
"failures": [
|
| 157 |
+
{
|
| 158 |
+
"id": "failure_001",
|
| 159 |
+
"risk_type": "HALLUCINATION",
|
| 160 |
+
"description": "Minor spelling inconsistency in user query may affect search precision.",
|
| 161 |
+
"raw_text": "what does oxford economics present?",
|
| 162 |
+
"raw_text_ref": [
|
| 163 |
+
{
|
| 164 |
+
"line_start": 19,
|
| 165 |
+
"line_end": 19
|
| 166 |
+
}
|
| 167 |
+
],
|
| 168 |
+
"affected_id": "input_001"
|
| 169 |
+
}
|
| 170 |
+
],
|
| 171 |
+
"optimizations": [
|
| 172 |
+
{
|
| 173 |
+
"id": "opt_001",
|
| 174 |
+
"recommendation_type": "PROMPT_REFINEMENT",
|
| 175 |
+
"description": "Enhance the agent prompt to include spell-checking and query normalization capabilities for improved accuracy and user experience.",
|
| 176 |
+
"affected_ids": ["agent_001"],
|
| 177 |
+
"raw_text_ref": [
|
| 178 |
+
{
|
| 179 |
+
"line_start": 31,
|
| 180 |
+
"line_end": 32
|
| 181 |
+
}
|
| 182 |
+
]
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"id": "opt_002",
|
| 186 |
+
"recommendation_type": "TOOL_ENHANCEMENT",
|
| 187 |
+
"description": "Integrate Oxford Economics knowledge base with the language model to provide more specific and detailed responses about services and capabilities.",
|
| 188 |
+
"affected_ids": ["tool_001"],
|
| 189 |
+
"raw_text_ref": [
|
| 190 |
+
{
|
| 191 |
+
"line_start": 49,
|
| 192 |
+
"line_end": 49
|
| 193 |
+
}
|
| 194 |
+
]
|
| 195 |
+
}
|
| 196 |
+
],
|
| 197 |
+
"metadata": {
|
| 198 |
+
"creation_timestamp": "2025-01-27T12:00:00Z",
|
| 199 |
+
"schema_version": "2.1.0",
|
| 200 |
+
"quality_score": 0.89,
|
| 201 |
+
"entity_count": 6,
|
| 202 |
+
"relation_count": 5,
|
| 203 |
+
"failure_count": 1,
|
| 204 |
+
"optimization_count": 2,
|
| 205 |
+
"processing_method": "production_enhanced",
|
| 206 |
+
"content_source": "aif_inference_trace",
|
| 207 |
+
"language": "en",
|
| 208 |
+
"domain": "economics_consulting"
|
| 209 |
+
}
|
| 210 |
+
}
|
|
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"system_name": "Oxford Economics Inquiry and Response System",
|
| 3 |
+
"system_summary": "This system manages Oxford Economics inquiries through a streamlined workflow. The process begins when `Mateusz Urban` (human_001) submits their `User Inquiry Prompt` (input_001), which gets consumed by the `Knowledgeable Assistant on Oxford Economics` (agent_001). The assistant then performs the `Inquiry Response Task` (task_001) using the `GPT-4o Model` (tool_001) to generate the `Oxford Economics Definition Response` (output_001), which is ultimately delivered back to the user, completing the information flow cycle.",
|
| 4 |
+
"entities": [
|
| 5 |
+
{
|
| 6 |
+
"id": "agent_001",
|
| 7 |
+
"type": "Agent",
|
| 8 |
+
"name": "Knowledgeable Assistant on Oxford Economics",
|
| 9 |
+
"importance": "HIGH",
|
| 10 |
+
"raw_prompt": "You are a knowledgeable assistant on Oxford Economics designed to answer questions accurately based on the provided context. Use the information in the documents below to respond concisely and correctly.",
|
| 11 |
+
"raw_prompt_ref": [
|
| 12 |
+
{
|
| 13 |
+
"line_start": 31,
|
| 14 |
+
"line_end": 32,
|
| 15 |
+
"confidence": 0.95
|
| 16 |
+
}
|
| 17 |
+
]
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"id": "task_001",
|
| 21 |
+
"type": "Task",
|
| 22 |
+
"name": "Inquiry Response Task",
|
| 23 |
+
"importance": "HIGH",
|
| 24 |
+
"raw_prompt": "Process user inquiry about Oxford Economics and generate an accurate, contextual response based on available information and company background.",
|
| 25 |
+
"raw_prompt_ref": [
|
| 26 |
+
{
|
| 27 |
+
"line_start": 26,
|
| 28 |
+
"line_end": 28,
|
| 29 |
+
"confidence": 0.9
|
| 30 |
+
}
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"id": "output_001",
|
| 35 |
+
"type": "Output",
|
| 36 |
+
"name": "Oxford Economics Definition Response",
|
| 37 |
+
"importance": "HIGH",
|
| 38 |
+
"raw_prompt": "Oxford Economics provides economic analysis, forecasting, and consultancy services.",
|
| 39 |
+
"raw_prompt_ref": [
|
| 40 |
+
{
|
| 41 |
+
"line_start": 20,
|
| 42 |
+
"line_end": 20,
|
| 43 |
+
"confidence": 1.0
|
| 44 |
+
}
|
| 45 |
+
]
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"id": "input_001",
|
| 49 |
+
"type": "Input",
|
| 50 |
+
"name": "User Inquiry Prompt",
|
| 51 |
+
"importance": "HIGH",
|
| 52 |
+
"raw_prompt": "what does oxford eonomics present?",
|
| 53 |
+
"raw_prompt_ref": [
|
| 54 |
+
{
|
| 55 |
+
"line_start": 19,
|
| 56 |
+
"line_end": 19,
|
| 57 |
+
"confidence": 1.0
|
| 58 |
+
}
|
| 59 |
+
]
|
| 60 |
+
},
|
| 61 |
+
{
|
| 62 |
+
"id": "human_001",
|
| 63 |
+
"type": "Human",
|
| 64 |
+
"name": "Mateusz Urban",
|
| 65 |
+
"importance": "MEDIUM",
|
| 66 |
+
"raw_prompt": "User interaction pattern: submits inquiry and receives response",
|
| 67 |
+
"raw_prompt_ref": [
|
| 68 |
+
{
|
| 69 |
+
"line_start": 31,
|
| 70 |
+
"line_end": 31,
|
| 71 |
+
"confidence": 0.8
|
| 72 |
+
}
|
| 73 |
+
]
|
| 74 |
+
},
|
| 75 |
+
{
|
| 76 |
+
"id": "tool_001",
|
| 77 |
+
"type": "Tool",
|
| 78 |
+
"name": "GPT-4o Model (2024-11-20)",
|
| 79 |
+
"importance": "HIGH",
|
| 80 |
+
"raw_prompt": "AI language model configured for Oxford Economics domain knowledge with structured response capabilities and context-aware processing.",
|
| 81 |
+
"raw_prompt_ref": [
|
| 82 |
+
{
|
| 83 |
+
"line_start": 49,
|
| 84 |
+
"line_end": 49,
|
| 85 |
+
"confidence": 1.0
|
| 86 |
+
}
|
| 87 |
+
]
|
| 88 |
+
}
|
| 89 |
+
],
|
| 90 |
+
"relations": [
|
| 91 |
+
{
|
| 92 |
+
"id": "relation_001",
|
| 93 |
+
"source": "input_001",
|
| 94 |
+
"target": "agent_001",
|
| 95 |
+
"type": "CONSUMED_BY",
|
| 96 |
+
"importance": "HIGH",
|
| 97 |
+
"interaction_prompt": "User inquiry processed by assistant: 'what does oxford eonomics present?'",
|
| 98 |
+
"interaction_prompt_ref": [
|
| 99 |
+
{
|
| 100 |
+
"line_start": 19,
|
| 101 |
+
"line_end": 19,
|
| 102 |
+
"confidence": 1.0
|
| 103 |
+
}
|
| 104 |
+
]
|
| 105 |
+
},
|
| 106 |
+
{
|
| 107 |
+
"id": "relation_002",
|
| 108 |
+
"source": "agent_001",
|
| 109 |
+
"target": "task_001",
|
| 110 |
+
"type": "PERFORMS",
|
| 111 |
+
"importance": "HIGH",
|
| 112 |
+
"interaction_prompt": "Assistant actively processes the Oxford Economics inquiry using domain knowledge",
|
| 113 |
+
"interaction_prompt_ref": [
|
| 114 |
+
{
|
| 115 |
+
"line_start": 31,
|
| 116 |
+
"line_end": 32,
|
| 117 |
+
"confidence": 0.9
|
| 118 |
+
}
|
| 119 |
+
]
|
| 120 |
+
},
|
| 121 |
+
{
|
| 122 |
+
"id": "relation_003",
|
| 123 |
+
"source": "task_001",
|
| 124 |
+
"target": "output_001",
|
| 125 |
+
"type": "PRODUCES",
|
| 126 |
+
"importance": "HIGH",
|
| 127 |
+
"interaction_prompt": "Task generates structured response about Oxford Economics services",
|
| 128 |
+
"interaction_prompt_ref": [
|
| 129 |
+
{
|
| 130 |
+
"line_start": 20,
|
| 131 |
+
"line_end": 20,
|
| 132 |
+
"confidence": 1.0
|
| 133 |
+
}
|
| 134 |
+
]
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"id": "relation_004",
|
| 138 |
+
"source": "output_001",
|
| 139 |
+
"target": "human_001",
|
| 140 |
+
"type": "DELIVERS_TO",
|
| 141 |
+
"importance": "HIGH",
|
| 142 |
+
"interaction_prompt": "Response delivered to Mateusz Urban with Oxford Economics definition",
|
| 143 |
+
"interaction_prompt_ref": [
|
| 144 |
+
{
|
| 145 |
+
"line_start": 20,
|
| 146 |
+
"line_end": 20,
|
| 147 |
+
"confidence": 1.0
|
| 148 |
+
}
|
| 149 |
+
]
|
| 150 |
+
},
|
| 151 |
+
{
|
| 152 |
+
"id": "relation_005",
|
| 153 |
+
"source": "agent_001",
|
| 154 |
+
"target": "tool_001",
|
| 155 |
+
"type": "USES",
|
| 156 |
+
"importance": "HIGH",
|
| 157 |
+
"interaction_prompt": "Assistant leverages GPT-4o model capabilities for processing and response generation",
|
| 158 |
+
"interaction_prompt_ref": [
|
| 159 |
+
{
|
| 160 |
+
"line_start": 49,
|
| 161 |
+
"line_end": 49,
|
| 162 |
+
"confidence": 0.9
|
| 163 |
+
}
|
| 164 |
+
]
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"id": "relation_006",
|
| 168 |
+
"source": "task_001",
|
| 169 |
+
"target": "tool_001",
|
| 170 |
+
"type": "REQUIRED_BY",
|
| 171 |
+
"importance": "HIGH",
|
| 172 |
+
"interaction_prompt": "Task execution requires GPT-4o model for natural language processing",
|
| 173 |
+
"interaction_prompt_ref": [
|
| 174 |
+
{
|
| 175 |
+
"line_start": 49,
|
| 176 |
+
"line_end": 49,
|
| 177 |
+
"confidence": 0.8
|
| 178 |
+
}
|
| 179 |
+
]
|
| 180 |
+
}
|
| 181 |
+
],
|
| 182 |
+
"failures": [
|
| 183 |
+
{
|
| 184 |
+
"id": "failure_001",
|
| 185 |
+
"risk_type": "HALLUCINATION",
|
| 186 |
+
"description": "User input contains spelling error 'eonomics' instead of 'economics' which may lead to misinterpretation or processing errors.",
|
| 187 |
+
"raw_text": "what does oxford eonomics present?",
|
| 188 |
+
"raw_text_ref": [
|
| 189 |
+
{
|
| 190 |
+
"line_start": 19,
|
| 191 |
+
"line_end": 19,
|
| 192 |
+
"confidence": 1.0
|
| 193 |
+
}
|
| 194 |
+
],
|
| 195 |
+
"affected_id": "input_001"
|
| 196 |
+
},
|
| 197 |
+
{
|
| 198 |
+
"id": "failure_002",
|
| 199 |
+
"risk_type": "AGENT_ERROR",
|
| 200 |
+
"description": "System prompt contains spelling error 'knowledgable' instead of 'knowledgeable' which may affect professional credibility.",
|
| 201 |
+
"raw_text": "You are a knowledgable assitant on Oxford Economics",
|
| 202 |
+
"raw_text_ref": [
|
| 203 |
+
{
|
| 204 |
+
"line_start": 31,
|
| 205 |
+
"line_end": 31,
|
| 206 |
+
"confidence": 0.9
|
| 207 |
+
}
|
| 208 |
+
],
|
| 209 |
+
"affected_id": "agent_001"
|
| 210 |
+
},
|
| 211 |
+
{
|
| 212 |
+
"id": "failure_003",
|
| 213 |
+
"risk_type": "PLANNING_ERROR",
|
| 214 |
+
"description": "Missing validation step for user input quality and spell-checking before processing, leading to potential propagation of errors.",
|
| 215 |
+
"raw_text": "",
|
| 216 |
+
"raw_text_ref": [
|
| 217 |
+
{
|
| 218 |
+
"line_start": 19,
|
| 219 |
+
"line_end": 32,
|
| 220 |
+
"confidence": 0.7
|
| 221 |
+
}
|
| 222 |
+
],
|
| 223 |
+
"affected_id": "task_001"
|
| 224 |
+
}
|
| 225 |
+
],
|
| 226 |
+
"optimizations": [
|
| 227 |
+
{
|
| 228 |
+
"id": "opt_001",
|
| 229 |
+
"recommendation_type": "PROMPT_REFINEMENT",
|
| 230 |
+
"description": "Enhance the system prompt to include explicit spell-checking and error correction capabilities. The current prompt should be refined to handle common misspellings and provide clarification when ambiguous terms are encountered. This would improve robustness and user experience.",
|
| 231 |
+
"affected_ids": ["agent_001"],
|
| 232 |
+
"raw_text_ref": [
|
| 233 |
+
{
|
| 234 |
+
"line_start": 31,
|
| 235 |
+
"line_end": 32,
|
| 236 |
+
"confidence": 0.9
|
| 237 |
+
}
|
| 238 |
+
]
|
| 239 |
+
},
|
| 240 |
+
{
|
| 241 |
+
"id": "opt_002",
|
| 242 |
+
"recommendation_type": "WORKFLOW_SIMPLIFICATION",
|
| 243 |
+
"description": "Add an input validation and preprocessing step before the main task execution. This would include spell-checking, query normalization, and intent clarification to improve overall system reliability and reduce downstream errors.",
|
| 244 |
+
"affected_ids": ["task_001", "input_001"],
|
| 245 |
+
"raw_text_ref": [
|
| 246 |
+
{
|
| 247 |
+
"line_start": 19,
|
| 248 |
+
"line_end": 19,
|
| 249 |
+
"confidence": 0.8
|
| 250 |
+
}
|
| 251 |
+
]
|
| 252 |
+
},
|
| 253 |
+
{
|
| 254 |
+
"id": "opt_003",
|
| 255 |
+
"recommendation_type": "TOOL_ENHANCEMENT",
|
| 256 |
+
"description": "Configure the GPT-4o model with specific Oxford Economics domain knowledge and terminology database to provide more accurate and detailed responses. Consider implementing RAG (Retrieval-Augmented Generation) with Oxford Economics documentation.",
|
| 257 |
+
"affected_ids": ["tool_001"],
|
| 258 |
+
"raw_text_ref": [
|
| 259 |
+
{
|
| 260 |
+
"line_start": 49,
|
| 261 |
+
"line_end": 49,
|
| 262 |
+
"confidence": 0.8
|
| 263 |
+
}
|
| 264 |
+
]
|
| 265 |
+
},
|
| 266 |
+
{
|
| 267 |
+
"id": "opt_004",
|
| 268 |
+
"recommendation_type": "PROMPT_REFINEMENT",
|
| 269 |
+
"description": "Implement response quality metrics and feedback collection from users to continuously improve the system's knowledge base and response accuracy. This would enable iterative enhancement of the Oxford Economics information repository.",
|
| 270 |
+
"affected_ids": ["output_001", "human_001"],
|
| 271 |
+
"raw_text_ref": [
|
| 272 |
+
{
|
| 273 |
+
"line_start": 20,
|
| 274 |
+
"line_end": 20,
|
| 275 |
+
"confidence": 0.7
|
| 276 |
+
}
|
| 277 |
+
]
|
| 278 |
+
}
|
| 279 |
+
],
|
| 280 |
+
"metadata": {
|
| 281 |
+
"content_resolution": {
|
| 282 |
+
"resolved_at": "2025-01-27T11:35:54.766346",
|
| 283 |
+
"original_trace_length": 4203,
|
| 284 |
+
"resolution_method": "enhanced_content_reference_resolver",
|
| 285 |
+
"confidence_scoring": true
|
| 286 |
+
},
|
| 287 |
+
"window_info": {
|
| 288 |
+
"window_index": 1,
|
| 289 |
+
"window_start_char": 1914,
|
| 290 |
+
"window_end_char": 4202,
|
| 291 |
+
"chunk_size": 2288,
|
| 292 |
+
"window_size": 800000,
|
| 293 |
+
"overlap_size": 1144,
|
| 294 |
+
"splitter_type": "agent_semantic",
|
| 295 |
+
"log_type": "structured_json",
|
| 296 |
+
"boundary_used": "json_object_end",
|
| 297 |
+
"boundary_confidence": 0.8,
|
| 298 |
+
"contains_agent_markers": false,
|
| 299 |
+
"contains_tool_patterns": true,
|
| 300 |
+
"overlap_with_previous": true,
|
| 301 |
+
"global_line_start": 1,
|
| 302 |
+
"global_line_end": 53,
|
| 303 |
+
"processed_at": "2025-01-27T11:35:22.437186",
|
| 304 |
+
"line_mapping_created": true,
|
| 305 |
+
"window_total": 4,
|
| 306 |
+
"trace_id": "1dca1078-8505-4263-998a-740e7794a94c",
|
| 307 |
+
"processing_run_id": "eac673d4"
|
| 308 |
+
},
|
| 309 |
+
"merge_info": {
|
| 310 |
+
"source_graphs": 2,
|
| 311 |
+
"merge_timestamp": "2025-01-27T11:35:54.762510",
|
| 312 |
+
"window_count": 2,
|
| 313 |
+
"merged_entity_count": 6,
|
| 314 |
+
"merged_relation_count": 6,
|
| 315 |
+
"deduplication_applied": true,
|
| 316 |
+
"quality_score": 0.92
|
| 317 |
+
},
|
| 318 |
+
"processing_info": {
|
| 319 |
+
"entity_deduplication": {
|
| 320 |
+
"original_count": 8,
|
| 321 |
+
"deduplicated_count": 6,
|
| 322 |
+
"duplicates_removed": 2
|
| 323 |
+
},
|
| 324 |
+
"relationship_deduplication": {
|
| 325 |
+
"original_count": 7,
|
| 326 |
+
"deduplicated_count": 6,
|
| 327 |
+
"duplicates_removed": 1
|
| 328 |
+
},
|
| 329 |
+
"failure_detection": {
|
| 330 |
+
"total_failures_detected": 3,
|
| 331 |
+
"failure_types": ["HALLUCINATION", "AGENT_ERROR", "PLANNING_ERROR"],
|
| 332 |
+
"confidence_threshold": 0.7
|
| 333 |
+
},
|
| 334 |
+
"optimization_generation": {
|
| 335 |
+
"total_optimizations": 4,
|
| 336 |
+
"recommendation_types": ["PROMPT_REFINEMENT", "WORKFLOW_SIMPLIFICATION", "TOOL_ENHANCEMENT"],
|
| 337 |
+
"priority_scoring": true
|
| 338 |
+
}
|
| 339 |
+
},
|
| 340 |
+
"hierarchical_merge_info": {
|
| 341 |
+
"source_graphs": 4,
|
| 342 |
+
"batch_size": 3,
|
| 343 |
+
"max_parallel": 3,
|
| 344 |
+
"merge_timestamp": "2025-01-27T11:35:54.763664",
|
| 345 |
+
"total_window_count": 4,
|
| 346 |
+
"final_entity_count": 6,
|
| 347 |
+
"final_relation_count": 6,
|
| 348 |
+
"skip_layers_threshold": 3,
|
| 349 |
+
"optimization_applied": true,
|
| 350 |
+
"failure_detection_enabled": true
|
| 351 |
+
},
|
| 352 |
+
"trace_info": {
|
| 353 |
+
"trace_id": "1dca1078-8505-4263-998a-740e7794a94c",
|
| 354 |
+
"window_count": 4,
|
| 355 |
+
"processed_at": "2025-01-27T11:35:54.764137",
|
| 356 |
+
"source_trace_id": "1dca1078-8505-4263-998a-740e7794a94c",
|
| 357 |
+
"processing_run_id": "eac673d4",
|
| 358 |
+
"quality_assessment": {
|
| 359 |
+
"overall_score": 0.89,
|
| 360 |
+
"entity_quality": 0.91,
|
| 361 |
+
"relation_quality": 0.88,
|
| 362 |
+
"content_reference_quality": 0.87,
|
| 363 |
+
"failure_detection_coverage": 0.92,
|
| 364 |
+
"optimization_relevance": 0.86
|
| 365 |
+
}
|
| 366 |
+
},
|
| 367 |
+
"processing_params": {
|
| 368 |
+
"method_name": "production_enhanced",
|
| 369 |
+
"batch_size": 3,
|
| 370 |
+
"parallel_processing": true,
|
| 371 |
+
"merge_method": "hierarchical_batch_with_quality_control",
|
| 372 |
+
"optimization_applied": true,
|
| 373 |
+
"failure_detection_enabled": true,
|
| 374 |
+
"confidence_scoring_enabled": true,
|
| 375 |
+
"window_size": 800000,
|
| 376 |
+
"overlap_size": 2288,
|
| 377 |
+
"splitter_type": "agent_semantic",
|
| 378 |
+
"enhancement_features": [
|
| 379 |
+
"spell_checking",
|
| 380 |
+
"content_quality_assessment",
|
| 381 |
+
"automatic_optimization_generation",
|
| 382 |
+
"comprehensive_failure_detection"
|
| 383 |
+
]
|
| 384 |
+
},
|
| 385 |
+
"schema_version": "2.1.0",
|
| 386 |
+
"generation_timestamp": "2025-01-27T12:00:00.000000Z",
|
| 387 |
+
"model_used": "gpt-4o-mini-enhanced",
|
| 388 |
+
"processing_duration_seconds": 168.4
|
| 389 |
+
}
|
| 390 |
+
}
|