Cogmate Client
Connect to Cogmate instances for knowledge retrieval and Q&A.
Prerequisites
- - Valid access token (obtain from CogNexus or instance owner)
- Cogmate API endpoint URL
Quick Start
Ask a Question
CODEBLOCK0
Semantic Search
CODEBLOCK1
API Reference
Authentication
All protected endpoints require token as query parameter (not JSON body).
Endpoints
| Endpoint | Method | Description |
|---|
| INLINECODE1 | POST | Ask questions, get AI-powered answers |
| INLINECODE2 |
GET | Browse/search knowledge facts |
|
/api/visual/stats | GET | Get knowledge base statistics |
|
/api/visual/graph | GET | Get knowledge graph data |
|
/api/hub/profile | GET | Get Cogmate profile (public) |
POST /api/ask?token=YOUR_TOKEN
Ask a question against the knowledge base.
Request:
CODEBLOCK2
Response:
CODEBLOCK3
GET /api/visual/facts
Browse or search facts.
Parameters:
- -
token (required): Access token - INLINECODE7 (optional): Search query
- INLINECODE8 (optional): Filter by layer (fact/connection/abstract)
GET /api/visual/stats
Get statistics about the knowledge base.
Response:
CODEBLOCK4
Token Permissions
| Scope | Capabilities |
|---|
| INLINECODE9 | Complete access: browse, ask, view private |
| INLINECODE10 |
Q&A only (may have usage limits) |
|
browse_public | Browse public facts only |
Helper Scripts
Ask Question
CODEBLOCK5
Search Knowledge
CODEBLOCK6
Getting Access
- 1. Visit the Cogmate owner's CogNexus marketplace listing
- Purchase a token with ATP (platform credits)
- Use the token to access the Cogmate API
Error Handling
| Status | Meaning |
|---|
| 401 | Invalid or expired token |
| 403 |
Insufficient permissions |
| 429 | Rate limit exceeded |
| 500 | Server error |
Example Workflow
CODEBLOCK7
技能名称: cogmate-client
详细描述:
Cogmate 客户端
连接至 Cogmate 实例,用于知识检索与问答。
前置条件
- - 有效的访问令牌(从 CogNexus 或实例所有者处获取)
- Cogmate API 端点 URL
快速开始
提问
bash
curl -X POST http://{COGMATEURL}/api/ask?token=YOURTOKEN \
-H Content-Type: application/json \
-d {question: 你的问题}
语义搜索
bash
curl http://{COGMATEURL}/api/visual/facts?token=YOURTOKEN&search=关键词
API 参考
身份验证
所有受保护的端点均需将 token 作为查询参数(而非 JSON 请求体)传递。
端点
| 端点 | 方法 | 描述 |
|---|
| /api/ask | POST | 提问,获取基于 AI 的答案 |
| /api/visual/facts |
GET | 浏览/搜索知识事实 |
| /api/visual/stats | GET | 获取知识库统计信息 |
| /api/visual/graph | GET | 获取知识图谱数据 |
| /api/hub/profile | GET | 获取 Cogmate 配置文件(公开) |
POST /api/ask?token=YOUR_TOKEN
针对知识库提问。
请求:
json
{
question: 关于 X 你知道些什么?
}
响应:
json
{
answer: 根据知识库...,
sources: [{id: fact_xxx, summary: ...}]
}
GET /api/visual/facts
浏览或搜索事实。
参数:
- - token(必填):访问令牌
- search(可选):搜索查询
- layer(可选):按层级过滤(事实/关联/摘要)
GET /api/visual/stats
获取知识库统计信息。
响应:
json
{
facts: 87,
connections: 45,
abstracts: 12
}
令牌权限
| 范围 | 能力 |
|---|
| full | 完全访问:浏览、提问、查看私有内容 |
| qa_public |
仅限问答(可能有使用限制) |
| browse_public | 仅浏览公开事实 |
辅助脚本
提问
bash
./scripts/ask.sh 你的问题
搜索知识
bash
./scripts/search.sh 搜索词
获取访问权限
- 1. 访问 Cogmate 所有者的 CogNexus 市场列表
- 使用 ATP(平台积分)购买令牌
- 使用令牌访问 Cogmate API
错误处理
权限不足 |
| 429 | 超出速率限制 |
| 500 | 服务器错误 |
示例工作流
python
import requests
COGMATE_URL = http://example.com:8000
TOKEN = yourtokenhere
提问(令牌在查询参数中,问题在请求体中)
response = requests.post(
f{COGMATE_URL}/api/ask,
params={token: TOKEN},
json={question: 关于 X 的关键见解是什么?}
)
print(response.json()[answer])
搜索事实
facts = requests.get(
f{COGMATE_URL}/api/visual/facts,
params={token: TOKEN, search: 关键词}
).json()
for fact in facts.get(facts, []):
print(f- {fact[summary]})