pub struct GraphTrace { /* private fields */ }Expand description
Opinionated tracing helpers to build a Graph-style hierarchy in LangSmith:
- Root run named
Graph(RunType::Chain) - Step runs under root (e.g.
chatbot,should_continue,tools) - Nested runs under steps (e.g.
ChatOpenAI, tool runs)
This is intentionally generic: inputs/outputs are serde_json::Value so any app can
provide LangSmith-compatible payloads such as { \"messages\": [...] }.
Implementations§
Source§impl GraphTrace
impl GraphTrace
Sourcepub async fn start_root(
inputs: Value,
thread_id: Option<String>,
) -> Result<Self>
pub async fn start_root( inputs: Value, thread_id: Option<String>, ) -> Result<Self>
Starts the root Graph run (name: Graph, type: Chain) and POSTs it.
pub fn root_scope(&self) -> &RunScope
pub fn root_tracer(&self) -> &Tracer
Sourcepub async fn start_node_iteration(
&self,
node_name: &str,
inputs: Value,
) -> Result<RunScope>
pub async fn start_node_iteration( &self, node_name: &str, inputs: Value, ) -> Result<RunScope>
Starts a top-level step/node under the root run (POSTs it) and returns the scope. Use this for nodes like “chatbot”, “tools”, etc. that may contain nested runs.
Sourcepub async fn trace_llm_call(
&self,
parent_node: &RunScope,
llm_name: &str,
inputs: Value,
outputs: Value,
model_name: Option<&str>,
) -> Result<()>
pub async fn trace_llm_call( &self, parent_node: &RunScope, llm_name: &str, inputs: Value, outputs: Value, model_name: Option<&str>, ) -> Result<()>
Traces an LLM call within a parent node (e.g., within “chatbot”).
llm_name is typically “ChatOpenAI” or similar.
model_name is optional (e.g., “gpt-4o-mini”) and will be added to inputs if provided.
Sourcepub async fn trace_decision(
&self,
parent_node: &RunScope,
decision_name: &str,
inputs: Value,
outputs: Value,
) -> Result<()>
pub async fn trace_decision( &self, parent_node: &RunScope, decision_name: &str, inputs: Value, outputs: Value, ) -> Result<()>
Traces a routing/decision step (e.g., “should_continue”).
Auto Trait Implementations§
impl !RefUnwindSafe for GraphTrace
impl !UnwindSafe for GraphTrace
impl Freeze for GraphTrace
impl Send for GraphTrace
impl Sync for GraphTrace
impl Unpin for GraphTrace
impl UnsafeUnpin for GraphTrace
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more