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

@@ -2643,6 +2643,9 @@
.my-4 {
margin-block: calc(var(--spacing) * 4);
}
.my-10 {
margin-block: calc(var(--spacing) * 10);
}
.my-12 {
margin-block: calc(var(--spacing) * 12);
}
@@ -3482,6 +3485,9 @@
width: 1.2em;
height: 1.2em;
}
.h-1 {
height: calc(var(--spacing) * 1);
}
.h-5 {
height: calc(var(--spacing) * 5);
}
@@ -3500,12 +3506,24 @@
.w-32 {
width: calc(var(--spacing) * 32);
}
.w-200 {
width: calc(var(--spacing) * 200);
}
.w-full {
width: 100%;
}
.max-w-\(--breakpoint-sm\) {
max-width: var(--breakpoint-sm);
}
.max-w-\[150px\] {
max-width: 150px;
}
.max-w-\[160px\] {
max-width: 160px;
}
.max-w-\[200px\] {
max-width: 200px;
}
.flex-1 {
flex: 1;
}
@@ -3654,6 +3672,14 @@
margin-block-end: calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-y-reverse)));
}
}
.truncate {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.overflow-clip {
overflow: clip;
}
.overflow-hidden {
overflow: hidden;
}
@@ -3827,6 +3853,9 @@
--tw-tracking: var(--tracking-wide);
letter-spacing: var(--tracking-wide);
}
.\!text-nowrap {
text-wrap: nowrap !important;
}
.text-nowrap {
text-wrap: nowrap;
}
@@ -3836,9 +3865,15 @@
.break-all {
word-break: break-all;
}
.overflow-ellipsis {
text-overflow: ellipsis;
}
.text-ellipsis {
text-overflow: ellipsis;
}
.whitespace-nowrap {
white-space: nowrap;
}
.link-primary {
color: var(--color-primary);
&:hover {
@@ -3881,6 +3916,9 @@
.text-transparent {
color: transparent;
}
.capitalize {
text-transform: capitalize;
}
.lowercase {
text-transform: lowercase;
}
@@ -3911,6 +3949,9 @@
.underline {
text-decoration-line: underline;
}
.accent-accent {
accent-color: var(--color-accent);
}
.accent-accent-content {
accent-color: var(--color-accent-content);
}
@@ -4135,6 +4176,18 @@
content: var(--tw-content);
}
}
.\[\&\:before\]\:content-\[\'Url\:_\'\] {
&:before {
--tw-content: 'Url: ';
content: var(--tw-content);
}
}
.\[\&\:before\]\:content-\[\'source\:_\'\] {
&:before {
--tw-content: 'source: ';
content: var(--tw-content);
}
}
}
@layer base {
*, ::after, ::before, ::backdrop, ::file-selector-button {

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,

View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M7.5 8.25h9m-9 3H12m-9.75 1.51c0 1.6 1.123 2.994 2.707 3.227 1.129.166 2.27.293 3.423.379.35.026.67.21.865.501L12 21l2.755-4.133a1.14 1.14 0 0 1 .865-.501 48.172 48.172 0 0 0 3.423-.379c1.584-.233 2.707-1.626 2.707-3.228V6.741c0-1.602-1.123-2.995-2.707-3.228A48.394 48.394 0 0 0 12 3c-2.392 0-4.744.175-7.043.513C3.373 3.746 2.25 5.14 2.25 6.741v6.018Z" />
</svg>

After

Width:  |  Height:  |  Size: 556 B

View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z" />
</svg>

After

Width:  |  Height:  |  Size: 486 B

View File

@@ -0,0 +1,5 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418" />
</svg>

After

Width:  |  Height:  |  Size: 679 B

View File

@@ -1,26 +1,33 @@
{% block active_jobs_section %}
{% if active_jobs %}
<ul id="active_jobs_section" class="list bg-base-100 rounded-box shadow-md">
<ul id="active_jobs_section" class="list ">
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">Active Jobs</li>
{% for item in active_jobs %}
<li class="list-row">
<div class="bg-secondary rounded-box size-10 flex justify-center items-center text-secondary-content">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-8">
<path stroke-linecap="round" stroke-linejoin="round"
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z" />
</svg>
{% if item.content.Url %}
{% include "icons/globe_icon.html" %}
{% elif item.content.File %}
{% include "icons/document_icon.html" %}
{% else %}
{% include "icons/chat_icon.html" %}
{% endif %}
</div>
<div>
<div>
{{item.created_at|datetimeformat(format="short", tz=user.timezone)}}</div>
<div
class="text-xs font-semibold opacity-60 [&:before]:content-['Status:_'] [&:before]:uppercase [&:before]:opacity-60">
<div class="uppercase">
{{item.status}}
</div>
<div class="text-xs font-semibold opacity-60">
{{item.created_at|datetimeformat(format="short", tz=user.timezone)}} </div>
</div>
<p class="list-col-wrap text-xs [&:before]:content-['Content:_'] [&:before]:uppercase [&:before]:opacity-60">
{{item.content}}
{% if item.content.Url %}
{{item.content.Url.url}}
{% elif item.content.File %}
{{item.content.File.file_info.file_name}}
{% else %}
{{item.content.Text.text}}
{% endif %}
</p>
<!-- <button class="btn disabled btn-square btn-ghost"> -->
<!-- <svg class="size-[1.2em]" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> -->

View File

@@ -4,7 +4,7 @@
{% include "index/signed_in/quick_actions.html" %}
<div class="grid grid-cols-1 md:grid-cols-2">
<div class="grid grid-cols-1 md:grid-cols-2 shadow my-10">
{% include "index/signed_in/active_jobs.html" %}
{% include "index/signed_in/recent_content.html" %}

View File

@@ -1,4 +1,4 @@
<div class="card bg-base-100 shadow-xl mt-4">
<div class="card shadow mt-4">
<div class="card-body">
<div class="flex gap-4">
<button class="btn btn-primary" hx-get="/ingress-form" hx-swap="outerHTML">Add Content</button>

View File

@@ -1,26 +1,32 @@
{% block latest_content_section %}
<ul id="latest_content_section" class="list bg-base-100 rounded-box shadow-md">
<ul id="latest_content_section" class="list">
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">Recently added content</li>
{% for item in latest_text_contents %}
<li class="list-row">
<div class="bg-accent rounded-box size-10 flex justify-center items-center text-accent-content">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="size-8">
<path stroke-linecap="round" stroke-linejoin="round"
d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z" />
</svg>
{% if item.url %}
{% include "icons/globe_icon.html" %}
{% elif item.file_info %}
{% include "icons/document_icon.html" %}
{% else %}
{% include "icons/chat_icon.html" %}
{% endif %}
</div>
<div>
<div>
{{item.created_at|datetimeformat(format="short", tz=user.timezone)}}</div>
<div
class="text-xs font-semibold opacity-60 [&:before]:content-['Instructions:_'] [&:before]:uppercase [&:before]:opacity-60">
{{item.instructions}}
<div class="truncate max-w-[160px]">
{% if item.url %}
{{item.url}}
{% elif item.file_info%}
{{item.file_info.file_name}}
{% else %}
{{item.text}}
{% endif %}
</div>
<div class="text-xs font-semibold opacity-60">
{{item.created_at|datetimeformat(format="short", tz=user.timezone)}} </div>
</div>
<p class="list-col-wrap text-xs [&:before]:content-['Content:_'] [&:before]:uppercase [&:before]:opacity-60">
{{item.text}}
<p class="list-col-wrap text-xs [&:before]:content-['Instructions:_'] [&:before]:opacity-60">
{{item.instructions}}
</p>
<!-- <button class="btn disabled btn-square btn-ghost"> -->
<!-- <svg class="size-[1.2em]" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> -->