llmrix-rust-sdk 1.0.0

Official Rust SDK for the llmrix AI Agent Platform API
Documentation
use std::sync::Arc;
use crate::{error::Result, model::*, transport::*};

/// Operations on the Conversations API. Obtain via [`LlmrixClient::conversations`].
pub struct ConversationsResource {
    pub(crate) t: Arc<Transport>,
}

impl ConversationsResource {
    /// Create a new conversation.
    pub async fn create(&self, req: ConversationCreateRequest) -> Result<Conversation> {
        self.t.post(&path_conversations(), &req).await
    }

    /// List conversations (cursor pagination). Pass `last_id = 0` to start from the beginning.
    pub async fn list(&self, last_id: i64, size: u32) -> Result<PageResult<Conversation>> {
        let path = format!("{}?lastId={}&size={}", path_conversations(), last_id, size);
        self.t.get(&path).await
    }

    /// Retrieve a single conversation by ID.
    pub async fn get(&self, id: &str) -> Result<Conversation> {
        self.t.get(&path_conversation(id)).await
    }

    /// Update a conversation's metadata (title).
    pub async fn update(&self, id: &str, req: ConversationUpdateRequest) -> Result<Conversation> {
        self.t.patch(&path_conversation(id), &req).await
    }

    /// Permanently delete a conversation and all of its messages.
    pub async fn delete(&self, id: &str) -> Result<()> {
        self.t.delete(&path_conversation(id)).await
    }

    /// Return a page of messages in the given conversation.
    pub async fn messages(&self, id: &str, last_id: i64, size: u32) -> Result<PageResult<Message>> {
        let path = format!("{}?lastId={}&size={}", path_messages(id), last_id, size);
        self.t.get(&path).await
    }
}