ckg-ai-platforms 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ckg_ai_platforms-0.1.0/.gitignore +6 -0
- ckg_ai_platforms-0.1.0/PKG-INFO +82 -0
- ckg_ai_platforms-0.1.0/README.md +61 -0
- ckg_ai_platforms-0.1.0/pyproject.toml +34 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/__init__.py +16 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/__main__.py +4 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/domains/anthropic-sdk.csv +45 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/domains/aws-bedrock.csv +47 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/domains/huggingface.csv +47 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/domains/langchain.csv +49 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/domains/langgraph.csv +43 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/domains/metadata.json +37 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/domains/openai-api.csv +44 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/domains/vertex-ai.csv +46 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/graph.py +106 -0
- ckg_ai_platforms-0.1.0/src/ckg_ai_platforms/server.py +211 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ckg-ai-platforms
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AI developer platforms as traversable knowledge graphs — LangChain, LangGraph, OpenAI, Anthropic, HuggingFace, AWS Bedrock, Vertex AI — MCP-native
|
|
5
|
+
Project-URL: Homepage, https://graphifymd.com
|
|
6
|
+
Project-URL: Repository, https://github.com/Yarmoluk/ckg-ai-platforms
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/Yarmoluk/ckg-ai-platforms/issues
|
|
8
|
+
Author-email: Daniel Yarmoluk <daniel.yarmoluk@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: ai-agents,anthropic,bedrock,huggingface,knowledge-graph,langchain,mcp,openai,vertex-ai
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Requires-Dist: mcp[cli]>=1.0.0
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# ckg-ai-platforms
|
|
23
|
+
|
|
24
|
+
AI developer platforms as traversable knowledge graphs — MCP-native.
|
|
25
|
+
|
|
26
|
+
**7 domains · 314 nodes · 445 edges · 11× fewer tokens than RAG**
|
|
27
|
+
|
|
28
|
+
| Domain | Nodes | Edges | Coverage |
|
|
29
|
+
|---|---|---|---|
|
|
30
|
+
| langchain | 48 | 71 | Chains, agents, LCEL, memory, retrievers, LangSmith |
|
|
31
|
+
| langgraph | 42 | 58 | Graph state, nodes, edges, cycles, persistence |
|
|
32
|
+
| openai-api | 43 | 59 | Chat completions, assistants, embeddings, DALL-E |
|
|
33
|
+
| anthropic-sdk | 44 | 62 | Messages API, tool use, prompt caching, computer use |
|
|
34
|
+
| huggingface | 46 | 65 | Hub, Transformers, Spaces, Datasets, Inference API |
|
|
35
|
+
| aws-bedrock | 46 | 67 | Converse API, Guardrails, Knowledge Bases, agents |
|
|
36
|
+
| vertex-ai | 45 | 63 | Model Garden, Gemini API, evaluation, fine-tuning |
|
|
37
|
+
|
|
38
|
+
## Install
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install ckg-ai-platforms
|
|
42
|
+
uvx ckg-ai-platforms # MCP server
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Use as MCP server
|
|
46
|
+
|
|
47
|
+
Add to your Claude Desktop or any MCP client:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"mcpServers": {
|
|
52
|
+
"ai-platforms": {
|
|
53
|
+
"command": "uvx",
|
|
54
|
+
"args": ["ckg-ai-platforms"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Use as Python library
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from ckg_ai_platforms import ask_platform, list_domains
|
|
64
|
+
|
|
65
|
+
# Ask a question — auto-detects platform
|
|
66
|
+
result = ask_platform("How does LCEL RunnableSequence work?")
|
|
67
|
+
print(result)
|
|
68
|
+
|
|
69
|
+
# Explicit domain
|
|
70
|
+
result = ask_platform("explain tool use", domain="anthropic-sdk")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Benchmark
|
|
74
|
+
|
|
75
|
+
Part of the [CKG benchmark](https://github.com/Yarmoluk/ckg-benchmark/blob/main/paper/main.pdf):
|
|
76
|
+
- F1: 0.471 vs RAG 0.123 (3.8×)
|
|
77
|
+
- Tokens/query: 269 vs 2,982 (11×)
|
|
78
|
+
- Cost/correct answer: $7.81 vs $76.23
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT · [graphifymd.com](https://graphifymd.com)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# ckg-ai-platforms
|
|
2
|
+
|
|
3
|
+
AI developer platforms as traversable knowledge graphs — MCP-native.
|
|
4
|
+
|
|
5
|
+
**7 domains · 314 nodes · 445 edges · 11× fewer tokens than RAG**
|
|
6
|
+
|
|
7
|
+
| Domain | Nodes | Edges | Coverage |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| langchain | 48 | 71 | Chains, agents, LCEL, memory, retrievers, LangSmith |
|
|
10
|
+
| langgraph | 42 | 58 | Graph state, nodes, edges, cycles, persistence |
|
|
11
|
+
| openai-api | 43 | 59 | Chat completions, assistants, embeddings, DALL-E |
|
|
12
|
+
| anthropic-sdk | 44 | 62 | Messages API, tool use, prompt caching, computer use |
|
|
13
|
+
| huggingface | 46 | 65 | Hub, Transformers, Spaces, Datasets, Inference API |
|
|
14
|
+
| aws-bedrock | 46 | 67 | Converse API, Guardrails, Knowledge Bases, agents |
|
|
15
|
+
| vertex-ai | 45 | 63 | Model Garden, Gemini API, evaluation, fine-tuning |
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install ckg-ai-platforms
|
|
21
|
+
uvx ckg-ai-platforms # MCP server
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Use as MCP server
|
|
25
|
+
|
|
26
|
+
Add to your Claude Desktop or any MCP client:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"mcpServers": {
|
|
31
|
+
"ai-platforms": {
|
|
32
|
+
"command": "uvx",
|
|
33
|
+
"args": ["ckg-ai-platforms"]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Use as Python library
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from ckg_ai_platforms import ask_platform, list_domains
|
|
43
|
+
|
|
44
|
+
# Ask a question — auto-detects platform
|
|
45
|
+
result = ask_platform("How does LCEL RunnableSequence work?")
|
|
46
|
+
print(result)
|
|
47
|
+
|
|
48
|
+
# Explicit domain
|
|
49
|
+
result = ask_platform("explain tool use", domain="anthropic-sdk")
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Benchmark
|
|
53
|
+
|
|
54
|
+
Part of the [CKG benchmark](https://github.com/Yarmoluk/ckg-benchmark/blob/main/paper/main.pdf):
|
|
55
|
+
- F1: 0.471 vs RAG 0.123 (3.8×)
|
|
56
|
+
- Tokens/query: 269 vs 2,982 (11×)
|
|
57
|
+
- Cost/correct answer: $7.81 vs $76.23
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT · [graphifymd.com](https://graphifymd.com)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ckg-ai-platforms"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "AI developer platforms as traversable knowledge graphs — LangChain, LangGraph, OpenAI, Anthropic, HuggingFace, AWS Bedrock, Vertex AI — MCP-native"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
authors = [{ name = "Daniel Yarmoluk", email = "daniel.yarmoluk@gmail.com" }]
|
|
12
|
+
keywords = ["langchain", "openai", "anthropic", "knowledge-graph", "mcp", "ai-agents", "huggingface", "bedrock", "vertex-ai"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
21
|
+
]
|
|
22
|
+
requires-python = ">=3.11"
|
|
23
|
+
dependencies = ["mcp[cli]>=1.0.0"]
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
ckg-ai-platforms = "ckg_ai_platforms.server:main"
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://graphifymd.com"
|
|
30
|
+
Repository = "https://github.com/Yarmoluk/ckg-ai-platforms"
|
|
31
|
+
"Bug Tracker" = "https://github.com/Yarmoluk/ckg-ai-platforms/issues"
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.wheel]
|
|
34
|
+
packages = ["src/ckg_ai_platforms"]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"""ckg-ai-platforms — AI developer platforms as traversable knowledge graphs."""
|
|
2
|
+
__version__ = "0.1.0"
|
|
3
|
+
|
|
4
|
+
from ckg_ai_platforms.server import ( # noqa: F401
|
|
5
|
+
ask_platform,
|
|
6
|
+
list_domains,
|
|
7
|
+
search_concepts,
|
|
8
|
+
query_ckg,
|
|
9
|
+
get_prerequisites,
|
|
10
|
+
)
|
|
11
|
+
from ckg_ai_platforms.graph import ( # noqa: F401
|
|
12
|
+
available_domains,
|
|
13
|
+
load_graph,
|
|
14
|
+
find_concept,
|
|
15
|
+
prerequisite_chain,
|
|
16
|
+
)
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
ConceptID,ConceptLabel,Dependencies,TaxonomyID
|
|
2
|
+
1,Anthropic SDK,,Platform
|
|
3
|
+
2,Anthropic Client,1,Core
|
|
4
|
+
3,AsyncAnthropic Client,1,Core
|
|
5
|
+
4,Messages API,2,Core
|
|
6
|
+
5,system message,4,Message
|
|
7
|
+
6,user message,4,Message
|
|
8
|
+
7,assistant message,4,Message
|
|
9
|
+
8,content block,4,Message
|
|
10
|
+
9,tool_use block,8,Tool
|
|
11
|
+
10,tool_result block,9,Tool
|
|
12
|
+
11,tool definition,4,Tool
|
|
13
|
+
12,input_schema,11,Tool
|
|
14
|
+
13,computer_use tool,9,Tool
|
|
15
|
+
14,bash_tool,9,Tool
|
|
16
|
+
15,text_editor_tool,9,Tool
|
|
17
|
+
16,tool_choice,11,Tool
|
|
18
|
+
17,Extended Thinking,4,Reasoning
|
|
19
|
+
18,thinking block,17,Reasoning
|
|
20
|
+
19,budget_tokens,17,Reasoning
|
|
21
|
+
20,redacted_thinking,17,Reasoning
|
|
22
|
+
21,Prompt Caching,4,Efficiency
|
|
23
|
+
22,cache_control ephemeral,21,Efficiency
|
|
24
|
+
23,cache_control persistent,21,Efficiency
|
|
25
|
+
24,cache_read_input_tokens,21,Efficiency
|
|
26
|
+
25,Streaming,4,Streaming
|
|
27
|
+
26,stream context manager,25,Streaming
|
|
28
|
+
27,on_message handler,25,Streaming
|
|
29
|
+
28,on_content_block_delta,25,Streaming
|
|
30
|
+
29,Message Batches API,1,Batching
|
|
31
|
+
30,batch request,29,Batching
|
|
32
|
+
31,batch result,29,Batching
|
|
33
|
+
32,Files API,1,Files
|
|
34
|
+
33,file upload,32,Files
|
|
35
|
+
34,file reference,33,Files
|
|
36
|
+
35,Token Counting,4,Efficiency
|
|
37
|
+
36,count_tokens,35,Efficiency
|
|
38
|
+
37,claude-opus-4,1,Model
|
|
39
|
+
38,claude-sonnet-5,1,Model
|
|
40
|
+
39,claude-haiku-4-5,1,Model
|
|
41
|
+
40,MCPServerStdio,1,MCP
|
|
42
|
+
41,MCPServerSSE,40,MCP
|
|
43
|
+
42,RateLimitError,2,ErrorHandling
|
|
44
|
+
43,APIStatusError,42,ErrorHandling
|
|
45
|
+
44,retry with backoff,42,ErrorHandling
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
ConceptID,ConceptLabel,Dependencies,TaxonomyID
|
|
2
|
+
1,AWS Bedrock,,Platform
|
|
3
|
+
2,Model Access,1,Foundation
|
|
4
|
+
3,Anthropic Claude,2,Foundation
|
|
5
|
+
4,Amazon Titan,2,Foundation
|
|
6
|
+
5,Meta Llama,2,Foundation
|
|
7
|
+
6,Mistral AI,2,Foundation
|
|
8
|
+
7,Cohere Command,2,Foundation
|
|
9
|
+
8,Stability AI,2,Foundation
|
|
10
|
+
9,InvokeModel API,1,Inference
|
|
11
|
+
10,Converse API,9,Inference
|
|
12
|
+
11,InvokeModelWithResponseStream,9,Inference
|
|
13
|
+
12,ConverseStream,10|11,Inference
|
|
14
|
+
13,Titan Embeddings,4,Embedding
|
|
15
|
+
14,Cohere Embed,7,Embedding
|
|
16
|
+
15,Knowledge Base,1,RAG
|
|
17
|
+
16,Vector Store,15,RAG
|
|
18
|
+
17,OpenSearch Serverless,16,RAG
|
|
19
|
+
18,Aurora PostgreSQL,16,RAG
|
|
20
|
+
19,Pinecone,16,RAG
|
|
21
|
+
20,RetrieveAndGenerate API,15,RAG
|
|
22
|
+
21,Bedrock Agent,1,Agent
|
|
23
|
+
22,Action Group,21,Agent
|
|
24
|
+
23,Lambda Function,22,Agent
|
|
25
|
+
24,Agent Alias,21,Agent
|
|
26
|
+
25,Orchestration Strategy,21,Agent
|
|
27
|
+
26,Return of Control,21|22,Agent
|
|
28
|
+
27,Guardrail,1,Safety
|
|
29
|
+
28,Content Filter,27,Safety
|
|
30
|
+
29,Topic Filter,27,Safety
|
|
31
|
+
30,PII Redaction,27,Safety
|
|
32
|
+
31,Grounding Check,27,Safety
|
|
33
|
+
32,Word Filter,27,Safety
|
|
34
|
+
33,Fine-tuning Job,1,Training
|
|
35
|
+
34,Training Data S3,33,Training
|
|
36
|
+
35,Continued Pre-training,33,Training
|
|
37
|
+
36,Model Customization,33|35,Training
|
|
38
|
+
37,Model Evaluation,1,Evaluation
|
|
39
|
+
38,LLM-as-Judge,37,Evaluation
|
|
40
|
+
39,Human Evaluation,37,Evaluation
|
|
41
|
+
40,Prompt Management,1,Prompt
|
|
42
|
+
41,Prompt Version,40,Prompt
|
|
43
|
+
42,Prompt Flow,40,Prompt
|
|
44
|
+
43,VPC Endpoint,1,Security
|
|
45
|
+
44,KMS Encryption,1,Security
|
|
46
|
+
45,IAM Role,1,Security
|
|
47
|
+
46,CloudTrail Logging,1,Security
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
ConceptID,ConceptLabel,Dependencies,TaxonomyID
|
|
2
|
+
1,HuggingFace Hub,,Platform
|
|
3
|
+
2,Model Hub,1,Hub
|
|
4
|
+
3,Dataset Hub,1,Hub
|
|
5
|
+
4,Space Hub,1,Hub
|
|
6
|
+
5,Model Card,2,Hub
|
|
7
|
+
6,LFS Large File Storage,2,Hub
|
|
8
|
+
7,AutoModel,2,Transformers
|
|
9
|
+
8,AutoTokenizer,2,Transformers
|
|
10
|
+
9,pipeline API,7|8,Transformers
|
|
11
|
+
10,Trainer,7,Transformers
|
|
12
|
+
11,TrainingArguments,10,Transformers
|
|
13
|
+
12,BPE Tokenizer,8,Tokenizer
|
|
14
|
+
13,WordPiece Tokenizer,8,Tokenizer
|
|
15
|
+
14,SentencePiece,8,Tokenizer
|
|
16
|
+
15,Fast Tokenizer,8|12,Tokenizer
|
|
17
|
+
16,LoRA,7,PEFT
|
|
18
|
+
17,QLoRA,16,PEFT
|
|
19
|
+
18,PromptTuning,7,PEFT
|
|
20
|
+
19,IA3,7,PEFT
|
|
21
|
+
20,AdaLoRA,16,PEFT
|
|
22
|
+
21,PeftModel,16|17,PEFT
|
|
23
|
+
22,SFTTrainer,10,TRL
|
|
24
|
+
23,DPOTrainer,10,TRL
|
|
25
|
+
24,PPOTrainer,10,TRL
|
|
26
|
+
25,RewardTrainer,10,TRL
|
|
27
|
+
26,InferenceClient,1,Inference
|
|
28
|
+
27,InferenceEndpoint,26,Inference
|
|
29
|
+
28,Serverless Inference API,26,Inference
|
|
30
|
+
29,load_dataset,3,Dataset
|
|
31
|
+
30,DatasetDict,29,Dataset
|
|
32
|
+
31,dataset map,29,Dataset
|
|
33
|
+
32,dataset filter,29,Dataset
|
|
34
|
+
33,evaluate library,1,Evaluation
|
|
35
|
+
34,metric,33,Evaluation
|
|
36
|
+
35,EvaluationSuite,33,Evaluation
|
|
37
|
+
36,DiffusionPipeline,1,Diffusers
|
|
38
|
+
37,StableDiffusionPipeline,36,Diffusers
|
|
39
|
+
38,Accelerator,1,Accelerate
|
|
40
|
+
39,distributed training,38|10,Accelerate
|
|
41
|
+
40,GGUF format,2,Quantization
|
|
42
|
+
41,GGML format,40,Quantization
|
|
43
|
+
42,llama.cpp integration,41,Quantization
|
|
44
|
+
43,bitsandbytes,17,Quantization
|
|
45
|
+
44,Gradio Blocks,4,Demo
|
|
46
|
+
45,Gradio Interface,44,Demo
|
|
47
|
+
46,ChatInterface,44,Demo
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
ConceptID,ConceptLabel,Dependencies,TaxonomyID
|
|
2
|
+
1,LangChain Framework,,Platform
|
|
3
|
+
2,LangChain Core,1,Library
|
|
4
|
+
3,LangChain Community,1,Library
|
|
5
|
+
4,LangChain CLI,1,Tool
|
|
6
|
+
5,LangSmith,1,Observability
|
|
7
|
+
6,LangChain Hub,1,Registry
|
|
8
|
+
7,ChatPromptTemplate,2,Prompt
|
|
9
|
+
8,PromptTemplate,2,Prompt
|
|
10
|
+
9,MessagesPlaceholder,7,Prompt
|
|
11
|
+
10,BaseLLM,2,Model
|
|
12
|
+
11,ChatOpenAI,10,Model
|
|
13
|
+
12,ChatAnthropic,10,Model
|
|
14
|
+
13,Ollama,10,Model
|
|
15
|
+
14,LCEL RunnableSequence,2,Orchestration
|
|
16
|
+
15,RunnableParallel,14,Orchestration
|
|
17
|
+
16,RunnablePassthrough,14,Orchestration
|
|
18
|
+
17,RunnableLambda,14,Orchestration
|
|
19
|
+
18,LLMChain,10|8,Chain
|
|
20
|
+
19,SequentialChain,18,Chain
|
|
21
|
+
20,RouterChain,18,Chain
|
|
22
|
+
21,AgentExecutor,2,Agent
|
|
23
|
+
22,ReAct Agent,21,Agent
|
|
24
|
+
23,Tool-Calling Agent,21,Agent
|
|
25
|
+
24,OpenAI Functions Agent,21,Agent
|
|
26
|
+
25,BaseTool,2,Tool
|
|
27
|
+
26,StructuredTool,25,Tool
|
|
28
|
+
27,tool decorator,25,Tool
|
|
29
|
+
28,Toolkit,25,Tool
|
|
30
|
+
29,ConversationBufferMemory,2,Memory
|
|
31
|
+
30,ConversationSummaryMemory,29|10,Memory
|
|
32
|
+
31,VectorStoreMemory,29,Memory
|
|
33
|
+
32,BaseRetriever,2,Retrieval
|
|
34
|
+
33,VectorStoreRetriever,32,Retrieval
|
|
35
|
+
34,MultiQueryRetriever,32|10,Retrieval
|
|
36
|
+
35,ContextualCompressionRetriever,32,Retrieval
|
|
37
|
+
36,ParentDocumentRetriever,32,Retrieval
|
|
38
|
+
37,EnsembleRetriever,32,Retrieval
|
|
39
|
+
38,BaseDocumentLoader,2,Loader
|
|
40
|
+
39,WebBaseLoader,38,Loader
|
|
41
|
+
40,PyPDFLoader,38,Loader
|
|
42
|
+
41,UnstructuredLoader,38,Loader
|
|
43
|
+
42,RecursiveCharacterTextSplitter,2,Splitter
|
|
44
|
+
43,TokenTextSplitter,42,Splitter
|
|
45
|
+
44,OpenAIEmbeddings,2,Embedding
|
|
46
|
+
45,HuggingFaceEmbeddings,2,Embedding
|
|
47
|
+
46,FAISS,33,VectorStore
|
|
48
|
+
47,Chroma,33,VectorStore
|
|
49
|
+
48,CallbackManager,5,Observability
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
ConceptID,ConceptLabel,Dependencies,TaxonomyID
|
|
2
|
+
1,LangGraph Framework,,Platform
|
|
3
|
+
2,StateGraph,1,Core
|
|
4
|
+
3,CompiledGraph,2,Core
|
|
5
|
+
4,Node,2,Core
|
|
6
|
+
5,Edge,2,Core
|
|
7
|
+
6,Conditional Edge,5,Core
|
|
8
|
+
7,AgentState,2,State
|
|
9
|
+
8,TypedDict,7,State
|
|
10
|
+
9,Annotated Reducer,7|8,State
|
|
11
|
+
10,MessagesState,7,State
|
|
12
|
+
11,START,2,Control
|
|
13
|
+
12,END,2,Control
|
|
14
|
+
13,Branch,6|2,Control
|
|
15
|
+
14,Router Node,4|13,Control
|
|
16
|
+
15,MemorySaver,2,Persistence
|
|
17
|
+
16,SqliteSaver,15,Persistence
|
|
18
|
+
17,PostgresSaver,15,Persistence
|
|
19
|
+
18,AsyncSqliteSaver,15,Persistence
|
|
20
|
+
19,Checkpointer,15,Persistence
|
|
21
|
+
20,thread_id,19,Persistence
|
|
22
|
+
21,interrupt,2,HumanInLoop
|
|
23
|
+
22,Command,21,HumanInLoop
|
|
24
|
+
23,HumanMessage,21,HumanInLoop
|
|
25
|
+
24,approve/reject pattern,21|22,HumanInLoop
|
|
26
|
+
25,stream,3,Streaming
|
|
27
|
+
26,astream,25,Streaming
|
|
28
|
+
27,stream_events,25,Streaming
|
|
29
|
+
28,stream_mode,25,Streaming
|
|
30
|
+
29,create_react_agent,1,Prebuilt
|
|
31
|
+
30,ToolNode,4|29,Prebuilt
|
|
32
|
+
31,tools_condition,6|29,Prebuilt
|
|
33
|
+
32,Supervisor Agent,4,MultiAgent
|
|
34
|
+
33,Worker Agent,4|32,MultiAgent
|
|
35
|
+
34,Handoff,5|32,MultiAgent
|
|
36
|
+
35,Subgraph,2|3,MultiAgent
|
|
37
|
+
36,add_node subgraph,35|2,MultiAgent
|
|
38
|
+
37,LangSmith Trace,3,Observability
|
|
39
|
+
38,LangSmith Evaluate,37,Observability
|
|
40
|
+
39,LangSmith Dataset,38,Observability
|
|
41
|
+
40,recursion_limit,3,Config
|
|
42
|
+
41,config_schema,3,Config
|
|
43
|
+
42,RunnableConfig,41,Config
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"langchain": {
|
|
3
|
+
"nodes": 48,
|
|
4
|
+
"edges": 71,
|
|
5
|
+
"description": "LangChain ecosystem \u2014 chains, agents, memory, retrieval, LCEL, tools, and LangSmith"
|
|
6
|
+
},
|
|
7
|
+
"langgraph": {
|
|
8
|
+
"nodes": 42,
|
|
9
|
+
"edges": 58,
|
|
10
|
+
"description": "LangGraph agent framework \u2014 stateful graphs, persistence, human-in-the-loop, multi-agent"
|
|
11
|
+
},
|
|
12
|
+
"aws-bedrock": {
|
|
13
|
+
"nodes": 46,
|
|
14
|
+
"edges": 67,
|
|
15
|
+
"description": "AWS Bedrock enterprise AI \u2014 foundation models, agents, knowledge bases, guardrails, fine-tuning"
|
|
16
|
+
},
|
|
17
|
+
"anthropic-sdk": {
|
|
18
|
+
"nodes": 44,
|
|
19
|
+
"edges": 62,
|
|
20
|
+
"description": "Anthropic Claude API and SDK \u2014 messages, tools, extended thinking, prompt caching, MCP, batching"
|
|
21
|
+
},
|
|
22
|
+
"huggingface": {
|
|
23
|
+
"nodes": 46,
|
|
24
|
+
"edges": 65,
|
|
25
|
+
"description": "HuggingFace ecosystem \u2014 Hub, Transformers, PEFT/LoRA, TRL, Inference, Datasets, Gradio"
|
|
26
|
+
},
|
|
27
|
+
"openai-api": {
|
|
28
|
+
"nodes": 43,
|
|
29
|
+
"edges": 59,
|
|
30
|
+
"description": "OpenAI API ecosystem \u2014 chat completions, tools, structured outputs, assistants, fine-tuning, batch"
|
|
31
|
+
},
|
|
32
|
+
"vertex-ai": {
|
|
33
|
+
"nodes": 45,
|
|
34
|
+
"edges": 63,
|
|
35
|
+
"description": "Google Vertex AI \u2014 Gemini, generative AI, Agent Builder, Vector Search, pipelines, MLOps"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
ConceptID,ConceptLabel,Dependencies,TaxonomyID
|
|
2
|
+
1,OpenAI API,,Platform
|
|
3
|
+
2,Chat Completions API,1,Core
|
|
4
|
+
3,system role,2,Message
|
|
5
|
+
4,user role,2,Message
|
|
6
|
+
5,assistant role,2,Message
|
|
7
|
+
6,content array,2,Message
|
|
8
|
+
7,function calling,2,Tool
|
|
9
|
+
8,tool_choice,7,Tool
|
|
10
|
+
9,parallel_tool_calls,7,Tool
|
|
11
|
+
10,tool definition JSON,7,Tool
|
|
12
|
+
11,Structured Outputs,2,Output
|
|
13
|
+
12,response_format,11,Output
|
|
14
|
+
13,JSON schema strict,11|12,Output
|
|
15
|
+
14,Assistants API,1,Assistant
|
|
16
|
+
15,Assistant object,14,Assistant
|
|
17
|
+
16,Thread,14,Assistant
|
|
18
|
+
17,Run,14|15|16,Assistant
|
|
19
|
+
18,Message object,16,Assistant
|
|
20
|
+
19,File object,14,Assistant
|
|
21
|
+
20,Code Interpreter,14,Assistant
|
|
22
|
+
21,File Search,14,Assistant
|
|
23
|
+
22,Embeddings API,1,Embedding
|
|
24
|
+
23,text-embedding-3-small,22,Embedding
|
|
25
|
+
24,text-embedding-3-large,22,Embedding
|
|
26
|
+
25,Fine-tuning API,1,Training
|
|
27
|
+
26,fine_tuning.job,25,Training
|
|
28
|
+
27,training_file JSONL,25,Training
|
|
29
|
+
28,validation_file,25,Training
|
|
30
|
+
29,Moderation API,1,Safety
|
|
31
|
+
30,moderation category,29,Safety
|
|
32
|
+
31,moderation score,29,Safety
|
|
33
|
+
32,Images API,1,Multimodal
|
|
34
|
+
33,DALL-E 3,32,Multimodal
|
|
35
|
+
34,image generation,32,Multimodal
|
|
36
|
+
35,image editing,32,Multimodal
|
|
37
|
+
36,Audio API,1,Multimodal
|
|
38
|
+
37,Whisper ASR,36,Multimodal
|
|
39
|
+
38,TTS,36,Multimodal
|
|
40
|
+
39,Batch API,1,Efficiency
|
|
41
|
+
40,batch job,39,Efficiency
|
|
42
|
+
41,Streaming,2,Efficiency
|
|
43
|
+
42,GPT-4o,1,Model
|
|
44
|
+
43,o3 reasoning model,1,Model
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
ConceptID,ConceptLabel,Dependencies,TaxonomyID
|
|
2
|
+
1,Vertex AI Platform,,Platform
|
|
3
|
+
2,Gemini 2.0 Flash,1,Model
|
|
4
|
+
3,Gemini 2.0 Pro,1,Model
|
|
5
|
+
4,Gemini Ultra,1,Model
|
|
6
|
+
5,Imagen 3,1,Model
|
|
7
|
+
6,Text Embedding Gecko,1,Model
|
|
8
|
+
7,GenerativeModel,2|3,SDK
|
|
9
|
+
8,GenerationConfig,7,SDK
|
|
10
|
+
9,SafetySettings,7,SDK
|
|
11
|
+
10,Content,7,SDK
|
|
12
|
+
11,Vertex AI Studio,1,Studio
|
|
13
|
+
12,Prompt Design,11,Studio
|
|
14
|
+
13,Grounding Google Search,7,Grounding
|
|
15
|
+
14,Grounding Vertex AI Search,7,Grounding
|
|
16
|
+
15,Agent Builder,1,Agent
|
|
17
|
+
16,Dialogflow CX,15,Agent
|
|
18
|
+
17,Search App,15,Agent
|
|
19
|
+
18,Conversation App,15,Agent
|
|
20
|
+
19,Data Store,15|17,Agent
|
|
21
|
+
20,Vector Search,1,Search
|
|
22
|
+
21,Matching Engine Index,20,Search
|
|
23
|
+
22,IndexEndpoint,21,Search
|
|
24
|
+
23,ANN approximate nearest neighbor,20,Search
|
|
25
|
+
24,Kubeflow Pipeline,1,Pipeline
|
|
26
|
+
25,pipeline component,24,Pipeline
|
|
27
|
+
26,pipeline artifact,24,Pipeline
|
|
28
|
+
27,pipeline DAG,24,Pipeline
|
|
29
|
+
28,CustomJob,1,Training
|
|
30
|
+
29,HyperparameterTuning,28,Training
|
|
31
|
+
30,Distributed Training,28,Training
|
|
32
|
+
31,Model Registry,1,Registry
|
|
33
|
+
32,Model Version,31,Registry
|
|
34
|
+
33,Model Evaluation,31|32,Registry
|
|
35
|
+
34,Model Champion Challenger,33,Registry
|
|
36
|
+
35,Feature Store,1,FeatureStore
|
|
37
|
+
36,EntityType,35,FeatureStore
|
|
38
|
+
37,Feature,35|36,FeatureStore
|
|
39
|
+
38,Online Serving,35,FeatureStore
|
|
40
|
+
39,Batch Prediction,1,Inference
|
|
41
|
+
40,Prediction Endpoint,1,Inference
|
|
42
|
+
41,AutoML,1,AutoML
|
|
43
|
+
42,AutoML Tables,41,AutoML
|
|
44
|
+
43,IAM Vertex,1,Security
|
|
45
|
+
44,VPC Service Controls,43,Security
|
|
46
|
+
45,CMEK,43,Security
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import csv
|
|
2
|
+
import json
|
|
3
|
+
from collections import defaultdict, deque
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
DOMAINS_DIR = Path(__file__).parent / "domains"
|
|
7
|
+
|
|
8
|
+
EDGE_TYPES = {"REQUIRES", "ENABLES", "RELATES_TO", "IMPLEMENTS"}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _parse_dep(token: str) -> tuple[str, str, float | None]:
|
|
12
|
+
"""Split 'ID:EDGETYPE:CONFIDENCE' token.
|
|
13
|
+
EDGETYPE defaults to REQUIRES. CONFIDENCE is float 0-1 or None if unreviewed.
|
|
14
|
+
"""
|
|
15
|
+
parts = token.split(":", 2)
|
|
16
|
+
etype = parts[1] if len(parts) >= 2 and parts[1] in EDGE_TYPES else "REQUIRES"
|
|
17
|
+
confidence = None
|
|
18
|
+
if len(parts) == 3 and parts[2]:
|
|
19
|
+
try:
|
|
20
|
+
confidence = float(parts[2])
|
|
21
|
+
except ValueError:
|
|
22
|
+
pass
|
|
23
|
+
return parts[0], etype, confidence
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def load_domain_meta(domain: str) -> dict:
|
|
27
|
+
"""Return domain-level provenance: source_url, build_date."""
|
|
28
|
+
meta_path = DOMAINS_DIR / "metadata.json"
|
|
29
|
+
if not meta_path.exists():
|
|
30
|
+
return {}
|
|
31
|
+
with open(meta_path) as f:
|
|
32
|
+
data = json.load(f)
|
|
33
|
+
return data.get(domain, {})
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def available_domains() -> list[str]:
|
|
37
|
+
return sorted(p.stem for p in DOMAINS_DIR.glob("*.csv"))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def load_graph(domain: str):
|
|
41
|
+
csv_path = DOMAINS_DIR / f"{domain}.csv"
|
|
42
|
+
if not csv_path.exists():
|
|
43
|
+
raise ValueError(f"Domain '{domain}' not found. Run list_domains() to see available domains.")
|
|
44
|
+
|
|
45
|
+
id_to_label, label_to_id, prerequisites, dependents, taxonomy = {}, {}, defaultdict(list), defaultdict(list), {}
|
|
46
|
+
with open(csv_path) as f:
|
|
47
|
+
for row in csv.DictReader(f):
|
|
48
|
+
cid = row["ConceptID"]
|
|
49
|
+
label = row["ConceptLabel"].strip()
|
|
50
|
+
raw = [t.strip() for t in row["Dependencies"].split("|") if t.strip()]
|
|
51
|
+
deps = [_parse_dep(t) for t in raw] # [(dep_id, etype, confidence), ...]
|
|
52
|
+
id_to_label[cid] = label
|
|
53
|
+
label_to_id[label.lower()] = cid
|
|
54
|
+
taxonomy[cid] = row.get("TaxonomyID", "").strip()
|
|
55
|
+
prerequisites[cid] = deps
|
|
56
|
+
for dep_id, etype, confidence in deps:
|
|
57
|
+
dependents[dep_id].append((cid, etype, confidence))
|
|
58
|
+
|
|
59
|
+
return id_to_label, label_to_id, prerequisites, dependents, taxonomy
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def find_concept(label_to_id: dict, query: str) -> str | None:
|
|
63
|
+
q = query.lower().strip()
|
|
64
|
+
if q in label_to_id:
|
|
65
|
+
return label_to_id[q]
|
|
66
|
+
for label, cid in label_to_id.items():
|
|
67
|
+
if q in label:
|
|
68
|
+
return cid
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def bfs_subgraph(start_id: str, adj: dict, id_to_label: dict, max_depth: int) -> list[dict]:
|
|
73
|
+
"""DFS traversal so parent-child relationships indent correctly in text output."""
|
|
74
|
+
visited: set = set()
|
|
75
|
+
results: list[dict] = []
|
|
76
|
+
|
|
77
|
+
def _dfs(cid: str, depth: int, etype, conf):
|
|
78
|
+
if cid in visited or depth > max_depth:
|
|
79
|
+
return
|
|
80
|
+
visited.add(cid)
|
|
81
|
+
results.append({
|
|
82
|
+
"concept": id_to_label.get(cid, cid),
|
|
83
|
+
"concept_id": cid,
|
|
84
|
+
"edge_type": etype,
|
|
85
|
+
"confidence": conf,
|
|
86
|
+
"depth": depth,
|
|
87
|
+
})
|
|
88
|
+
for n, et, c in adj.get(cid, []):
|
|
89
|
+
_dfs(n, depth + 1, et, c)
|
|
90
|
+
|
|
91
|
+
_dfs(start_id, 0, None, None)
|
|
92
|
+
return results
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def prerequisite_chain(start_id: str, prerequisites: dict, id_to_label: dict) -> list[str]:
|
|
96
|
+
visited, queue, chain = set(), deque([start_id]), []
|
|
97
|
+
while queue:
|
|
98
|
+
cid = queue.popleft()
|
|
99
|
+
if cid in visited:
|
|
100
|
+
continue
|
|
101
|
+
visited.add(cid)
|
|
102
|
+
chain.append(id_to_label.get(cid, cid))
|
|
103
|
+
for dep_id, _etype, _conf in prerequisites.get(cid, []):
|
|
104
|
+
if dep_id not in visited:
|
|
105
|
+
queue.append(dep_id)
|
|
106
|
+
return chain
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ckg-ai-platforms — AI developer platforms as traversable knowledge graphs.
|
|
3
|
+
|
|
4
|
+
7 domains · 314 nodes · MCP-native · 11x fewer tokens than RAG
|
|
5
|
+
|
|
6
|
+
Domains: LangChain · LangGraph · OpenAI API · Anthropic SDK · HuggingFace ·
|
|
7
|
+
AWS Bedrock · Vertex AI
|
|
8
|
+
|
|
9
|
+
Edge types: REQUIRES · ENABLES · RELATES_TO · IMPLEMENTS
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
uvx ckg-ai-platforms # run as MCP server
|
|
13
|
+
python -m ckg_ai_platforms # same
|
|
14
|
+
|
|
15
|
+
Claude Desktop config:
|
|
16
|
+
{
|
|
17
|
+
"mcpServers": {
|
|
18
|
+
"ai-platforms": {
|
|
19
|
+
"command": "uvx",
|
|
20
|
+
"args": ["ckg-ai-platforms"]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
"""
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
from mcp.server.fastmcp import FastMCP
|
|
27
|
+
from .graph import available_domains, load_graph, load_domain_meta, find_concept, bfs_subgraph, prerequisite_chain
|
|
28
|
+
|
|
29
|
+
_DOMAIN_HINTS: dict[str, list[str]] = {
|
|
30
|
+
"langchain": ["langchain", "lcel", "chain", "langsmith", "runnable", "agent executor"],
|
|
31
|
+
"langgraph": ["langgraph", "graph state", "state machine", "state graph", "cycl"],
|
|
32
|
+
"openai-api": ["openai", "gpt", "chat completion", "embeddings", "assistants", "dall-e", "whisper"],
|
|
33
|
+
"anthropic-sdk": ["anthropic", "claude", "messages api", "tool use", "prompt caching", "computer use"],
|
|
34
|
+
"huggingface": ["huggingface", "hugging face", "transformers", "hub", "spaces", "datasets", "inference api"],
|
|
35
|
+
"aws-bedrock": ["bedrock", "aws bedrock", "amazon bedrock", "converse api", "guardrails", "knowledge base"],
|
|
36
|
+
"vertex-ai": ["vertex", "google cloud", "vertex ai", "model garden", "gemini", "palm"],
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _detect_domain(question: str) -> str | None:
|
|
41
|
+
q = question.lower()
|
|
42
|
+
best, top = None, 0
|
|
43
|
+
for domain, hints in _DOMAIN_HINTS.items():
|
|
44
|
+
score = sum(1 for h in hints if h in q)
|
|
45
|
+
if score > top:
|
|
46
|
+
top, best = score, domain
|
|
47
|
+
return best
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
mcp = FastMCP(
|
|
51
|
+
"ckg-ai-platforms",
|
|
52
|
+
instructions=(
|
|
53
|
+
"CKG server for AI developer platforms (LangChain, LangGraph, OpenAI, Anthropic, "
|
|
54
|
+
"HuggingFace, AWS Bedrock, Vertex AI). "
|
|
55
|
+
"Call list_domains first, then query_ckg or get_prerequisites. "
|
|
56
|
+
"Edges are typed: REQUIRES / ENABLES / RELATES_TO / IMPLEMENTS."
|
|
57
|
+
),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@mcp.tool()
|
|
62
|
+
def ask_platform(question: str, domain: str = "") -> str:
|
|
63
|
+
"""Answer a question about an AI platform by traversing the relevant CKG.
|
|
64
|
+
|
|
65
|
+
Auto-detects the platform from the question if domain is not specified.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
question: Your question about an AI platform concept or workflow.
|
|
69
|
+
domain: Optional — one of: langchain, langgraph, openai-api, anthropic-sdk,
|
|
70
|
+
huggingface, aws-bedrock, vertex-ai
|
|
71
|
+
"""
|
|
72
|
+
domains = available_domains()
|
|
73
|
+
if not domain:
|
|
74
|
+
domain = _detect_domain(question)
|
|
75
|
+
if not domain or domain not in domains:
|
|
76
|
+
return (
|
|
77
|
+
f"Could not detect platform. Available: {', '.join(domains)}.\n"
|
|
78
|
+
"Re-call with domain= set explicitly."
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
id_to_label, label_to_id, prerequisites, dependents, taxonomy = load_graph(domain)
|
|
82
|
+
meta = load_domain_meta(domain)
|
|
83
|
+
|
|
84
|
+
cid = find_concept(label_to_id, question)
|
|
85
|
+
if cid is None:
|
|
86
|
+
for word in sorted(question.lower().split(), key=len, reverse=True):
|
|
87
|
+
if len(word) > 3:
|
|
88
|
+
cid = find_concept(label_to_id, word)
|
|
89
|
+
if cid:
|
|
90
|
+
break
|
|
91
|
+
if cid is None:
|
|
92
|
+
top = list(label_to_id.keys())[:8]
|
|
93
|
+
return (
|
|
94
|
+
f"No concept matched '{question}' in {domain}.\n"
|
|
95
|
+
f"Sample concepts: {', '.join(t.title() for t in top)}"
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
concept_label = id_to_label[cid]
|
|
99
|
+
chain = prerequisite_chain(cid, prerequisites, id_to_label)
|
|
100
|
+
subgraph = bfs_subgraph(cid, prerequisites, id_to_label, max_depth=3)
|
|
101
|
+
|
|
102
|
+
lines = [
|
|
103
|
+
f"# CKG: {domain} — {concept_label}",
|
|
104
|
+
f"Taxonomy: {taxonomy.get(cid, 'unknown')}",
|
|
105
|
+
"",
|
|
106
|
+
"## Prerequisite chain (upstream dependencies)",
|
|
107
|
+
]
|
|
108
|
+
for label in chain[1:]:
|
|
109
|
+
lines.append(f" ← {label}")
|
|
110
|
+
|
|
111
|
+
lines += ["", "## What this concept enables / depends on"]
|
|
112
|
+
for entry in subgraph:
|
|
113
|
+
if entry["concept"] != concept_label and entry["depth"] == 1:
|
|
114
|
+
lines.append(f" {entry['edge_type']}: {entry['concept']}")
|
|
115
|
+
|
|
116
|
+
if meta:
|
|
117
|
+
lines += ["", f"Domain: {meta.get('description', '')}"]
|
|
118
|
+
lines.append("\nSource: ckg-ai-platforms v0.1.0 · graphifymd.com")
|
|
119
|
+
return "\n".join(lines)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
@mcp.tool()
|
|
123
|
+
def list_domains() -> str:
|
|
124
|
+
"""List all available AI platform domains in this package."""
|
|
125
|
+
domains = available_domains()
|
|
126
|
+
lines = [f"Available domains ({len(domains)}):"]
|
|
127
|
+
for d in sorted(domains):
|
|
128
|
+
lines.append(f" - {d}")
|
|
129
|
+
lines.append("\nUse query_ckg(concept, domain) or ask_platform(question).")
|
|
130
|
+
return "\n".join(lines)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@mcp.tool()
|
|
134
|
+
def search_concepts(query: str, domain: str) -> str:
|
|
135
|
+
"""Find concepts in a domain by partial name match.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
query: Substring to search for (case-insensitive).
|
|
139
|
+
domain: One of the available domains.
|
|
140
|
+
"""
|
|
141
|
+
_, label_to_id, _, _, taxonomy = load_graph(domain)
|
|
142
|
+
q = query.lower()
|
|
143
|
+
matches = [(label, cid) for label, cid in label_to_id.items() if q in label][:20]
|
|
144
|
+
if not matches:
|
|
145
|
+
return f"No concepts matching '{query}' in {domain}."
|
|
146
|
+
return "\n".join(
|
|
147
|
+
f" - {label.title()} [{taxonomy.get(cid, '')}]"
|
|
148
|
+
for label, cid in matches
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@mcp.tool()
|
|
153
|
+
def query_ckg(concept: str, domain: str, depth: int = 3) -> str:
|
|
154
|
+
"""Return the dependency subgraph around a concept.
|
|
155
|
+
|
|
156
|
+
Args:
|
|
157
|
+
concept: Concept name (partial match supported).
|
|
158
|
+
domain: Domain to search in.
|
|
159
|
+
depth: Upstream hops to include (1-5, default 3).
|
|
160
|
+
"""
|
|
161
|
+
id_to_label, label_to_id, prerequisites, dependents, taxonomy = load_graph(domain)
|
|
162
|
+
cid = find_concept(label_to_id, concept)
|
|
163
|
+
if cid is None:
|
|
164
|
+
return f"Concept '{concept}' not found in {domain}."
|
|
165
|
+
|
|
166
|
+
concept_label = id_to_label[cid]
|
|
167
|
+
chain = prerequisite_chain(cid, prerequisites, id_to_label)
|
|
168
|
+
subgraph = bfs_subgraph(cid, dependents, id_to_label, max_depth=min(depth, 5))
|
|
169
|
+
|
|
170
|
+
lines = [
|
|
171
|
+
f"## {concept_label} [{taxonomy.get(cid, '')}] — {domain}",
|
|
172
|
+
"",
|
|
173
|
+
"### Prerequisites (what you need to know first)",
|
|
174
|
+
]
|
|
175
|
+
for label in chain[1:]:
|
|
176
|
+
lines.append(f" ← {label}")
|
|
177
|
+
|
|
178
|
+
lines += ["", "### Builds toward (concepts that depend on this)"]
|
|
179
|
+
for entry in subgraph:
|
|
180
|
+
if entry["concept"] != concept_label:
|
|
181
|
+
lines.append(f" → {entry['concept']} [{entry['edge_type']}]")
|
|
182
|
+
return "\n".join(lines)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@mcp.tool()
|
|
186
|
+
def get_prerequisites(concept: str, domain: str) -> str:
|
|
187
|
+
"""Return the full upstream prerequisite chain for a concept.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
concept: Concept to trace (partial match supported).
|
|
191
|
+
domain: Domain to search in.
|
|
192
|
+
"""
|
|
193
|
+
id_to_label, label_to_id, prerequisites, _, _ = load_graph(domain)
|
|
194
|
+
cid = find_concept(label_to_id, concept)
|
|
195
|
+
if cid is None:
|
|
196
|
+
return f"Concept '{concept}' not found in {domain}."
|
|
197
|
+
|
|
198
|
+
chain = prerequisite_chain(cid, prerequisites, id_to_label)
|
|
199
|
+
if len(chain) <= 1:
|
|
200
|
+
return f"{id_to_label[cid]} has no prerequisites in {domain}."
|
|
201
|
+
return f"Prerequisite chain for {id_to_label[cid]}:\n" + "\n".join(
|
|
202
|
+
f" {' ' * i}← {label}" for i, label in enumerate(chain[1:])
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def main() -> None:
|
|
207
|
+
mcp.run()
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
if __name__ == "__main__":
|
|
211
|
+
main()
|