openai-safe

Crates.ioopenai-safe
lib.rsopenai-safe
version0.2.4
sourcesrc
created_at2023-11-17 05:03:10.827028
updated_at2023-11-25 16:41:30.968419
descriptionOpenAI Framework for Rust
homepage
repositoryhttps://github.com/neferdata/openai-typesafe-rs
max_upload_size
id1038709
size599,714
(kamillitman)

documentation

README

OpenAI Typesafe Rust Library

crates.io docs.rs

This Rust library is specialized in providing type-safe interactions with the OpenAI API. It's designed to simplify the process of sending requests to OpenAI and interpreting the responses, ensuring that the JSON data is handled in a type-safe manner. This guarantees that the data conforms to predefined structures, reducing runtime errors and increasing the reliability of applications using OpenAI's powerful AI models like GPT-3.5 and GPT-4.

Features

  • Support for various OpenAI models including GPT-3.5, GPT-4, etc.
  • Easy-to-use functions for completions, chat responses, and other OpenAI features.
  • Structured response handling.
  • Rate limit handling.
  • Asynchronous support using Tokio.

Prerequisites

  • An OpenAI API key.

Examples

Explore the examples directory to see more use cases and how to handle different types of responses from the OpenAI API.

This is the output of calling the assistant api with metallica.pdf

RUST_LOG=info RUST_BACKTRACE=1 cargo run --example use_openai_assistant

This program will send this press release to OpenAI Assistant API and get the data requested in the response type back:

pub struct ConcertInfo {
    dates: Vec<String>,
    band: String,
    venue: String,
    city: String,
    country: String,
    ticket_price: String,
}

Output:

Running `target/debug/examples/use_openai_assistant`

ConcertInfo { dates: ["Friday September 6, 2019"], band: "Metallica and the San Francisco Symphony", venue: "Chase Center", city: "San Francisco", country: "USA", ticket_price: "Information not available" }

License

This project is licensed under dual MIT/Apache-2.0 license. See the LICENSE-MIT and LICENSE-APACHE files for details.

Commit count: 13

cargo fmt