@1kbirds/chidori 0.1.26 → 3.3.0
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 +113 -6
- package/dist/agent.d.ts +487 -0
- package/dist/agent.js +46 -0
- package/dist/index.d.ts +332 -0
- package/dist/index.js +318 -0
- package/package.json +27 -33
- package/src/agent.ts +548 -0
- package/src/index.ts +580 -0
- package/CHANGELOG.md +0 -33
- package/Cargo.toml +0 -83
- package/build.rs +0 -7
- package/package_node/index.d.ts +0 -0
- package/package_node/index.js +0 -130
- package/pyproject.toml +0 -35
- package/src/lib.rs +0 -23
- package/src/translations/mod.rs +0 -9
- package/src/translations/nodejs.rs +0 -739
- package/src/translations/python.rs +0 -921
- package/src/translations/rust.rs +0 -737
- package/src/translations/shared.rs +0 -49
- package/src/translations/wasm.rs +0 -1
- package/tests/nodejs/chidori.test.js +0 -41
- package/tests/nodejs/nodeHandle.test.js +0 -15
- package/tests/python/test_chidori.py +0 -30
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
use serde_json::Value as JsonValue;
|
|
2
|
-
use std::collections::VecDeque;
|
|
3
|
-
use prompt_graph_core::proto2::SerializedValue;
|
|
4
|
-
use prompt_graph_core::templates::json_value_to_serialized_value;
|
|
5
|
-
|
|
6
|
-
pub fn json_value_to_paths(
|
|
7
|
-
d: &JsonValue,
|
|
8
|
-
) -> Vec<(Vec<String>, SerializedValue)> {
|
|
9
|
-
let mut paths = Vec::new();
|
|
10
|
-
let mut queue: VecDeque<(Vec<String>, &JsonValue)> = VecDeque::new();
|
|
11
|
-
queue.push_back((Vec::new(), d));
|
|
12
|
-
|
|
13
|
-
while let Some((mut path, dict)) = queue.pop_front() {
|
|
14
|
-
match dict {
|
|
15
|
-
JsonValue::Object(map) => {
|
|
16
|
-
for (key, val) in map {
|
|
17
|
-
let key_str = key.clone();
|
|
18
|
-
path.push(key_str.clone());
|
|
19
|
-
match val {
|
|
20
|
-
JsonValue::Object(_) => {
|
|
21
|
-
queue.push_back((path.clone(), val));
|
|
22
|
-
},
|
|
23
|
-
_ => {
|
|
24
|
-
paths.push((path.clone(), json_value_to_serialized_value(&val)));
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
path.pop();
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
JsonValue::Array(arr) => {
|
|
31
|
-
for (i, val) in arr.iter().enumerate() {
|
|
32
|
-
path.push(i.to_string());
|
|
33
|
-
match val {
|
|
34
|
-
JsonValue::Object(_) => {
|
|
35
|
-
queue.push_back((path.clone(), val));
|
|
36
|
-
},
|
|
37
|
-
_ => {
|
|
38
|
-
paths.push((path.clone(), json_value_to_serialized_value(&val)));
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
path.pop();
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
_ => panic!("Root should be a JSON object but was {:?}", d),
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
paths
|
|
49
|
-
}
|
package/src/translations/wasm.rs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// https://crates.io/crates/grpc-web-client
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
const {Chidori, GraphBuilder} = require("../..");
|
|
2
|
-
|
|
3
|
-
async function delay(ms) {
|
|
4
|
-
// Returns a promise that resolves after "ms" milliseconds
|
|
5
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
test('initialize without error', () => {
|
|
10
|
-
expect(new Chidori("1", "http://localhost:9800")).toEqual({"chi": {}});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('start server', async () => {
|
|
14
|
-
const chi = new Chidori("21", "http://127.0.0.1:9800");
|
|
15
|
-
await chi.startServer();
|
|
16
|
-
await chi.play(0,0);
|
|
17
|
-
const g = new GraphBuilder();
|
|
18
|
-
g.denoCodeNode({
|
|
19
|
-
name: "InspirationalQuote",
|
|
20
|
-
code: `return {"promptResult": "Believe"}`,
|
|
21
|
-
output: `type InspirationalQuote { promptResult: String }`,
|
|
22
|
-
is_template: true
|
|
23
|
-
});
|
|
24
|
-
g.denoCodeNode({
|
|
25
|
-
name: "CodeNode",
|
|
26
|
-
queries: ["query Q { InspirationalQuote { promptResult } }"],
|
|
27
|
-
code: `return {"output": "Here is your quote for " + \`{{InspirationalQuote.promptResult}}\` }`,
|
|
28
|
-
output: `type CodeNode { output: String }`,
|
|
29
|
-
is_template: true
|
|
30
|
-
});
|
|
31
|
-
g.commit(chi, 0);
|
|
32
|
-
await delay(1000);
|
|
33
|
-
console.log(await chi.graphStructure(0))
|
|
34
|
-
// expect((await chi.query(`
|
|
35
|
-
// query Q { InspirationalQuote { promptResult } }
|
|
36
|
-
// `, 0, 100))["values"].length).toBe(1)
|
|
37
|
-
// console.log(await chi.query(`
|
|
38
|
-
// query Q { CodeNode { output } }
|
|
39
|
-
// `, 0, 100))
|
|
40
|
-
});
|
|
41
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const {Chidori, GraphBuilder} = require("../../package_node");
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
test('adds 1 + 2 to equal 3', () => {
|
|
5
|
-
const gb = new GraphBuilder();
|
|
6
|
-
expect(gb.denoCodeNode({name: "test", code: "return 1+1"})).toEqual({"nh": {}});
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
test('nodehandle query', async () => {
|
|
10
|
-
const chi = new Chidori("1", "http://localhost:9800");
|
|
11
|
-
await chi.startServer();
|
|
12
|
-
const gb = new GraphBuilder();
|
|
13
|
-
const nh = gb.denoCodeNode({name: "test", code: "return 1+1"});
|
|
14
|
-
// expect(await nh.query(0, 0)).toEqual({});
|
|
15
|
-
});
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import pytest
|
|
2
|
-
from unittest.mock import AsyncMock, MagicMock
|
|
3
|
-
from chidori import Chidori, GraphBuilder
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
@pytest.mark.asyncio
|
|
7
|
-
async def test_simple_agent():
|
|
8
|
-
client = Chidori("100", "http://localhost:9800")
|
|
9
|
-
g = GraphBuilder()
|
|
10
|
-
await client.start_server(":memory:")
|
|
11
|
-
await g.deno_code_node(
|
|
12
|
-
name="InspirationalQuote",
|
|
13
|
-
code="""
|
|
14
|
-
return {"promptResult": "placeholder for openai call" }
|
|
15
|
-
"""
|
|
16
|
-
)
|
|
17
|
-
pn = await g.deno_code_node(
|
|
18
|
-
name="CodeNode",
|
|
19
|
-
queries=["""SELECT promptResult FROM InspirationalQuote"""],
|
|
20
|
-
code="""
|
|
21
|
-
return {"output": "Here is your quote for "+ new Date() + {{InspirationalQuote.promptResult}} }
|
|
22
|
-
""",
|
|
23
|
-
is_template=True
|
|
24
|
-
)
|
|
25
|
-
# await g.commit(client, 0)
|
|
26
|
-
# await client.play(0, 0)
|
|
27
|
-
assert 1 == 1
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|