Struct openai_safe::OpenAIFile
source · pub struct OpenAIFile {
pub id: String,
/* private fields */
}
Fields§
§id: String
Implementations§
source§impl OpenAIFile
impl OpenAIFile
sourcepub async fn new(
file_bytes: Vec<u8>,
open_ai_key: &str,
debug: bool
) -> Result<Self>
pub async fn new( file_bytes: Vec<u8>, open_ai_key: &str, debug: bool ) -> Result<Self>
Examples found in repository?
examples/use_openai_assistant.rs (line 28)
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
async fn main() -> Result<()> {
env_logger::init();
let api_key: String = std::env::var("OPENAI_API_KEY").expect("OPENAI_API_KEY not set");
// Read invoice file
let path = Path::new("examples/sample-bill.pdf");
let bytes = std::fs::read(path)?;
let openai_file = OpenAIFile::new(bytes, &api_key, true).await?;
// Extract invoice detail using Assistant API
let invoice = OpenAIAssistant::new(OpenAIModels::Gpt4Turbo, &api_key, true)
.await?
.get_answer::<Invoice>(
"Extract the following information from the attached invoice: invoice number, vendor name, payment amount, payment date.",
&[openai_file.id],
)
.await?;
println!("Invoice: {:?}", invoice);
Ok(())
}
Trait Implementations§
source§impl Clone for OpenAIFile
impl Clone for OpenAIFile
source§fn clone(&self) -> OpenAIFile
fn clone(&self) -> OpenAIFile
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for OpenAIFile
impl Debug for OpenAIFile
source§impl<'de> Deserialize<'de> for OpenAIFile
impl<'de> Deserialize<'de> for OpenAIFile
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl RefUnwindSafe for OpenAIFile
impl Send for OpenAIFile
impl Sync for OpenAIFile
impl Unpin for OpenAIFile
impl UnwindSafe for OpenAIFile
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more