@nestbox-ai/cli 1.0.50 → 1.0.52
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.
- package/README.md +532 -19
- package/package.json +2 -1
- package/templates/base-js/index.js.hbs +30 -0
- package/templates/base-js/nestbox-agents.yaml.hbs +12 -0
- package/templates/base-js/package.json +15 -0
- package/templates/base-py/main.py.hbs +42 -0
- package/templates/base-py/nestbox-agents.yaml.hbs +12 -0
- package/templates/base-py/pyproject.toml +15 -0
- package/templates/base-ts/eslint.config.mjs +27 -0
- package/templates/base-ts/nestbox-agents.yaml.hbs +12 -0
- package/templates/base-ts/nestbox.config.json +9 -0
- package/templates/base-ts/package.json +24 -0
- package/templates/base-ts/src/index.ts.hbs +29 -0
- package/templates/base-ts/tsconfig.json +14 -0
- package/templates/chatbot-js/index.js.hbs +18 -0
- package/templates/chatbot-js/package-lock.json +1571 -0
- package/templates/chatbot-js/package.json +15 -0
- package/templates/chatbot-py/main.py.hbs +42 -0
- package/templates/chatbot-py/nestbox-agents.yaml.hbs +12 -0
- package/templates/chatbot-py/pyproject.toml +19 -0
- package/templates/chatbot-ts/eslint.config.mjs +27 -0
- package/templates/chatbot-ts/package.json +24 -0
- package/templates/chatbot-ts/src/index.ts.hbs +18 -0
- package/templates/chatbot-ts/tsconfig.json +14 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chatbot",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"author": "",
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"description": "",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@nestbox-ai/functions": "^2.0.0",
|
|
13
|
+
"ollama": "^0.5.14"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from nestbox_ai_functions import use_chatbot
|
|
2
|
+
from openai import OpenAI
|
|
3
|
+
|
|
4
|
+
MODEL_NAME = "openai/gpt-oss-20b"
|
|
5
|
+
|
|
6
|
+
client = OpenAI(
|
|
7
|
+
base_url="http://localhost:8000/v1",
|
|
8
|
+
api_key="sk-xxxxxx"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
@use_chatbot
|
|
12
|
+
async def {{agentName}}(context, events):
|
|
13
|
+
try:
|
|
14
|
+
response = client.chat.completions.create(
|
|
15
|
+
model=MODEL_NAME,
|
|
16
|
+
messages=context.messages,
|
|
17
|
+
stream=False,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
result = (
|
|
21
|
+
response.choices[0].message.content
|
|
22
|
+
if response.choices
|
|
23
|
+
else None
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if not result:
|
|
27
|
+
await events.emitQueryFailed({
|
|
28
|
+
"data": {
|
|
29
|
+
"error": "No response from model"
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
else:
|
|
33
|
+
await events.emitQueryCompleted({
|
|
34
|
+
"data": result
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
except Exception as e:
|
|
38
|
+
await events.emitQueryFailed({
|
|
39
|
+
"data": {
|
|
40
|
+
"error": str(e)
|
|
41
|
+
}
|
|
42
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
agents:
|
|
2
|
+
- name: {{ agentNameInYaml }}
|
|
3
|
+
description: Our new agent {{ agentNameInYaml }} that uses the nestbox API
|
|
4
|
+
entry: {{agentName}}
|
|
5
|
+
inputSchema:
|
|
6
|
+
type: object
|
|
7
|
+
properties:
|
|
8
|
+
content:
|
|
9
|
+
type: string
|
|
10
|
+
description: The content of the input as string
|
|
11
|
+
minLength: 10
|
|
12
|
+
maxLength: 5000
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "app"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Nestbox AI Python Agent"
|
|
9
|
+
requires-python = ">=3.9"
|
|
10
|
+
|
|
11
|
+
dependencies = [
|
|
12
|
+
"nestbox-ai-functions>=2.0.3",
|
|
13
|
+
"openai>=1.40.0",
|
|
14
|
+
"httpx>=0.27.0",
|
|
15
|
+
"anyio>=4.0.0"
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[tool.setuptools]
|
|
19
|
+
packages = ["."]
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import tsParser from "@typescript-eslint/parser";
|
|
2
|
+
import eslintPluginTs from "@typescript-eslint/eslint-plugin";
|
|
3
|
+
|
|
4
|
+
export default [
|
|
5
|
+
{
|
|
6
|
+
files: ["**/*.ts"],
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser: tsParser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
ecmaVersion: "latest",
|
|
11
|
+
sourceType: "module",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
plugins: {
|
|
15
|
+
"@typescript-eslint": eslintPluginTs,
|
|
16
|
+
},
|
|
17
|
+
rules: {
|
|
18
|
+
...eslintPluginTs.configs.recommended.rules,
|
|
19
|
+
// Optional custom rules:
|
|
20
|
+
// '@typescript-eslint/no-explicit-any': 'warn',
|
|
21
|
+
// '@typescript-eslint/explicit-function-return-type': 'off',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
ignores: ["dist/", "node_modules/"],
|
|
26
|
+
},
|
|
27
|
+
];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "app-ts",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "tsc",
|
|
7
|
+
"start": "node dist/index.js",
|
|
8
|
+
"dev": "ts-node src/index.ts",
|
|
9
|
+
"lint": "eslint ."
|
|
10
|
+
},
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"description": "",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@nestbox-ai/functions": "^2.0.0",
|
|
16
|
+
"ollama": "^0.5.15"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@typescript-eslint/eslint-plugin": "^8.31.0",
|
|
20
|
+
"@typescript-eslint/parser": "^8.31.0",
|
|
21
|
+
"eslint": "^9.25.1",
|
|
22
|
+
"typescript": "^5.8.3"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ChatContext, ChatEvents, useChatbot } from "@nestbox-ai/functions";
|
|
2
|
+
import { Ollama } from "ollama";
|
|
3
|
+
|
|
4
|
+
const ollama = new Ollama();
|
|
5
|
+
|
|
6
|
+
export const {{agentName}} = useChatbot(
|
|
7
|
+
async (context: ChatContext, events: ChatEvents) => {
|
|
8
|
+
const response = await ollama.chat({
|
|
9
|
+
messages: context.messages,
|
|
10
|
+
model: "gemma3:27b",
|
|
11
|
+
stream: false,
|
|
12
|
+
});
|
|
13
|
+
const result = response.response;
|
|
14
|
+
|
|
15
|
+
events.emitQueryCompleted({ data: result });
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
4
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
8
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
9
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
10
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
11
|
+
},
|
|
12
|
+
"include": ["src"],
|
|
13
|
+
"exclude": ["node_modules", "**/*.spec.ts", "**/*.test.ts"],
|
|
14
|
+
}
|