Compare commits
2 commits
main
...
sed-ollama
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01ba23c809 | ||
|
|
8e5f2e3684 |
8 changed files with 6 additions and 324 deletions
|
|
@ -1,12 +1,12 @@
|
|||
[project]
|
||||
name = "cognee-mcp"
|
||||
version = "0.2.1"
|
||||
version = "0.2.2"
|
||||
description = "A MCP server project"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.10"
|
||||
|
||||
dependencies = [
|
||||
"cognee[postgres,codegraph,gemini,huggingface]",
|
||||
"cognee[postgres,codegraph,gemini,huggingface]==0.1.36",
|
||||
"mcp==1.5.0",
|
||||
"uv>=0.6.3",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ def get_embedding_engine() -> EmbeddingEngine:
|
|||
return OllamaEmbeddingEngine(
|
||||
model=config.embedding_model,
|
||||
dimensions=config.embedding_dimensions,
|
||||
endpoint=config.embedding_endpoint,
|
||||
max_tokens=config.embedding_max_tokens,
|
||||
huggingface_tokenizer=config.huggingface_tokenizer,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ services:
|
|||
limits:
|
||||
cpus: "2.0"
|
||||
memory: 8GB
|
||||
# Add this so inside the container "host.docker.internal" -> your host machine
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
|
||||
# NOTE: Frontend is a work in progress and is not intended to be used by users yet.
|
||||
# If you want to use Cognee with a UI environment you can run the cognee-gui.py script or
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import nodeFetch from 'node-fetch';
|
||||
import handleServerErrors from './handleServerErrors.js';
|
||||
|
||||
export default function fetch(url, options = {}, token) {
|
||||
return nodeFetch('http://127.0.0.1:8000/api' + url, {
|
||||
...options,
|
||||
headers: {
|
||||
...options.headers,
|
||||
'Authorization': `Bearer ${token}`,
|
||||
},
|
||||
})
|
||||
.then(handleServerErrors)
|
||||
.catch(handleServerErrors);
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
export default function handleServerErrors(response) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (response.status === 401) {
|
||||
return reject(new Error('Unauthorized'));
|
||||
}
|
||||
if (!response.ok) {
|
||||
if (response.json) {
|
||||
return response.json().then(error => reject(error));
|
||||
} else {
|
||||
return reject(response.detail || response.body || response);
|
||||
}
|
||||
}
|
||||
|
||||
return resolve(response);
|
||||
});
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
import fs from 'fs';
|
||||
import FormData from 'form-data';
|
||||
import fetch from './fetch.js';
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
// Default user is created automatically, you can create a new user if needed.
|
||||
// const registerResponse = await fetch('/v1/auth/register', {
|
||||
// method: 'POST',
|
||||
// body: {
|
||||
// email: 'default_user@example.com',
|
||||
// password: 'default_password',
|
||||
// is_active: true,
|
||||
// is_superuser: true,
|
||||
// is_verified: true
|
||||
// },
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// },
|
||||
// });
|
||||
// const user = await registerResponse.json();
|
||||
|
||||
const authCredentials = new FormData();
|
||||
authCredentials.append('username', 'default_user@example.com');
|
||||
authCredentials.append('password', 'default_password');
|
||||
|
||||
const loginResponse = await fetch('/v1/auth/login', {
|
||||
method: 'POST',
|
||||
body: authCredentials,
|
||||
});
|
||||
|
||||
const bearer = await loginResponse.json();
|
||||
const token = bearer.access_token;
|
||||
|
||||
const response = await fetch('/v1/datasets', {}, token);
|
||||
const datasets = await response.json();
|
||||
console.log(datasets);
|
||||
|
||||
const files = [
|
||||
fs.createReadStream('../data/artificial_intelligence.pdf'),
|
||||
];
|
||||
|
||||
const addData = new FormData();
|
||||
files.forEach((file) => {
|
||||
addData.append('data', file, file.name);
|
||||
})
|
||||
addData.append('datasetId', 'main');
|
||||
|
||||
await fetch('/v1/add', {
|
||||
method: 'POST',
|
||||
body: addData,
|
||||
headers: addData.getHeaders(),
|
||||
}, token);
|
||||
|
||||
await fetch('/v1/cognify', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
datasets: ['main'],
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
}, token);
|
||||
|
||||
const graphResponse = await fetch('/v1/datasets/main/graph', {
|
||||
method: 'GET',
|
||||
}, token);
|
||||
|
||||
const graphUrl = await graphResponse.text();
|
||||
console.log('Graph URL:', graphUrl);
|
||||
|
||||
// Search for summaries
|
||||
const summariesResponse = await fetch('/v1/search', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
searchType: 'SUMMARIES',
|
||||
query: 'Artificial Intelligence',
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
}, token);
|
||||
|
||||
|
||||
const summariesResults = await summariesResponse.json();
|
||||
console.log('Summaries Results:', summariesResults);
|
||||
|
||||
// Search for chunks
|
||||
const chunksResponse = await fetch('/v1/search', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
searchType: 'CHUNKS',
|
||||
query: 'Artificial Intelligence',
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
}, token);
|
||||
|
||||
const chunksResults = await chunksResponse.json();
|
||||
console.log('Chunks Results:', chunksResults);
|
||||
|
||||
// Search for insights
|
||||
const insightsResponse = await fetch('/v1/search', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
searchType: 'INSIGHTS',
|
||||
query: 'Artificial Intelligence',
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
}, token);
|
||||
|
||||
const insightsResults = await insightsResponse.json();
|
||||
console.log('Insights Results:', insightsResults);
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
156
examples/node/package-lock.json
generated
156
examples/node/package-lock.json
generated
|
|
@ -1,156 +0,0 @@
|
|||
{
|
||||
"name": "node-example",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "node-example",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"form-data": "^4.0.1",
|
||||
"node-fetch": "^3.3.2"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
|
||||
},
|
||||
"node_modules/combined-stream": {
|
||||
"version": "1.0.8",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
|
||||
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
|
||||
"dependencies": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/data-uri-to-buffer": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz",
|
||||
"integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==",
|
||||
"engines": {
|
||||
"node": ">= 12"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/fetch-blob": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz",
|
||||
"integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jimmywarting"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://paypal.me/jimmywarting"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"node-domexception": "^1.0.0",
|
||||
"web-streams-polyfill": "^3.0.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.20 || >= 14.13"
|
||||
}
|
||||
},
|
||||
"node_modules/form-data": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz",
|
||||
"integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==",
|
||||
"dependencies": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "^1.0.8",
|
||||
"mime-types": "^2.1.12"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/formdata-polyfill": {
|
||||
"version": "4.0.10",
|
||||
"resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz",
|
||||
"integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==",
|
||||
"dependencies": {
|
||||
"fetch-blob": "^3.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/node-domexception": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz",
|
||||
"integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/jimmywarting"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://paypal.me/jimmywarting"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "3.3.2",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz",
|
||||
"integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==",
|
||||
"dependencies": {
|
||||
"data-uri-to-buffer": "^4.0.0",
|
||||
"fetch-blob": "^3.1.4",
|
||||
"formdata-polyfill": "^4.0.10"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/node-fetch"
|
||||
}
|
||||
},
|
||||
"node_modules/web-streams-polyfill": {
|
||||
"version": "3.3.3",
|
||||
"resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz",
|
||||
"integrity": "sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==",
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"type": "module",
|
||||
"name": "node-example",
|
||||
"version": "1.0.0",
|
||||
"description": "Node example calling Cognee API",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"dependencies": {
|
||||
"form-data": "^4.0.1",
|
||||
"node-fetch": "^3.3.2"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue