Skip to content

0xhappyboy/langhub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

langhub

An LLM application development framework based on Rust.

License

简体中文 | English

Install

cargo add langhub
[dependencies]
langhub = "0.1.1"

Basic Usage

Generate a welcome message with OpenAI

use langhub_macros::chat;

#[chat(msg = "Write a welcome message for a developer tool", type = "openai")]
fn generate_welcome() -> Result<String, Box<dyn std::error::Error>> {
println!("Generated: {}", llm_response);
Ok(llm_response)
}

Reply to user using DeepSeek

use langhub_macros::chat;

#[chat(msg = format!("Reply to the user in a friendly tone: {}", user_input), type = "deepseek")]
fn reply_to_user(user_input: String) -> Result<String, Box<dyn std::error::Error>> {
    println!("AI reply: {}", llm_response);
    Ok(llm_response)
}

Analyze sentiment with Anthropic

use langhub_macros::chat;

#[chat(msg = format!("Analyze the sentiment (positive/negative/neutral) of this text:\n{}", text), type = "anthropic")]
fn analyze_sentiment(text: String) -> Result<String, Box<dyn std::error::Error>> {
    match llm_response {
        Ok(sentiment) => {
            println!("Sentiment analysis result: {}", sentiment);
            Ok(sentiment)
        }
        Err(e) => {
            eprintln!("Analysis failed: {}", e);
            Err(e.into())
        }
    }
}

About

An LLM application development framework based on Rust.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages