feat: additional variables to database structs & display

This commit is contained in:
Per Stark
2025-01-29 15:50:43 +01:00
parent 0fe253a127
commit fd769018ce
12 changed files with 126 additions and 35 deletions

View File

@@ -41,13 +41,15 @@ pub fn create_ingress_objects(
});
}
Err(_) => {
info!("Treating input as plain text");
object_list.push(IngressObject::Text {
text: input_content.to_string(),
instructions: input.instructions.clone(),
category: input.category.clone(),
user_id: user_id.into(),
});
if input_content.len() > 2 {
info!("Treating input as plain text");
object_list.push(IngressObject::Text {
text: input_content.to_string(),
instructions: input.instructions.clone(),
category: input.category.clone(),
user_id: user_id.into(),
});
}
}
}
}

View File

@@ -14,7 +14,6 @@ use serde::{Deserialize, Serialize};
use std::fmt::Write;
use tiktoken_rs::{o200k_base, CoreBPE};
/// Knowledge object type, containing the content or reference to it, as well as metadata
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum IngressObject {
Url {
@@ -62,6 +61,7 @@ impl IngressObject {
instructions.into(),
category.into(),
None,
Some(url.into()),
user_id.into(),
))
}
@@ -75,6 +75,7 @@ impl IngressObject {
instructions.into(),
category.into(),
None,
None,
user_id.into(),
)),
IngressObject::File {
@@ -89,6 +90,7 @@ impl IngressObject {
instructions.into(),
category.into(),
Some(file_info.to_owned()),
None,
user_id.into(),
))
}

View File

@@ -39,6 +39,7 @@ pub enum FileError {
stored_object!(FileInfo, "file", {
sha256: String,
path: String,
file_name: String,
mime_type: String
});
@@ -77,6 +78,7 @@ impl FileInfo {
id: uuid.to_string(),
created_at: now,
updated_at: now,
file_name,
sha256,
path: Self::persist_file(&uuid, file, &sanitized_file_name, user_id)
.await?

View File

@@ -7,6 +7,8 @@ use super::file_info::FileInfo;
stored_object!(TextContent, "text_content", {
text: String,
file_info: Option<FileInfo>,
url: Option<String>,
instructions: String,
category: String,
user_id: String
@@ -18,6 +20,7 @@ impl TextContent {
instructions: String,
category: String,
file_info: Option<FileInfo>,
url: Option<String>,
user_id: String,
) -> Self {
let now = Utc::now();
@@ -27,6 +30,7 @@ impl TextContent {
updated_at: now,
text,
file_info,
url,
instructions,
category,
user_id,