--- name: gangtise description: | Use when the user asks about Chinese equity research, broker reports, analyst opinions, industry chain analysis, investment logic, company deep-dives, economic indicators, or needs to search financial knowledge bases. Triggers: "研报", "研究报告", "投资逻辑", "产业链", "调研提纲", "晨报", "指标查询", "GDP", "销量", "深度研究", "gangtise". allowed-tools: Bash WebFetch Read Write Edit Glob Grep AskUserQuestion user-invokable: true --- # Gangtise Ultra — 投研知识库 & AI Agent API 港股/A股研报知识库智能检索 + AI 深度研究 Agent + 经济指标查询。 ## Configuration **Base URL:** `http://39.96.218.64:8009` **Auth:** All requests require `Authorization: Bearer ` header. ### Token Resolution (MUST do before first API call) Run this bash snippet to resolve the token. It checks multiple sources automatically: ```bash # 1. Environment variable TOKEN="${GANGTISE_TOKEN:-}" # 2. .env in current directory if [ -z "$TOKEN" ] && [ -f .env ]; then TOKEN=$(grep -E '^GANGTISE_TOKEN=' .env | cut -d= -f2- | tr -d '"'"'"' ') fi # 3. ~/.env global dotenv if [ -z "$TOKEN" ] && [ -f ~/.env ]; then TOKEN=$(grep -E '^GANGTISE_TOKEN=' ~/.env | cut -d= -f2- | tr -d '"'"'"' ') fi ``` **If `$TOKEN` is still empty after the above**, use `AskUserQuestion` to ask: > "Gangtise API 需要 Bearer Token 才能调用。请提供 token,或者告诉我 .env 文件路径。" Once obtained, export it for the rest of the session: ```bash export GANGTISE_TOKEN="" ``` ### Verify Connection ```bash curl -s -o /dev/null -w "%{http_code}" http://39.96.218.64:8009/api/docs \ -H "Authorization: Bearer $TOKEN" # 200 = OK, 401 = token invalid ``` ## API Quick Reference | Endpoint | Method | Response | Use Case | |----------|--------|----------|----------| | `/api/search` | POST | JSON | 搜索研报/公告/纪要 | | `/api/search/batch` | POST | JSON | 批量搜索多个主题 | | `/api/ai/chat` | POST | JSON/SSE | AI 深度研究(支持3种返回模式) | | `/api/ai/chat/create-group` | GET | JSON | 创建会话(用于多轮对话) | | `/api/ai/indicator` | POST | JSON | 经济/行业指标数据查询 | | `/api/docs` | GET | JSON | 完整接口文档 | ## 1. Knowledge Search — `/api/search` Search broker reports, analyst opinions, company filings, meeting minutes. ```bash curl -s http://39.96.218.64:8009/api/search \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "query": "比亚迪", "top": 10, "time_range": "1m", "resource_types": ["BROKER_REPORT"] }' ``` **Parameters:** - `query` (required): Search keywords - `top`: 1-20, default 10 - `time_range`: `1d` `1w` `1m` `1q` `6m` `1y` `all` (default `1m`) - `resource_types`: Filter array, options: - `BROKER_REPORT` — 券商研报 - `INTERNAL_REPORT` — 内部研报 - `ANALYST_OPINION` — 首席观点 - `COMPANY_NOTICE` — 公司公告 - `MEETING_MINUTES` — 会议纪要 - `SURVEY_NOTES` — 调研纪要 - `WEB_RESOURCE` — 网络资源 - `INDUSTRY_OFFICIAL` — 产业公众号 **Response:** `{query, total, time_range, results: [{title, source, date, company, content, source_url, source_id}]}` Each result includes `source_url` for citation. Use `[[n]](source_url)` format in replies. ## 2. Batch Search — `/api/search/batch` Search multiple topics at once (max 5). ```bash curl -s http://39.96.218.64:8009/api/search/batch \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "queries": ["比亚迪", "宁德时代", "特斯拉"], "top": 5, "time_range": "1m" }' ``` **Response:** `{total_queries, time_range, responses: [{query, total, results}]}` ## 3. Agent Deep Research — `/api/ai/chat` AI-powered deep analysis with multi-round thinking. Supports 3 return modes. **Response takes 30-120 seconds.** Use `stream="progress"` mode for best LLM experience. ### Recommended: Progress Mode (for LLM/Agent) Returns lightweight SSE progress events during thinking, then final JSON result: ```bash curl -s -N http://39.96.218.64:8009/api/ai/chat \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "query": "比亚迪的投资逻辑", "forced_agent": "investment_logic", "stream": "progress", "thinking_detail": "summary" }' --max-time 200 ``` Progress events arrive during processing, final result at end: ``` event: progress data: {"phase":"think","round":1,"title":"识别问题","seq":1} event: progress data: {"phase":"answer","status":"generating"} event: result data: {"query":"...","answer":"...","thinking":[...],"usage":{"thinking_rounds":4,"answer_length":5041}} ``` To extract the final JSON result from progress mode: ```bash curl -s -N ... --max-time 200 | grep '^data:' | tail -1 | sed 's/^data: //' | python3 -m json.tool ``` ### JSON Mode (simple, blocking) Wait for complete result as pure JSON (no streaming): ```bash curl -s http://39.96.218.64:8009/api/ai/chat \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "query": "比亚迪的投资逻辑", "forced_agent": "investment_logic", "stream": false, "include_thinking": true, "thinking_detail": "summary" }' --max-time 200 ``` **Response:** `{query, group_id, answer, thinking, usage: {thinking_rounds, answer_length}}` ### Raw SSE Mode (for frontend streaming) ```bash curl -s -N http://39.96.218.64:8009/api/ai/chat \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"query": "比亚迪的投资逻辑", "forced_agent": "investment_logic", "stream": true}' ``` ### Parameters - `query` (required): Research question - `stream`: Return mode — `true` (raw SSE, default), `false` (JSON), `"progress"` (SSE progress + JSON result) - `forced_agent`: Force a specific agent (default: auto-select). See **Agent Selection Guide** above for routing logic. - `include_thinking`: Include thinking rounds in response (default true, only for non-raw modes) - `thinking_detail`: `"full"` (default) or `"summary"` (titles only, saves tokens) - `group_id`: Pass to maintain conversation context - `include_search_types`: Filter sources `[10,20,40,50,60,70,80,90]` - `web_enable`: Enable web search (default false) ## 4. Create Chat Group — `/api/ai/chat/create-group` Create a session for multi-turn agent conversations. ```bash curl -s http://39.96.218.64:8009/api/ai/chat/create-group \ -H "Authorization: Bearer $TOKEN" ``` **Response:** `{"group_id": 12345}` Pass `group_id` to subsequent `/api/ai/chat` calls for context continuity. ## 5. Indicator Query — `/api/ai/indicator` Query macroeconomic data, industry statistics, company operating metrics. ```bash curl -s http://39.96.218.64:8009/api/ai/indicator \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"query": "比亚迪仰望销量"}' ``` **Response:** `{reasoning_content: "...", content: "..."}` - `reasoning_content`: Data retrieval process - `content`: Final result (often markdown tables) **Good queries:** Company sales, GDP, CPI, PMI, battery installations, EV penetration, commodity prices. ## Agent Selection Guide Match user intent to the right agent. **If uncertain, omit `forced_agent` — the upstream AI will auto-select.** | User Intent (keywords) | `forced_agent` | What it does | |---|---|---| | 投资逻辑、买入/卖出理由、多空分析、估值 | `investment_logic` | 梳理公司核心投资逻辑,分析多空因素 | | 产业链、上下游、竞争格局、行业分析 | `industry_expert` | 拆解产业链结构,分析竞争格局和趋势 | | 调研提纲、调研问题、尽调清单 | `investigation_outline` | 生成结构化调研问题清单 | | 晨报、今日主题、板块速览、每日简报 | `theme_daily_report` | 生成主题/板块晨间简报 | | 查找、搜索、最新研报、有什么消息 | `searcher` | 通用信息检索,适合开放性问题 | | 销量、GDP、CPI、产量等具体数字 | *(use `/api/ai/indicator` instead)* | — | **Routing decision tree:** 1. User asks for **specific numbers/data** → `/api/ai/indicator` (not agent chat) 2. User asks for **latest reports/news** on a topic → `/api/search` or `searcher` 3. User asks **"why invest in X"** / **"X的投资逻辑"** → `investment_logic` 4. User asks about **supply chain / industry structure** → `industry_expert` 5. User asks to **prepare for a company visit** → `investigation_outline` 6. User asks for a **morning briefing / theme summary** → `theme_daily_report` 7. **Unclear** → omit `forced_agent`, let upstream auto-select ## Workflow Patterns ### Pattern A: Quick Research User asks about a company or topic → `/api/search` with relevant keywords → Synthesize results with citations. ### Pattern B: Deep Analysis (with agent routing) User wants deep analysis → Select `forced_agent` per Agent Selection Guide above → `/api/ai/chat` with `stream="progress"` → Present the final answer from `event: result`. Example: "分析宁德时代的产业链" → `forced_agent: "industry_expert"` Example: "比亚迪值得买吗" → `forced_agent: "investment_logic"` Example: "帮我准备一份调研小鹏汽车的提纲" → `forced_agent: "investigation_outline"` ### Pattern C: Data Query User asks for specific metrics (sales, GDP, production) → `/api/ai/indicator` → Present the data table. Do NOT use agent chat for pure data queries. ### Pattern D: Comparative Research User wants to compare multiple companies → `/api/search/batch` with company names → Cross-reference results. ### Pattern E: Multi-Turn Research Create group → ask initial question → follow up with `group_id` for contextual conversation. ### Pattern F: Combined Research Complex questions often need multiple API calls: 1. `/api/ai/indicator` for hard data (sales, financials) 2. `/api/ai/chat` with `investment_logic` for qualitative analysis 3. `/api/search` for latest broker reports as supporting evidence Synthesize all three into a comprehensive answer with citations. ## Citation Format When presenting search results, use this citation format: **In text:** `比亚迪1月出口增45% [[1]](source_url)` **At end:** ``` ## 参考来源 [1] 券商研报《标题》(日期) [查看原文](source_url) ``` ## Common Mistakes | Mistake | Fix | |---------|-----| | Forgetting Bearer token | Always include `Authorization: Bearer $TOKEN` | | Using `stream=true` (raw SSE) for LLM | Use `stream="progress"` or `stream=false` instead | | Setting short timeout for agent_chat | Allow 200s+ (`--max-time 200`) for deep research | | Not passing `group_id` for follow-ups | Create group first, reuse ID | | Searching with overly broad queries | Be specific: company name + topic | | Including full thinking in responses | Use `thinking_detail="summary"` to save tokens |