refactor: renamed instructions to context

This commit is contained in:
Per Stark
2025-05-09 16:00:52 +02:00
parent 463c562ba7
commit 6ed49f7155
22 changed files with 111 additions and 123 deletions

View File

@@ -94,7 +94,7 @@ pub async fn show_text_content_edit_form(
#[derive(Deserialize)]
pub struct PatchTextContentParams {
instructions: String,
context: String,
category: String,
text: String,
}
@@ -106,14 +106,7 @@ pub async fn patch_text_content(
) -> Result<impl IntoResponse, HtmlError> {
User::get_and_validate_text_content(&id, &user.id, &state.db).await?;
TextContent::patch(
&id,
&form.instructions,
&form.category,
&form.text,
&state.db,
)
.await?;
TextContent::patch(&id, &form.context, &form.category, &form.text, &state.db).await?;
let text_contents = User::get_text_contents(&user.id, &state.db).await?;
let categories = User::get_user_categories(&user.id, &state.db).await?;

View File

@@ -29,7 +29,7 @@ use crate::html_state::HtmlState;
#[derive(Serialize)]
pub struct IndexPageData {
user: Option<User>,
latest_text_contents: Vec<TextContent>,
text_contents: Vec<TextContent>,
active_jobs: Vec<IngestionTask>,
conversation_archive: Vec<Conversation>,
}
@@ -39,20 +39,12 @@ pub async fn index_handler(
auth: AuthSessionType,
) -> Result<impl IntoResponse, HtmlError> {
let Some(user) = auth.current_user else {
return Ok(TemplateResponse::new_template(
"index/index.html",
IndexPageData {
user: None,
latest_text_contents: vec![],
active_jobs: vec![],
conversation_archive: vec![],
},
));
return Ok(TemplateResponse::redirect("/"));
};
let active_jobs = User::get_unfinished_ingestion_tasks(&user.id, &state.db).await?;
let latest_text_contents = User::get_latest_text_contents(&user.id, &state.db).await?;
let text_contents = User::get_latest_text_contents(&user.id, &state.db).await?;
let conversation_archive = User::get_user_conversations(&user.id, &state.db).await?;
@@ -60,7 +52,7 @@ pub async fn index_handler(
"index/index.html",
IndexPageData {
user: Some(user),
latest_text_contents,
text_contents,
active_jobs,
conversation_archive,
},

View File

@@ -54,7 +54,7 @@ pub async fn hide_ingress_form(
#[derive(Debug, TryFromMultipart)]
pub struct IngressParams {
pub content: Option<String>,
pub instructions: String,
pub context: String,
pub category: String,
#[form_data(limit = "10000000")] // Adjust limit as needed
#[form_data(default)]
@@ -68,7 +68,7 @@ pub async fn process_ingress_form(
) -> Result<impl IntoResponse, HtmlError> {
#[derive(Serialize)]
pub struct IngressFormData {
instructions: String,
context: String,
content: String,
category: String,
error: String,
@@ -78,7 +78,7 @@ pub async fn process_ingress_form(
return Ok(TemplateResponse::new_template(
"index/signed_in/ingress_form.html",
IngressFormData {
instructions: input.instructions.clone(),
context: input.context.clone(),
content: input.content.clone().unwrap_or_default(),
category: input.category.clone(),
error: "You need to either add files or content".to_string(),
@@ -98,7 +98,7 @@ pub async fn process_ingress_form(
let payloads = IngestionPayload::create_ingestion_payload(
input.content,
input.instructions,
input.context,
input.category,
file_infos,
user.id.as_str(),