Crate aiassistant

Source
Expand description

OpenAI API Rust Client

This library provides a simple interface to interact with OpenAI’s API.

§Example

use aiassistant::{OpenAIClient, ChatMessage, Role};
 
#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = OpenAIClient::new("your-api-key");
    let messages = vec![
        ChatMessage::new(Role::System, "You are a helpful assistant."),
        ChatMessage::new(Role::User, "Hello!"),
    ];
     
    let response = client.chat_completion("gpt-3.5-turbo", messages).await?;
    println!("Assistant: {}", response);
    Ok(())
}

Structs§

ChatMessage
Represents a message in a chat conversation
OpenAIClient
OpenAI API client

Enums§

Role
Represents different roles in a chat conversation