Skip to content

Commit

Permalink
fix linearization of execution graph
Browse files Browse the repository at this point in the history
  • Loading branch information
kvey committed Nov 4, 2024
1 parent 4ec0b3b commit d2a927f
Show file tree
Hide file tree
Showing 45 changed files with 1,392 additions and 1,887 deletions.
10 changes: 2 additions & 8 deletions toolchain/chidori-core/src/cells/code_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ pub fn code_cell(execution_state_id: ExecutionNodeId, cell: &CodeCell, range: &T
CellTypes::Code(cell, Default::default()),
))
}
SupportedLanguage::Starlark => {
unreachable!("fail")
},
SupportedLanguage::Deno => {
let paths =
chidori_static_analysis::language::javascript::parse::extract_dependencies_js(
Expand Down Expand Up @@ -61,17 +58,15 @@ pub(crate) fn code_cell_exec_deno(cell: CodeCell) -> Box<OperationFn> {
let s = s.clone();
let cell = cell.clone();
async move {
println!("Should be running source_code_run_deno");
let result = crate::library::std::code::runtime_deno::source_code_run_deno(
&s,
&cell.source_code,
&x,
&cell.function_invocation,
).await?;
println!("After the evaluation of running source_code_run_deno");
Ok(OperationFnOutput {
has_error: false,
execution_state: None,
execution_state: Some(result.3),
output: result.0,
stdout: result.1,
stderr: result.2,
Expand All @@ -95,10 +90,9 @@ pub fn code_cell_exec_python(cell: CodeCell) -> Box<OperationFn> {
&None,
&None,
).await?;
// TODO: don't unwrap the output result here
Ok(OperationFnOutput {
has_error: false,
execution_state: None,
execution_state: Some(result.3),
output: result.0,
stdout: result.1,
stderr: result.2,
Expand Down
5 changes: 2 additions & 3 deletions toolchain/chidori-core/src/cells/llm_prompt_cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::library::std::ai::llm::ai_llm_run_embedding_model;
pub fn llm_prompt_cell(execution_state_id: ExecutionNodeId, cell: &LLMPromptCell, range: &TextRange) -> anyhow::Result<OperationNode> {
match cell {
llm_prompt_cell @ LLMPromptCell::Chat {
function_invocation,
is_function_invocation: function_invocation,
name,
provider,
complete_body,
Expand Down Expand Up @@ -105,13 +105,12 @@ pub fn llm_prompt_cell(execution_state_id: ExecutionNodeId, cell: &LLMPromptCell

pub fn llm_prompt_cell_exec_chat_openai(llm_prompt_cell: LLMPromptCell) -> Box<OperationFn> {
let LLMPromptCell::Chat {
function_invocation,
is_function_invocation,
name,
provider,
complete_body,
..
} = llm_prompt_cell else { unreachable!() };
let is_function_invocation = function_invocation;
let (frontmatter, req) = chidori_prompt_format::templating::templates::split_frontmatter(&complete_body).map_err(|e| {
anyhow::Error::msg(e.to_string())
}).unwrap();
Expand Down
23 changes: 13 additions & 10 deletions toolchain/chidori-core/src/cells/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ pub struct LLMPromptCellChatConfiguration {
pub enum LLMPromptCell {
Chat {
backing_file_reference: Option<BackingFileReference>,
function_invocation: bool,
is_function_invocation: bool,
configuration: LLMPromptCellChatConfiguration,
name: Option<String>,
provider: SupportedModelProviders,
Expand Down Expand Up @@ -506,14 +506,17 @@ impl Ord for CellTypes {
}
}

pub fn get_cell_name(cell: &CellTypes) -> &Option<String> {
match &cell {
CellTypes::Code(c, _) => &c.name,
CellTypes::Prompt(c, _) => match c {
LLMPromptCell::Chat { name, .. } => name,
LLMPromptCell::Completion { .. } => &None,
},
CellTypes::Template(c, _) => &c.name,
CellTypes::CodeGen(c, _) => &c.name
impl CellTypes {
pub fn name(&self) -> &Option<String> {
match &self {
CellTypes::Code(c, _) => &c.name,
CellTypes::Prompt(c, _) => match c {
LLMPromptCell::Chat { name, .. } => name,
LLMPromptCell::Completion { .. } => &None,
},
CellTypes::Template(c, _) => &c.name,
CellTypes::CodeGen(c, _) => &c.name
}
}
}

Loading

0 comments on commit d2a927f

Please sign in to comment.