mirror of
https://github.com/leon-ai/leon.git
synced 2024-12-24 17:23:23 +03:00
feat(bridge/nodejs): memory ESM debugging (WIP)
This commit is contained in:
parent
4abb68c1b3
commit
e240a2db3c
@ -7,12 +7,14 @@
|
||||
"email": "louis@getleon.ai",
|
||||
"url": "https://twitter.com/grenlouis"
|
||||
},
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"homepage": "https://getleon.ai",
|
||||
"bugs": {
|
||||
"url": "https://github.com/leon-ai/leon/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "1.4.0"
|
||||
"axios": "1.4.0",
|
||||
"lowdb": "6.0.1"
|
||||
}
|
||||
}
|
||||
|
@ -12,29 +12,18 @@ const {
|
||||
export const INTENT_OBJECT: IntentObject = JSON.parse(
|
||||
fs.readFileSync(INTENT_OBJ_FILE_PATH as string, 'utf8')
|
||||
)
|
||||
export const SKILL_PATH = path.join(
|
||||
process.cwd(),
|
||||
'skills',
|
||||
INTENT_OBJECT.domain,
|
||||
INTENT_OBJECT.skill
|
||||
)
|
||||
export const SKILL_CONFIG: SkillConfigSchema = JSON.parse(
|
||||
fs.readFileSync(
|
||||
path.join(
|
||||
process.cwd(),
|
||||
'skills',
|
||||
INTENT_OBJECT.domain,
|
||||
INTENT_OBJECT.skill,
|
||||
'config',
|
||||
INTENT_OBJECT.lang + '.json'
|
||||
),
|
||||
path.join(SKILL_PATH, 'config', INTENT_OBJECT.lang + '.json'),
|
||||
'utf8'
|
||||
)
|
||||
)
|
||||
export const SKILL_SRC_CONFIG: Record<string, unknown> = JSON.parse(
|
||||
fs.readFileSync(
|
||||
path.join(
|
||||
process.cwd(),
|
||||
'skills',
|
||||
INTENT_OBJECT.domain,
|
||||
INTENT_OBJECT.skill,
|
||||
'src',
|
||||
'config.json'
|
||||
),
|
||||
'utf8'
|
||||
)
|
||||
fs.readFileSync(path.join(SKILL_PATH, 'src', 'config.json'), 'utf8')
|
||||
).configurations
|
||||
|
19
bridges/nodejs/src/sdk/memory.ts
Normal file
19
bridges/nodejs/src/sdk/memory.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import path from 'node:path'
|
||||
|
||||
import { Low } from 'lowdb'
|
||||
import { JSONFile } from 'lowdb/node'
|
||||
|
||||
import { SKILL_PATH } from '@bridge/constants'
|
||||
|
||||
export class Memory {
|
||||
public async test(): Promise<void> {
|
||||
// const __dirname = dirname(fileURLToPath(import.meta.url))
|
||||
const file = path.join(SKILL_PATH, 'memory', 'db.json')
|
||||
|
||||
const adapter = new JSONFile(file)
|
||||
const defaultData = { posts: [] }
|
||||
const db = new Low(adapter, defaultData)
|
||||
|
||||
await db.read()
|
||||
}
|
||||
}
|
@ -3,9 +3,14 @@ import * as utility from 'utility'
|
||||
import type { ActionFunction } from '@sdk/types'
|
||||
import { leon } from '@sdk/leon'
|
||||
import { Network } from '@sdk/network'
|
||||
import { Memory } from '@sdk/memory'
|
||||
import { Button } from '@sdk/aurora/button'
|
||||
|
||||
export const run: ActionFunction = async function () {
|
||||
const db = new Memory()
|
||||
|
||||
await db.test()
|
||||
|
||||
await leon.answer({ key: 'default' })
|
||||
|
||||
await leon.answer({ key: utility.md5('test') })
|
||||
|
Loading…
Reference in New Issue
Block a user