Created
November 5, 2022 21:29
-
-
Save sachaarbonel/dfd8e52a7a69dc4a59ff1fa7b8b9958e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[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