初始化配置

This commit is contained in:
2026-04-09 06:22:01 +00:00
commit b16df5f9d9
8 changed files with 4223 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/alpine
{
"name": "node-dev-container",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "hub.gaomia.site/titor/node-dev-container:latest"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

34
.gitignore vendored Normal file
View File

@@ -0,0 +1,34 @@
# dependencies (bun install)
node_modules
# output
out
dist
*.tgz
# code coverage
coverage
*.lcov
# logs
logs
_.log
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# caches
.eslintcache
.cache
*.tsbuildinfo
# IntelliJ based IDEs
.idea
# Finder (MacOS) folder config
.DS_Store

15
README.md Normal file
View File

@@ -0,0 +1,15 @@
# mem0
To install dependencies:
```bash
bun install
```
To run:
```bash
bun run index.ts
```
This project was created using `bun init` in bun v1.3.6. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.

55
index.ts Normal file
View File

@@ -0,0 +1,55 @@
import { Memory } from "mem0ai/oss";
const memory = new Memory({
version: "v1.1",
embedder: {
provider: "openai",
config: {
baseURL: "https://api.siliconflow.cn/v1/",
apiKey: "sk-tnynjffzcdudlflrydljyxttorrtstpviyuodnyuyyalzfan",
model: "BAAI/bge-m3"
}
},
llm: {
provider: "openai",
config: {
baseURL: "https://api.siliconflow.cn/v1/",
apiKey: "sk-tnynjffzcdudlflrydljyxttorrtstpviyuodnyuyyalzfan",
model: "Qwen/Qwen2.5-7B-Instruct"
}
},
vectorStore: {
provider: "memory",
config: {
collectionName: "memories",
dimension: 1024
}
},
historyDbPath: "./memory.db"
})
const messages = [
{ role: "user", content: "I'm planning to watch a movie tonight. Any recommendations?" },
{ role: "assistant", content: "How about thriller movies? They can be quite engaging." },
{ role: "user", content: "I'm not a big fan of thriller movies but I love sci-fi movies." },
{ role: "assistant", content: "Got it! I'll avoid thriller recommendations and suggest sci-fi movies in the future." }
];
try {
const insertContent = await memory.add(messages, {"userId": "huyang", metadata: {
category: "movie_recommendations"
}})
if (insertContent) {
console.log(
"Insert Ok...",
"\r\n",
insertContent.results
)
} else {
console.log(
"Insert Error"
)
}
}catch (e) {
console.log(e)
}

BIN
memory.db Normal file

Binary file not shown.

4053
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

15
package.json Normal file
View File

@@ -0,0 +1,15 @@
{
"name": "mem0",
"module": "index.ts",
"type": "module",
"private": true,
"devDependencies": {
"esno": "^4.8.0"
},
"peerDependencies": {
"typescript": "^5"
},
"dependencies": {
"mem0ai": "^2.4.6"
}
}

29
tsconfig.json Normal file
View File

@@ -0,0 +1,29 @@
{
"compilerOptions": {
// Environment setup & latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "Preserve",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
// Some stricter flags (disabled by default)
"noUnusedLocals": false,
"noUnusedParameters": false,
"noPropertyAccessFromIndexSignature": false
}
}