neuromance_common/
lib.rs

1//! # neuromance-common
2//!
3//! Common types and data structures for LLM conversation and tool management.
4//!
5//! This crate provides the foundational types for building LLM-powered applications:
6//! - Conversation and message management
7//! - Tool/function calling support
8//! - Serializable data structures for persistence and API communication
9//!
10//! ## Example
11//!
12//! ```
13//! use neuromance_common::{Conversation, Message, ToolCall, Tool, Function};
14//! use uuid::Uuid;
15//!
16//! // Create a new conversation
17//! let conv = Conversation::new()
18//!     .with_title("Time Assistant")
19//!     .with_description("Helping users get the current time");
20//!
21//! // Add a user message
22//! let msg = Message::user(conv.id, "What time is it?");
23//!
24//! // Define a tool using the builder pattern
25//! let tool = Tool::builder()
26//!     .function(Function {
27//!         name: "get_current_time".to_string(),
28//!         description: "Get the current date and time in UTC format. Takes no parameters.".to_string(),
29//!         parameters: serde_json::json!({
30//!             "type": "object",
31//!             "properties": {},
32//!             "required": [],
33//!         }),
34//!     })
35//!     .build();
36//!
37//! // Or using struct initialization (the r#type field defaults to "function")
38//! let tool_alt = Tool {
39//!     r#type: "function".to_string(),
40//!     function: Function {
41//!         name: "get_current_time".to_string(),
42//!         description: "Get the current date and time in UTC format. Takes no parameters.".to_string(),
43//!         parameters: serde_json::json!({
44//!             "type": "object",
45//!             "properties": {},
46//!             "required": [],
47//!         }),
48//!     },
49//! };
50//!
51//! // Create a tool call using the into() conversion
52//! let tool_call = ToolCall::new("get_current_time", Vec::<String>::new());
53//! ```
54
55/// Chat conversation and message types.
56///
57/// Provides types for managing conversations, messages, and message roles.
58pub mod chat;
59/// Client configuration and request/response types.
60///
61/// Contains types for configuring LLM clients and making chat completion requests.
62pub mod client;
63/// Tool calling and function execution types.
64///
65/// Provides types for defining and executing functions/tools that LLMs can call.
66pub mod tools;
67
68pub mod agents;
69
70pub use agents::{AgentContext, AgentMemory, AgentMessage, AgentResponse, AgentState, AgentStats};
71pub use chat::{Conversation, ConversationStatus, Message, MessageRole};
72pub use client::{ChatRequest, ChatResponse, Config, FinishReason, RetryConfig, ToolChoice, Usage};
73pub use tools::{Function, FunctionCall, Parameters, Property, Tool, ToolApproval, ToolCall};