Skip to content

Instantly share code, notes, and snippets.

@sachaarbonel
Created November 5, 2022 21:29
Show Gist options
  • Save sachaarbonel/dfd8e52a7a69dc4a59ff1fa7b8b9958e to your computer and use it in GitHub Desktop.
Save sachaarbonel/dfd8e52a7a69dc4a59ff1fa7b8b9958e to your computer and use it in GitHub Desktop.
#[derive(Debug)]
pub struct EmbeddedBook {
pub title: String,
pub author: String,
pub summary: String,
pub embeddings: [f32; 384],
}
impl Book {
fn to_embedded(self, embeddings: [f32; 384]) -> EmbeddedBook {
EmbeddedBook {
title: self.title,
author: self.author,
summary: self.summary,
embeddings: embeddings,
}
}
}
// convenient to convert a slice to a fixed size array
fn to_array(barry: &[f32]) -> [f32; 384] {
barry.try_into().expect("slice with incorrect length")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment