pepperoni21 / ollama-rs

A Rust library allowing to interact with the Ollama API.
MIT License
367 stars 47 forks source link

Manual create GenerationContext with my Vec<i32> #42

Closed Vebnik closed 2 months ago

Vebnik commented 2 months ago

Hi all ! I apologize right away for what may be a stupid question. Please tell me how I can make a GenerationRequest with my context, which (let's assume) is stored in my database.

let some_raw_data: Vec<i32> = Chat::get_last_context();
let last_context: GenerationContext = GenerationContext(some_raw_data);

But this example will generate an error at the compilation stage

error[E0423]: cannot initialize a tuple struct which contains private fields
  --> src\some\module\name.rs:1:1
   |
1  |         let last_context: GenerationContext = GenerationContext(some_raw_data);
   |                                               ^^^^^^^^^^^^^^^^^
   |
note: constructor is not visible here due to private fields
  --> Long\Path\To\ollama-rs-0.1.8\src\generation\completion\mod.rs:91:30
   |
91 | pub struct GenerationContext(Vec<i32>);
   |                              ^^^^^^^^ private field

Is it possible to make this field public ? 😢