From 30363a2a996f62ca37222063989215773ba6cc46 Mon Sep 17 00:00:00 2001 From: Colton Pierson Date: Wed, 4 Oct 2023 13:42:18 -0700 Subject: [PATCH] Fix Qdrant test (#25) * fixing qdrant test * add back feature --- .idea/toolchain.iml | 1 + toolchain/Cargo.lock | 14 +++--- .../prompt-graph-core/protobufs/DSL_v1.proto | 25 +++++++++++ toolchain/prompt-graph-exec/Cargo.toml | 1 + .../src/runtime_nodes/node_memory/node.rs | 43 +++++++++++++------ 5 files changed, 64 insertions(+), 20 deletions(-) diff --git a/.idea/toolchain.iml b/.idea/toolchain.iml index 4a5abaf..71db908 100644 --- a/.idea/toolchain.iml +++ b/.idea/toolchain.iml @@ -20,6 +20,7 @@ + diff --git a/toolchain/Cargo.lock b/toolchain/Cargo.lock index 94038cc..da4d2c1 100644 --- a/toolchain/Cargo.lock +++ b/toolchain/Cargo.lock @@ -744,7 +744,7 @@ dependencies = [ [[package]] name = "chidori" -version = "0.1.27" +version = "0.1.28" dependencies = [ "anyhow", "env_logger", @@ -755,8 +755,8 @@ dependencies = [ "neon-serde3", "once_cell", "openssl", - "prompt-graph-core 0.1.27", - "prompt-graph-exec 0.1.27", + "prompt-graph-core 0.1.28", + "prompt-graph-exec 0.1.28", "prost", "protobuf", "pyo3", @@ -4220,7 +4220,7 @@ dependencies = [ [[package]] name = "prompt-graph-core" -version = "0.1.27" +version = "0.1.28" dependencies = [ "anyhow", "env_logger", @@ -4294,7 +4294,7 @@ dependencies = [ [[package]] name = "prompt-graph-exec" -version = "0.1.27" +version = "0.1.28" dependencies = [ "anyhow", "async-stream", @@ -4314,7 +4314,7 @@ dependencies = [ "log", "neon", "openai-api-rs", - "prompt-graph-core 0.1.27", + "prompt-graph-core 0.1.28", "prost", "protobuf", "qdrant-client", @@ -4345,7 +4345,7 @@ version = "0.1.0" dependencies = [ "chidori 0.1.26", "futures 0.3.28", - "prompt-graph-core 0.1.27", + "prompt-graph-core 0.1.28", "prost", "serde", "serde_json", diff --git a/toolchain/prompt-graph-core/protobufs/DSL_v1.proto b/toolchain/prompt-graph-core/protobufs/DSL_v1.proto index fea092a..926544b 100644 --- a/toolchain/prompt-graph-core/protobufs/DSL_v1.proto +++ b/toolchain/prompt-graph-core/protobufs/DSL_v1.proto @@ -6,6 +6,31 @@ package promptgraph; // This is used to provide a language agnostic interface // for defining PromptGraphs + +// TODO: capabilities also gives us a security model + +// A Node is the core primitive within a PromptGraph, it is +// at a base level, just a function. However it includes an +// execution_capabilities which is used to determine where in our +// environment the function should be invoked. This allows us +// to determine in what environment this function must run. +message Node { + string handle = 1; + string execution_capabilities = 2; + repeated string argument_array = 3; + string inner_function_handle = 4; +} + +message Triggerable { + string node_handle = 1; + Query query = 2; +} + +message Subscribeable { + string node_handle = 1; + OutputType output = 2; +} + enum SupportedChatModel { GPT_4 = 0; GPT_4_0314 = 1; diff --git a/toolchain/prompt-graph-exec/Cargo.toml b/toolchain/prompt-graph-exec/Cargo.toml index 3b8ce44..31ae9ee 100644 --- a/toolchain/prompt-graph-exec/Cargo.toml +++ b/toolchain/prompt-graph-exec/Cargo.toml @@ -22,6 +22,7 @@ starlark = ["dep:starlark"] parquet = [ # "dep:parquet", "dep:arrow" ] +qdrant = [] default = [] [dependencies] diff --git a/toolchain/prompt-graph-exec/src/runtime_nodes/node_memory/node.rs b/toolchain/prompt-graph-exec/src/runtime_nodes/node_memory/node.rs index cee1ac5..0a61d62 100644 --- a/toolchain/prompt-graph-exec/src/runtime_nodes/node_memory/node.rs +++ b/toolchain/prompt-graph-exec/src/runtime_nodes/node_memory/node.rs @@ -202,8 +202,10 @@ pub async fn initialize_node_memory_init(n: &PromptGraphNodeMemory, _core: &Item #[cfg(test)] mod tests { + use std::collections::HashSet; use prompt_graph_core::graph_definition::create_vector_memory_node; - use prompt_graph_core::proto::item; + use prompt_graph_core::proto::{item, NodeWillExecuteOnBranch}; + use sled::Config as SledConfig; use anyhow::Result; use super::*; @@ -217,6 +219,8 @@ mod tests { // -e QDRANT__SERVICE__GRPC_PORT="6334" \ // qdrant/qdrant + let db = SledConfig::new().temporary(true).flush_every_ms(None).open().unwrap(); + let tree = db.open_tree("test").unwrap(); let config = QdrantClientConfig::from_url("http://localhost:6334"); let client = QdrantClient::new(Some(config)).unwrap(); let _ = client.delete_collection("test_exec_memory_node_qdrant").await; @@ -235,10 +239,16 @@ mod tests { vec![] ).unwrap(); - let nwe = NodeWillExecute { - source_node: "".to_string(), - change_values_used_in_execution: vec![], - matched_query_index: 0 + + let nwe = NodeWillExecuteOnBranch { + branch: 0, + counter: 0, + custom_node_type_name: None, + node: Some(NodeWillExecute { + source_node: "".to_string(), + change_values_used_in_execution: vec![], + matched_query_index: 0, + }) }; if let (core, item::Item::NodeMemory(n)) = (write.core.unwrap(), write.item.unwrap()) { @@ -249,11 +259,12 @@ mod tests { 0).await.unwrap(); let ctx = NodeExecutionContext { - node_will_execute: &nwe, + node_will_execute_on_branch: &nwe, item_core: &core, item: &item::Item::NodeMemory(n), namespaces: &HashSet::from(["".to_string()]), - template_partials: &HashMap::new() + template_partials: &HashMap::new(), + tree: &tree }; execute_node_memory(&ctx).await.unwrap(); } else { @@ -261,10 +272,15 @@ mod tests { } - let nwe = NodeWillExecute { - source_node: "".to_string(), - change_values_used_in_execution: vec![], - matched_query_index: 0 + let nwe = NodeWillExecuteOnBranch { + branch: 0, + counter: 0, + custom_node_type_name: None, + node: Some(NodeWillExecute { + source_node: "".to_string(), + change_values_used_in_execution: vec![], + matched_query_index: 0, + }) }; let read = create_vector_memory_node( @@ -281,11 +297,12 @@ mod tests { if let (core, item::Item::NodeMemory(n)) = (read.core.unwrap(), read.item.unwrap()) { let ctx = NodeExecutionContext { - node_will_execute: &nwe, + node_will_execute_on_branch: &nwe, item_core: &core, item: &item::Item::NodeMemory(n), namespaces: &HashSet::from(["".to_string()]), - template_partials: &HashMap::new() + template_partials: &HashMap::new(), + tree: &tree }; let recollection = execute_node_memory( &ctx ).await.unwrap(); assert_eq!(recollection[0].path, Some(Path { address: vec![ "".to_string(), "key".to_string() ] }));