Run open-source generative AI models in a lightweight, reliable, and customizable rust API.
This is a Rust project powered by Huggingface's Candle and Tokio's Axum. It focuses on text generation and image generation models.
cargo run --releasedisclaimer: This program is designed to run on limited hardware, prompts often take upwards of a minute to finish generating. This API chooses the prompt/polling stragety for standalone prompts to avoid http requests timing out due to a long async process on the server.
POST /prompt_polledGenerates text from a prompt, stored on the server for a limited amount of time, to be polled. Returns the id of your content.
Parameters:
GET /poll_text/{id}Polls the server for the generated text. Returns the generated text or an error if the id is invalid or the content has expired.
Parameters:
POST /new_streamingInitializes a model and sets up message history for a new streaming session. Returns the id of your content.
Parameters:
POST /prompt_streaming/{id} (Unstable Work in Progress)Generates text from a prompt and streams it token by token to the consumer, stores message history on the server for a limited amount of time
Parameters:
Mistral7b,
Mistral7b Instruct,
Mistral7b Instruct V02,
Mixtral (needs beefy gpu),
Mixtral Instruct (needs beefy gpu),
Mistral7b Quantized,
Mistral7b Instruct Quantized,
Mistral7b Instruct V02 Quantized,
Mixtral Quantized,
Mixtral Instruct Quantized,
Zephyr Alpha Quantized (fine tuned mixtral),
Zephyr Beta Quantized (fine tuned mixtral),
Dolphin Mixtral Quantized (fine tuned mixtral),
other llms coming soon...
pub trait TextGeneratorInner: Send + Sync {
fn run(&mut self, prompt: &str, sample_len: u32, sender: Sender<String>) -> anyhow::Result<()>;
}
impl YourModel {
pub fn new(arguments_of_your_choice: Args, or_none_at_all: Option<Args>) -> anyhow::Result<Self> {
...
}
}
TextGenerationModel enum in src/text_generation/utils.rs, this is what http requests will identify your model as:pub enum TextGenerationModel {
YourModelName,
...
}
match statement in src/text_generation/utils.rs:impl TextGenerator {
pub fn new(model: TextGenerationModel, args: &TextGenerationArgs) -> anyhow::Result<Self> {
match model {
TextGenerationModel::YourModelName => wrap(YourModel::new(args)?),
...
}
}
}
coming soon ...
20 commits
Rust
100.0%
Run open-source generative AI models in a lightweight, reliable, and customizable rust API.
This is a Rust project powered by Huggingface's Candle and Tokio's Axum. It focuses on text generation and image generation models.
cargo run --releasedisclaimer: This program is designed to run on limited hardware, prompts often take upwards of a minute to finish generating. This API chooses the prompt/polling stragety for standalone prompts to avoid http requests timing out due to a long async process on the server.
POST /prompt_polledGenerates text from a prompt, stored on the server for a limited amount of time, to be polled. Returns the id of your content.
Parameters:
GET /poll_text/{id}Polls the server for the generated text. Returns the generated text or an error if the id is invalid or the content has expired.
Parameters:
POST /new_streamingInitializes a model and sets up message history for a new streaming session. Returns the id of your content.
Parameters:
POST /prompt_streaming/{id} (Unstable Work in Progress)Generates text from a prompt and streams it token by token to the consumer, stores message history on the server for a limited amount of time
Parameters:
Mistral7b,
Mistral7b Instruct,
Mistral7b Instruct V02,
Mixtral (needs beefy gpu),
Mixtral Instruct (needs beefy gpu),
Mistral7b Quantized,
Mistral7b Instruct Quantized,
Mistral7b Instruct V02 Quantized,
Mixtral Quantized,
Mixtral Instruct Quantized,
Zephyr Alpha Quantized (fine tuned mixtral),
Zephyr Beta Quantized (fine tuned mixtral),
Dolphin Mixtral Quantized (fine tuned mixtral),
other llms coming soon...
pub trait TextGeneratorInner: Send + Sync {
fn run(&mut self, prompt: &str, sample_len: u32, sender: Sender<String>) -> anyhow::Result<()>;
}
impl YourModel {
pub fn new(arguments_of_your_choice: Args, or_none_at_all: Option<Args>) -> anyhow::Result<Self> {
...
}
}
TextGenerationModel enum in src/text_generation/utils.rs, this is what http requests will identify your model as:pub enum TextGenerationModel {
YourModelName,
...
}
match statement in src/text_generation/utils.rs:impl TextGenerator {
pub fn new(model: TextGenerationModel, args: &TextGenerationArgs) -> anyhow::Result<Self> {
match model {
TextGenerationModel::YourModelName => wrap(YourModel::new(args)?),
...
}
}
}
coming soon ...
20 commits
Rust
100.0%