@1kbirds/chidori 0.1.16
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/Cargo.toml +77 -0
- package/build.rs +7 -0
- package/package.json +39 -0
- package/package_node/index.d.ts +0 -0
- package/package_node/index.js +96 -0
- package/package_python/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- package/package_python/.idea/misc.xml +4 -0
- package/package_python/.idea/modules.xml +8 -0
- package/package_python/.idea/package_python.iml +8 -0
- package/package_python/.idea/vcs.xml +6 -0
- package/package_python/__init__.py +0 -0
- package/package_python/__pycache__/__init__.cpython-310.pyc +0 -0
- package/package_python/__pycache__/test_chidori.cpython-310-pytest-7.4.0.pyc +0 -0
- package/package_python/__pycache__/test_promptgraph.cpython-310-pytest-7.4.0.pyc +0 -0
- package/package_python/chidori.pyi +30 -0
- package/package_python/py.typed +0 -0
- package/package_python/test_chidori.py +33 -0
- package/pyproject.toml +33 -0
- package/src/lib.rs +22 -0
- package/src/translations/mod.rs +8 -0
- package/src/translations/nodejs.rs +1239 -0
- package/src/translations/python.rs +964 -0
- package/src/translations/rust.rs +177 -0
- package/src/translations/wasm.rs +1 -0
- package/tests/nodejs/chidori.test.js +54 -0
- package/tests/nodejs/nodeHandle.test.js +17 -0
package/Cargo.toml
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "chidori"
|
|
3
|
+
version = "0.1.7"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
|
|
6
|
+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
7
|
+
[lib]
|
|
8
|
+
name = "chidori"
|
|
9
|
+
crate-type = ["cdylib", "lib"]
|
|
10
|
+
bench = false
|
|
11
|
+
|
|
12
|
+
[features]
|
|
13
|
+
python = [
|
|
14
|
+
"dep:pyo3",
|
|
15
|
+
"dep:pyo3-asyncio",
|
|
16
|
+
"dep:pyo3-log",
|
|
17
|
+
]
|
|
18
|
+
nodejs = [
|
|
19
|
+
"dep:neon"
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# https://chat.openai.com/c/52edc960-dc19-4df7-b36f-30caad9c1905
|
|
24
|
+
[dependencies]
|
|
25
|
+
protobuf = "3.2.0"
|
|
26
|
+
sqlparser = "0.34.0"
|
|
27
|
+
# we do not enable wasm-bindgen serde-serialize because it causes this issue https://github.com/rustwasm/wasm-bindgen/pull/3031
|
|
28
|
+
# serde-wasm-bindgen should be used instead
|
|
29
|
+
|
|
30
|
+
# Vendor protoc and openssl so we don't need to separately install them
|
|
31
|
+
openssl = { version = "0.10", features = ["vendored"] }
|
|
32
|
+
|
|
33
|
+
once_cell = "1"
|
|
34
|
+
prompt-graph-core = { path = "../prompt-graph-core", version = "0.1.0" }
|
|
35
|
+
wasm-bindgen = {version = "0.2.86", features = []}
|
|
36
|
+
handlebars = "4.3.7"
|
|
37
|
+
anyhow = { version = "1.0", default-features = false }
|
|
38
|
+
indoc = "1.0.3"
|
|
39
|
+
serde = { version = "1.0", features = ["derive"] }
|
|
40
|
+
serde-wasm-bindgen = "0.4"
|
|
41
|
+
serde_json = "1.0.96"
|
|
42
|
+
tonic = "0.9"
|
|
43
|
+
prost = "0.11"
|
|
44
|
+
tokio = { version = "1", features = ["full"] }
|
|
45
|
+
env_logger = "0.10.0"
|
|
46
|
+
log = "0.4.16"
|
|
47
|
+
futures = "0.3.15"
|
|
48
|
+
|
|
49
|
+
# Optional unless the python feature is enabled
|
|
50
|
+
pyo3 = { version = "0.18.3", features = ["extension-module", "abi3-py37"], optional = true }
|
|
51
|
+
pyo3-asyncio = { version = "0.18", features = ["attributes", "tokio-runtime"], optional = true }
|
|
52
|
+
pyo3-log = { version = "0.8.2", optional = true }
|
|
53
|
+
|
|
54
|
+
neon-serde3 = "0.10.0"
|
|
55
|
+
|
|
56
|
+
[dependencies.prompt-graph-exec]
|
|
57
|
+
path = "../prompt-graph-exec"
|
|
58
|
+
version = "0.1.0"
|
|
59
|
+
default-features = false
|
|
60
|
+
|
|
61
|
+
[dependencies.neon]
|
|
62
|
+
version = "0.10.1"
|
|
63
|
+
default-features = false
|
|
64
|
+
features = ["napi-6", "channel-api", "promise-api", "try-catch-api"]
|
|
65
|
+
optional = true
|
|
66
|
+
|
|
67
|
+
[dev-dependencies]
|
|
68
|
+
wasm-bindgen-test = "0.2"
|
|
69
|
+
|
|
70
|
+
[build-dependencies]
|
|
71
|
+
tonic-build = "0.9.2"
|
|
72
|
+
pyo3-build-config = "0.19.1"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
[package.metadata.maturin]
|
|
76
|
+
python-source = "package_python"
|
|
77
|
+
name = "chidori"
|
package/build.rs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@1kbirds/chidori",
|
|
3
|
+
"version": "v0.1.16",
|
|
4
|
+
"description": "Prompt Graph SDK",
|
|
5
|
+
"main": "package_node/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "cargo-cp-artifact -nc ./package_node/native/chidori.node -- cargo build --message-format=json-render-diagnostics --features nodejs",
|
|
8
|
+
"build-debug": "npm run build --",
|
|
9
|
+
"build-release": "npm run build -- --release",
|
|
10
|
+
"test-rust": "cargo test",
|
|
11
|
+
"test-js": "jest tests/nodejs",
|
|
12
|
+
"install": "node-pre-gyp install"
|
|
13
|
+
},
|
|
14
|
+
"os": [
|
|
15
|
+
"darwin",
|
|
16
|
+
"linux",
|
|
17
|
+
"win32"
|
|
18
|
+
],
|
|
19
|
+
"cpu": [
|
|
20
|
+
"x64",
|
|
21
|
+
"ia32",
|
|
22
|
+
"arm64"
|
|
23
|
+
],
|
|
24
|
+
"binary": {
|
|
25
|
+
"module_name": "chidori",
|
|
26
|
+
"module_path": "./package_node/native",
|
|
27
|
+
"host": "https://github.com/thousandbirdsinc/monorepo/releases/download/",
|
|
28
|
+
"package_name": "{module_name}-v{version}-{node_abi}-{platform}-{arch}-{libc}.tar.gz",
|
|
29
|
+
"remote_path": "v{version}"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@mapbox/node-pre-gyp": "^1.0.8"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"cargo-cp-artifact": "^0.1.8",
|
|
37
|
+
"jest": "^29.6.1"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const { promisify } = require("util");
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
simpleFun,
|
|
7
|
+
nodehandleDebugExample,
|
|
8
|
+
nodehandleRunWhen,
|
|
9
|
+
nodehandleQuery,
|
|
10
|
+
chidoriNew,
|
|
11
|
+
chidoriStartServer,
|
|
12
|
+
chidoriObjInterface,
|
|
13
|
+
chidoriPlay,
|
|
14
|
+
chidoriPause,
|
|
15
|
+
chidoriBranch,
|
|
16
|
+
chidoriQuery,
|
|
17
|
+
chidoriGraphStructure,
|
|
18
|
+
chidoriCustomNode,
|
|
19
|
+
chidoriDenoCodeNode,
|
|
20
|
+
chidoriVectorMemoryNode
|
|
21
|
+
} = require("./native/chidori.node");
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
// Wrapper class for the boxed `Database` for idiomatic JavaScript usage
|
|
26
|
+
class NodeHandle {
|
|
27
|
+
constructor() {
|
|
28
|
+
this.nh = nodehandleDebugExample();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
runWhen(otherNodeHandle) {
|
|
32
|
+
return nodehandleRunWhen.call(this.nh, otherNodeHandle);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
query(branch, frame) {
|
|
36
|
+
return nodehandleQuery.call(this.nh, branch, frame);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Chidori {
|
|
42
|
+
constructor(fileId, url) {
|
|
43
|
+
this.chi = chidoriNew(fileId, url);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
startServer() {
|
|
47
|
+
return chidoriStartServer.call(this.chi);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
objectInterface(executionStatus) {
|
|
51
|
+
return chidoriObjInterface.call(this.chi, executionStatus);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
play(branch, frame) {
|
|
55
|
+
return chidoriPlay.call(this.chi, branch, frame);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
pause() {
|
|
59
|
+
return chidoriPause.call(this.chi, branch, frame);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
query(query, branch, frame) {
|
|
63
|
+
return chidoriQuery.call(this.chi, query, branch, frame)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
branch() {
|
|
67
|
+
return chidoriBranch.call(this.chi, branch, frame);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
graphStructure() {
|
|
71
|
+
return chidoriGraphStructure.call(this.chi);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
objInterface() {
|
|
75
|
+
return chidoriObjInterface.call(this.chi, branch, frame);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
customNode(customNodeCreateOpts) {
|
|
79
|
+
return chidoriCustomNode.call(this.chi, createCustomNodeOpts);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
denoCodeNode(denoCodeNodeCreateOpts) {
|
|
83
|
+
return chidoriDenoCodeNode.call(this.chi, denoCodeNodeCreateOpts);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
vectorMemoryNode(vectorMemoryNodeCreateOpts) {
|
|
87
|
+
return chidoriVectorMemoryNode.call(this.chi, vectorMemoryNodeCreateOpts);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
Chidori: Chidori,
|
|
94
|
+
NodeHandle: NodeHandle,
|
|
95
|
+
simpleFun: simpleFun
|
|
96
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/package_python.iml" filepath="$PROJECT_DIR$/.idea/package_python.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
|
File without changes
|
|
Binary file
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import *
|
|
4
|
+
|
|
5
|
+
class NodeHandle:
|
|
6
|
+
def get_name(self) -> str: ...
|
|
7
|
+
def run_when(self, node_handle: Optional[NodeHandle]) -> None: ...
|
|
8
|
+
def query(self, branch: int, frame: int) -> None: ...
|
|
9
|
+
def __str__(self) -> str: ...
|
|
10
|
+
def __repr__(self) -> str: ...
|
|
11
|
+
|
|
12
|
+
class Chidori:
|
|
13
|
+
def start_server(self, file_path: Optional[str]) -> None: ...
|
|
14
|
+
def play(self, branch: int, frame: int) -> None: ...
|
|
15
|
+
def pause(self, frame: int) -> None: ...
|
|
16
|
+
def branch(self) -> None: ...
|
|
17
|
+
def query(self, query: str, branch: int, frame: int) -> None: ...
|
|
18
|
+
def list_branches(self) -> None: ...
|
|
19
|
+
def display_graph_structure(self) -> None: ...
|
|
20
|
+
def list_registered_graphs(self) -> None: ...
|
|
21
|
+
def list_input_proposals(self) -> None: ...
|
|
22
|
+
def list_change_events(self, callback: object) -> None: ...
|
|
23
|
+
def load_zip_file(self, name: str, output_tables: List[str], output: str, bytes: bytes) -> None: ...
|
|
24
|
+
def prompt_node(self, name: str, queries: List[Optional[str]], output_tables: List[str], template: str, model: str) -> None: ...
|
|
25
|
+
def poll_local_code_node_execution(self) -> None: ...
|
|
26
|
+
def ack_local_code_node_execution(self, branch: int, counter: int) -> None: ...
|
|
27
|
+
def respond_local_code_node_execution(self, branch: int, counter: int, node_name: str, response: Optional[object]) -> None: ...
|
|
28
|
+
def custom_node(self, name: str, queries: List[Optional[str]], output_tables: List[str], output: str, node_type_name: str) -> None: ...
|
|
29
|
+
def deno_code_node(self, name: str, queries: List[Optional[str]], output_tables: List[str], output: str, code: str, is_template: bool) -> None: ...
|
|
30
|
+
def vector_memory_node(self, name: str, queries: List[Optional[str]], output_tables: List[str], output: str, template: str, action: str, embedding_model: str, db_vendor: str, collection_name: str) -> None: ...
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from unittest.mock import AsyncMock, MagicMock
|
|
3
|
+
from chidori import Chidori
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.mark.asyncio
|
|
7
|
+
async def test_simple_agent():
|
|
8
|
+
client = Chidori("100", "http://localhost:9800")
|
|
9
|
+
await client.start_server(":memory:")
|
|
10
|
+
await client.deno_code_node(
|
|
11
|
+
name="InspirationalQuote",
|
|
12
|
+
code="""
|
|
13
|
+
return {"promptResult": "placeholder for openai call" }
|
|
14
|
+
"""
|
|
15
|
+
)
|
|
16
|
+
pn = await client.deno_code_node(
|
|
17
|
+
name="CodeNode",
|
|
18
|
+
queries=["""
|
|
19
|
+
query Q {
|
|
20
|
+
InspirationalQuote {
|
|
21
|
+
promptResult
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
"""],
|
|
25
|
+
code="""
|
|
26
|
+
return {"output": "Here is your quote for "+ new Date() + {{InspirationalQuote.promptResult}} }
|
|
27
|
+
""",
|
|
28
|
+
is_template=True
|
|
29
|
+
)
|
|
30
|
+
await client.play(0, 0)
|
|
31
|
+
await pn.query(0, 100)
|
|
32
|
+
|
|
33
|
+
|
package/pyproject.toml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "chidori"
|
|
3
|
+
repository = "https://github.com/thousandbirds/chidori"
|
|
4
|
+
description = "A framework for building LLM based agents"
|
|
5
|
+
authors = [
|
|
6
|
+
{name = "Colton Pierson"}
|
|
7
|
+
]
|
|
8
|
+
classifiers=[
|
|
9
|
+
"Development Status :: 3 - Alpha",
|
|
10
|
+
"Intended Audience :: Developers",
|
|
11
|
+
"Topic :: Software Development",
|
|
12
|
+
"Topic :: Software Development :: Libraries",
|
|
13
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"typing-extensions>=3; python_version < '3.8'",
|
|
17
|
+
"cffi"
|
|
18
|
+
]
|
|
19
|
+
requires-python = ">=3.9"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
homepage = "https://github.com/thousandbirds/chidori"
|
|
24
|
+
documentation = "https://github.com/thousandbirds/chidori/README.md"
|
|
25
|
+
repository = "https://github.com/thousandbirds/chidori"
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["maturin>=1.0,<2.0"]
|
|
29
|
+
build-backend = "maturin"
|
|
30
|
+
|
|
31
|
+
[tool.maturin]
|
|
32
|
+
features = ["python"]
|
|
33
|
+
python-source = "package_python"
|
package/src/lib.rs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
extern crate protobuf;
|
|
2
|
+
extern crate neon_serde3;
|
|
3
|
+
pub mod translations;
|
|
4
|
+
|
|
5
|
+
use prompt_graph_core::proto2::{ChangeValue, Path, SerializedValue};
|
|
6
|
+
use prompt_graph_core::proto2::serialized_value::Val;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
/// Our local server implementation is an extension of this. Implementing support for multiple
|
|
10
|
+
/// agent implementations to run on the same machine.
|
|
11
|
+
pub fn create_change_value(address: Vec<String>, val: Option<Val>, branch: u64) -> ChangeValue {
|
|
12
|
+
ChangeValue{
|
|
13
|
+
path: Some(Path {
|
|
14
|
+
address,
|
|
15
|
+
}),
|
|
16
|
+
value: Some(SerializedValue {
|
|
17
|
+
val,
|
|
18
|
+
}),
|
|
19
|
+
branch,
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|