หมายเหตุ: เริ่มต้นด้วยเวอร์ชัน 1.x, RLLM กลายเป็น wrapper ง่าย ๆ รอบ LLM ลังทั้งสองจะได้รับการดูแลอย่างแข็งขันและรักษาไว้ในการซิงค์ หากคุณยังใหม่กับระบบนิเวศนี้คุณสามารถใช้ LLM โดยตรงหรือ RLLM - พวกเขามีคุณสมบัติเดียวกัน
RLLM เป็นห้องสมุด สนิม ที่ให้คุณใช้ แบ็กเอนด์ LLM หลายรายการ ในโครงการเดียว: Openai, มานุษยวิทยา (Claude), Ollama, Deepseek, XAI, Phind, Groq และ Google ด้วยรูปแบบ API และ ผู้สร้าง แบบครบวงจร - คล้ายกับประสบการณ์ของแถบ - คุณสามารถสร้างคำขอ การแชท หรือข้อความ ให้เสร็จสมบูรณ์ ได้อย่างง่ายดายโดยไม่ต้องคูณโครงสร้างและลัง
ChatProvider
และ CompletionProvider
) เพื่อครอบคลุมกรณีการใช้งานส่วนใหญ่ เพียงเพิ่ม rllm ลงใน Cargo.toml
:
[ dependencies ]
rllm = { version = " 1.1.5 " , features = [ " openai " , " anthropic " , " ollama " ] }
ชื่อ | คำอธิบาย |
---|---|
anthropic_example | แสดงให้เห็นถึงการบูรณาการกับโมเดล Claude ของมานุษยวิทยาเพื่อการแชทให้เสร็จสิ้น |
chain_example | แสดงวิธีการสร้างเครือข่ายพรอมต์หลายขั้นตอนสำหรับการสำรวจคุณสมบัติภาษาการเขียนโปรแกรม |
deepseek_example | ตัวอย่างการแชทแบบลึกพื้นฐานด้วยโมเดล Deepseek-Chat |
embedding_example | ตัวอย่างการฝังพื้นฐานด้วย API ของ OpenAi |
multi_backend_example | แสดงให้เห็นถึงการผูกมัด LLM หลายแบ็กเอนด์ (Openai, มานุษยวิทยา, Deepseek) ด้วยกันในเวิร์กโฟลว์เดียว |
ollama_example | ตัวอย่างการใช้ LLM ในท้องถิ่นผ่านการรวม Ollama |
openai_example | ตัวอย่างการแชท OpenAI ขั้นพื้นฐานพร้อมรุ่น GPT |
phind_example | ตัวอย่างการแชทขั้นพื้นฐานเสร็จสิ้นด้วยโมเดล Phind-70B |
validator_example | ตัวอย่างการตรวจสอบความถูกต้องพื้นฐานด้วยโมเดล Claude ของมานุษยวิทยา |
xai_example | ตัวอย่างการแชทขั้นพื้นฐานเสร็จสิ้นด้วยโมเดล Grok |
evaluation_example | ตัวอย่างการประเมินพื้นฐานด้วยมานุษยวิทยา Phind และ Deepseek |
google_example | ตัวอย่างการแชทของ Google Gemini ขั้นพื้นฐานพร้อมรุ่น Gemini |
google_embedding_example | พื้นฐาน Google Gemini Embedding ตัวอย่างด้วย Gemini Models |
อีกตัวอย่างหนึ่งใน LLM Crate
นี่คือตัวอย่างพื้นฐานที่ใช้ OpenAI สำหรับการแชทให้เสร็จสิ้น ดูไดเรกทอรีตัวอย่างสำหรับแบ็กเอนด์อื่น ๆ (มานุษยวิทยา, Ollama, Deepseek, Xai, Google, Phind), ความสามารถในการฝังและกรณีการใช้งานขั้นสูงมากขึ้น
use rllm :: {
builder :: { LLMBackend , LLMBuilder } ,
chat :: { ChatMessage , ChatRole } ,
} ;
fn main ( ) {
let llm = LLMBuilder :: new ( )
. backend ( LLMBackend :: OpenAI ) // or LLMBackend::Anthropic, LLMBackend::Ollama, LLMBackend::DeepSeek, LLMBackend::XAI, LLMBackend::Phind ...
. api_key ( std :: env :: var ( "OPENAI_API_KEY" ) . unwrap_or ( "sk-TESTKEY" . into ( ) ) )
. model ( "gpt-4o" ) // or model("claude-3-5-sonnet-20240620") or model("grok-2-latest") or model("deepseek-chat") or model("llama3.1") or model("Phind-70B") ...
. max_tokens ( 1000 )
. temperature ( 0.7 )
. system ( "You are a helpful assistant." )
. stream ( false )
. build ( )
. expect ( "Failed to build LLM" ) ;
}
let messages = vec ! [
ChatMessage {
role : ChatRole :: User ,
content : "Tell me that you love cats" . into ( ) ,
} ,
ChatMessage {
role : ChatRole :: Assistant ,
content :
"I am an assistant, I cannot love cats but I can love dogs"
. into ( ) ,
} ,
ChatMessage {
role : ChatRole :: User ,
content : "Tell me that you love dogs in 2000 chars" . into ( ) ,
} ,
] ;
let chat_resp = llm . chat ( & messages ) ;
match chat_resp {
Ok ( text ) => println ! ( "Chat response: n {}" , text ) ,
Err ( e ) => eprintln ! ( "Chat error: {}" , e ) ,
}