Expand description
§neuromance-common
Common types and data structures for LLM conversation and tool management.
This crate provides the foundational types for building LLM-powered applications:
- Conversation and message management
- Tool/function calling support
- Serializable data structures for persistence and API communication
§Example
use neuromance_common::{Conversation, Message, ToolCall, Tool, Function};
use uuid::Uuid;
// Create a new conversation
let conv = Conversation::new()
.with_title("Time Assistant")
.with_description("Helping users get the current time");
// Add a user message
let msg = Message::user(conv.id, "What time is it?");
// Define a tool using the builder pattern
let tool = Tool::builder()
.function(Function {
name: "get_current_time".to_string(),
description: "Get the current date and time in UTC format. Takes no parameters.".to_string(),
parameters: serde_json::json!({
"type": "object",
"properties": {},
"required": [],
}),
})
.build();
// Or using struct initialization (the r#type field defaults to "function")
let tool_alt = Tool {
r#type: "function".to_string(),
function: Function {
name: "get_current_time".to_string(),
description: "Get the current date and time in UTC format. Takes no parameters.".to_string(),
parameters: serde_json::json!({
"type": "object",
"properties": {},
"required": [],
}),
},
};
// Create a tool call using the into() conversion
let tool_call = ToolCall::new("get_current_time", Vec::<String>::new());Re-exports§
pub use agents::AgentContext;pub use agents::AgentMemory;pub use agents::AgentMessage;pub use agents::AgentResponse;pub use agents::AgentState;pub use agents::AgentStats;pub use chat::Conversation;pub use chat::ConversationStatus;pub use chat::Message;pub use chat::MessageRole;pub use client::ChatRequest;pub use client::ChatResponse;pub use client::Config;pub use client::FinishReason;pub use client::RetryConfig;pub use client::ToolChoice;pub use client::Usage;pub use tools::Function;pub use tools::FunctionCall;pub use tools::Parameters;pub use tools::Property;pub use tools::Tool;pub use tools::ToolApproval;pub use tools::ToolCall;