@@ -23,7 +23,17 @@ AMRS builds on top of [async-openai](https://github.com/64bit/async-openai) to p
2323 - OpenAI compatible providers (OpenAI, DeepInfra, etc.)
2424 - More on the way
2525
26- ## How to use
26+ ## How to Install
27+
28+ Run the following Cargo command in your project directory:
29+
30+ ` cargo add arms `
31+
32+ Or add the following line to your Cargo.toml:
33+
34+ ` arms = "0.0.1" `
35+
36+ ## How to Use
2737
2838Here's a simple example with the Weighted Round Robin (WRR) routing mode. Before running the code, make sure to set your provider API key in the environment variable by running ` export <PROVIDER>_API_KEY="your_openai_api_key" ` .
2939Here we use OpenAI as an example.
@@ -32,54 +42,60 @@ Here we use OpenAI as an example.
3242``` rust
3343# Make sure OPENAI_API_KEY is set in your environment variables before running this code .
3444
35- use tokio :: runtime :: Runtime ;
3645use arms :: client;
3746use arms :: types :: chat;
47+ use tokio :: runtime :: Runtime ;
3848
39- let config = client :: Config :: builder ()
40- . provider (" openai" )
41- . routing_mode (client :: RoutingMode :: WRR )
42- . model (
43- client :: ModelConfig :: builder ()
44- . name (" gpt-3.5-turbo" )
45- . weight (2 )
46- . build ()
47- . unwrap (),
48- )
49- . model (
50- client :: ModelConfig :: builder ()
51- . name (" gpt-4" )
52- . weight (1 )
53- . build ()
54- . unwrap (),
55- )
56- . build ()
57- . unwrap ();
58-
59- let mut client = client :: Client :: new (config );
60- let request = chat :: CreateChatCompletionRequestArgs :: default ()
61- . messages ([
62- chat :: ChatCompletionRequestSystemMessage :: from (" You are a helpful assistant." ). into (),
63- chat :: ChatCompletionRequestUserMessage :: from (" Who won the FIFA World Cup in 2025?" ). into (),
64- ])
65- . build ()
66- . unwrap ();
67-
68- let result = Runtime :: new (). unwrap (). block_on (client . create_completion (request ));
69- match result {
70- Ok (response ) => {
71- for choice in response . choices {
72- println! (" Response: {:?}" , choice . message. content);
49+ fn main () {
50+ let config = client :: Config :: builder ()
51+ . provider (" deepinfra" )
52+ . routing_mode (client :: RoutingMode :: WRR )
53+ . model (
54+ client :: ModelConfig :: builder ()
55+ . name (" deepseek-ai/DeepSeek-V3.2" )
56+ . weight (2 )
57+ . build ()
58+ . unwrap (),
59+ )
60+ . model (
61+ client :: ModelConfig :: builder ()
62+ . name (" nvidia/Nemotron-3-Nano-30B-A3B" )
63+ . weight (1 )
64+ . build ()
65+ . unwrap (),
66+ )
67+ . build ()
68+ . unwrap ();
69+
70+ let mut client = client :: Client :: new (config );
71+ let request = chat :: CreateChatCompletionRequestArgs :: default ()
72+ . messages ([
73+ chat :: ChatCompletionRequestSystemMessage :: from (" You are a helpful assistant." ). into (),
74+ chat :: ChatCompletionRequestUserMessage :: from (" How long it takes to learn Rust?" ). into (),
75+ ])
76+ . build ()
77+ . unwrap ();
78+
79+ let result = Runtime :: new ()
80+ . unwrap ()
81+ . block_on (client . create_completion (request ));
82+ match result {
83+ Ok (response ) => {
84+ for choice in response . choices {
85+ println! (" Response: {:?}" , choice . message. content);
86+ }
87+ }
88+ Err (e ) => {
89+ eprintln! (" Error: {}" , e );
7390 }
74- }
75- Err (e ) => {
76- eprintln! (" Error: {}" , e );
7791 }
7892}
7993```
8094
95+ See more examples [ here] ( /examples ) folder.
96+
8197## Contributing
8298
8399🚀 All kinds of contributions are welcomed ! Please follow [ Contributing] ( /CONTRIBUTING.md ) .
84100
85- [ ![ Star History Chart] ( https://api.star-history.com/svg?repos=inftyai/amrs&type=Date )] ( https://www.star-history.com/#inftyai/amrs&Date )
101+ [ ![ Star History Chart] ( https://api.star-history.com/svg?repos=inftyai/amrs&type=Date )] ( https://www.star-history.com/#inftyai/amrs&Date )
0 commit comments