FRED Navigator
Purpose
Provide a reliable workflow to navigate FRED categories and series, with support for:
- 1. Direct INLINECODE0
- Direct INLINECODE1
- Natural-language
query → intent recognition → double validation
Inputs
- -
category_id: FRED category id - INLINECODE4 : FRED series id
- INLINECODE5 : natural language request
- INLINECODE6 : number of candidates to return (default 5)
- INLINECODE7 : read from environment
FRED_API_KEY only
Required Resources
- - INLINECODE9
- INLINECODE10
- Optional:
references/category_paths.json (precomputed) - Optional: INLINECODE12
- Helper script: INLINECODE13
- Path builder: INLINECODE14
Optional Resource Structure Notes
- -
references/category_paths.json format:
-
{ "category_id": { "id": <int>, "name": "<str>", "path": "<str>" }, ... }
- -
references/synonyms.json format:
- INLINECODE18
Workflow
1. Category Exploration
- 1. Load
fred_categories_tree.json for hierarchical browsing. - If user provides
category_id, validate it exists. - If user provides
category_name, fuzzy match against flat names and return candidates.
2. Series Discovery
- 1. Use
search_by_category(category_id) to list available series. - Prefer
scripts/fred_query.py category <id> for consistent output. - Return key columns:
-
id,
title,
frequency,
units,
seasonal_adjustment,
last_updated.
3. Series Retrieval
- 1. Use
get_series(series_id) for time series. - Use
get_series_info(series_id) for metadata. - Prefer
scripts/fred_query.py series <id> and scripts/fred_query.py series-info <id>. - Provide:
- data head/tail
- missing counts
- latest value and date
4. Natural Language Query
4.1 Intent Identification (Top-K)
- 1. Use the IDE agent (Codex) to interpret the natural-language intent.
- Select the single best-matching category.
- If confidence is low, ask the user to confirm the category before proceeding.
- Use
references/category_paths.json and references/synonyms.json as supporting context if available.
4.2 Double Validation
Structural validation
- - Candidate must exist in
fred_categories_tree.json. - Pass if at least one:
-
children non-empty
-
search_by_category(id) returns >= 1 series
- Prefer
scripts/fred_query.py check-category <id> for a quick check
Semantic validation (agent)
- - Compare
query with candidate name/path. - Return
pass/fail or numeric relevance score.
4.3 Decision
- - If structural + semantic validation both pass → accept category.
- Otherwise:
- return Top-5 candidates
- ask user to choose one explicitly
Failure Handling
- - Always provide Top-5 candidates when uncertain.
- Never proceed to series retrieval if category validation fails.
Notes
- - Do not hardcode API keys.
- Keep heavy reference data in
references/, not in this file. - When running Python functions for querying, execute them inside the sandbox environment.
Maintenance
- - Update workflow or constraints: edit
SKILL.md. - Update category data: replace files in
references/. - Improve natural-language matching: add or edit
references/synonyms.json (key → list of related terms). - Regenerate precomputed paths (optional): run
scripts/build_paths.py. - Add helper scripts (optional): place in
scripts/ and document usage here.
FRED Navigator
目的
提供可靠的工作流程以导航FRED类别和序列,支持:
- 1. 直接使用categoryid
- 直接使用seriesid
- 自然语言query → 意图识别 → 双重验证
输入
- - categoryid:FRED类别ID
- seriesid:FRED序列ID
- query:自然语言请求
- limit:返回候选数量(默认5)
- apikey:仅从环境变量FREDAPI_KEY读取
所需资源
- - references/fredcategoriestree.json
- references/fredcategoriesflat.json
- 可选:references/categorypaths.json(预计算)
- 可选:references/synonyms.json
- 辅助脚本:scripts/fredquery.py
- 路径构建器:scripts/build_paths.py
可选资源结构说明
- - references/category_paths.json格式:
- { category_id: { id:
, name: , path: }, ... }
- - references/synonyms.json格式:
- { 概念: [别名1, 别名2, ...], ... }
工作流程
1. 类别探索
- 1. 加载fredcategoriestree.json进行层级浏览。
- 如果用户提供categoryid,验证其是否存在。
- 如果用户提供categoryname,对扁平名称进行模糊匹配并返回候选结果。
2. 序列发现
- 1. 使用searchbycategory(categoryid)列出可用序列。
- 优先使用scripts/fredquery.py category 以获得一致输出。
- 返回关键列:
- id、title、frequency、units、seasonaladjustment、lastupdated
3. 序列检索
- 1. 使用getseries(seriesid)获取时间序列。
- 使用getseriesinfo(seriesid)获取元数据。
- 优先使用scripts/fredquery.py series 和scripts/fred_query.py series-info 。
- 提供:
- 数据头部/尾部
- 缺失值计数
- 最新数值和日期
4. 自然语言查询
4.1 意图识别(Top-K)
- 1. 使用IDE代理(Codex)解释自然语言意图。
- 选择最佳匹配的单个类别。
- 如果置信度较低,请用户确认类别后再继续。
- 如果可用,使用references/category_paths.json和references/synonyms.json作为辅助上下文。
4.2 双重验证
结构验证
- - 候选类别必须存在于fredcategoriestree.json中。
- 满足以下至少一项即通过:
- children非空
- searchbycategory(id)返回 >= 1 个序列
- 优先使用scripts/fred_query.py check-category 进行快速检查
语义验证(代理)
- - 将query与候选类别的name/path进行比较。
- 返回通过/未通过或数值相关性评分。
4.3 决策
- - 如果结构验证和语义验证均通过 → 接受该类别。
- 否则:
- 返回Top-5候选结果
- 请用户明确选择一个
失败处理
- - 不确定时始终提供Top-5候选结果。
- 如果类别验证失败,绝不进入序列检索步骤。
备注
- - 不要硬编码API密钥。
- 将大型参考数据保存在references/中,而非此文件内。
- 运行Python查询函数时,在沙箱环境中执行。
维护
- - 更新工作流程或约束条件:编辑SKILL.md。
- 更新类别数据:替换references/中的文件。
- 改进自然语言匹配:添加或编辑references/synonyms.json(键 → 相关术语列表)。
- 重新生成预计算路径(可选):运行scripts/build_paths.py。
- 添加辅助脚本(可选):放置在scripts/中并在此处记录用法。