1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
use ;
use crateResponse;
use Client;
/// Sends a message to the LLM
///
/// # Arguments
/// * `data` - The data which will be sent to the API
/// * `url` - The URL for the API.
///
/// # Returns
/// A `Result` containing a `Response` on success, or a `reqwest::Error` on failure.
///
/// # Examples
/// ```rust
/// use simple_llama_rs::{
/// ModelMemory, ModelOptions, DEFAULT_URL, chat::MessageMethods, send_message
/// };
///
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let mut messages: ModelMemory = Vec::new();
///
/// // Create model options
/// let model_data = ModelOptions {
/// messages,
/// temperature: 0.7,
/// top_p: 1.0,
/// top_k: 1,
/// model: "llama3.1".to_string(),
/// stream: false,
/// };
///
/// // Send message to the model
/// let response = send_message(&model_data, DEFAULT_URL).await?;
///
/// // Get the content from the response
/// let content = response.get_llm_content();
/// println!("Model response: {}", content);
///
/// Ok(())
/// }
/// ```
pub async
/// Copies a model under a new name.
///
/// # Arguments
/// * `copy_info` - The information required to copy the model, including source and destination names.
/// * `url` - The URL for the API endpoint that handles model copying. Make sure to use the correct one. Otherwise it won't work
///
/// # Returns
/// A `Result` containing a `Response` on success, or a `reqwest::Error` on failure.
///
/// # Examples
/// ```rust
/// use simple_llama_rs::{CopyInfo, copy_model, DEFAULT_COPY_URL};
///
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let copy_info = CopyInfo {
/// source: "llama3.1".to_string(),
/// destination: "llama_llm".to_string(),
/// };
///
/// let response = copy_model(©_info, DEFAULT_COPY_URL).await?;
/// println!("Copy status: {}", response.status_code);
///
/// Ok(())
/// }
/// ```
pub async
/// Deletes a model.
///
/// # Arguments
/// * `delete_info` - The information required to delete the model, including the model name.
/// * `url` - The URL for the API endpoint that handles model deletion. Make sure to use the correct one.
///
/// # Returns
/// A `Result` containing a `Response` on success, or a `reqwest::Error` on failure.
///
/// # Examples
/// ```rust
/// use simple_llama_rs::{DeleteInfo, delete_model, DEFAULT_URL};
///
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let delete_info = DeleteInfo {
/// model: "llama_model".to_string(),
/// };
///
/// let response = delete_model(&delete_info, DEFAULT_URL).await?;
/// println!("Delete status: {}", response.status_code);
///
/// Ok(())
/// }
/// ```
pub async
// You can unignore this if you want to wait an hour for a model to pull
/// Pulls a model from https://ollama.com.
///
/// # Arguments
/// * `pull_info` - The information required to pull the model, including the model name.
/// * `url` - The URL for the API endpoint that handles model pulling. Make sure to use the correct one.
///
/// # Returns
/// A `Result` containing a `Response` on success, or a `reqwest::Error` on failure.
///
/// # Examples
/// ```ignore
/// use simple_llama_rs::{PullInfo, pull_model, DEFAULT_PULL_URL};
///
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// let pull_info = PullInfo {
/// model: "llama3.1".to_string(),
/// insecure: false,
/// stream: false,
/// };
///
/// let response = pull_model(&pull_info, DEFAULT_PULL_URL).await?;
/// println!("Pull status: {}", response.status_code);
///
/// Ok(())
/// }
/// ```
pub async