mirror of
https://github.com/perstarkse/minne.git
synced 2026-11-13 11:03:29 +01:00
knowledge type select instead of input
This commit is contained in:
1 parent
813e454f89
commit
d0ab590d1d
4 files changed
+37
-17
No files matched your search
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
/*! tailwindcss v4.0.0-beta.9 | MIT License | https://tailwindcss.com */
|
/*! tailwindcss v4.0.0-beta.9 | MIT License | https://tailwindcss.com */
|
||||||
@layer theme{:root{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-serif:ui-serif,Georgia,Cambria,"Times New Roman",Times,serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(.971 .013 17.38);--color-red-100:oklch(.936 .032 17.717);--color-red-200:oklch(.885 .062 18.334);--color-red-300:oklch(.808 .114 19.571);--color-red-400:oklch(.704 .191 22.216);--color-red-500:oklch(.637 .237 25.331);--color-red-600:oklch(.577 .245 27.325);--color-red-700:oklch(.505 .213 27.518);--color-red-800:oklch(.444 .177 26.899);--color-red-900:oklch(.396 .141 25.723);--color-red-950:oklch(.258 .092 26.042);--color-orange-50:oklch(.98 .016 73.684);--color-orange-100:oklch(.954 .038 75.164);--color-orange-200:oklch(.901 .076 70.697);--color-orange-300:oklch(.837 .128 66.29);--color-orange-400:oklch(.75 .183 55.934);--color-orange-500:oklch(.705 .213 47.604);--color-orange-600:oklch(.646 .222 41.116);--color-orange-700:oklch(.553 .195 38.402);--color-orange-800:oklch(.47 .157 37.304);--color-orange-900:oklch(.408 .123 38.172);--color-orange-950:oklch(.266 .079 36.259);--color-amber-50:oklch(.987 .022 95.277);--color-amber-100:oklch(.962 .059 95.617);--color-amber-200:oklch(.924 .12 95.746);--color-amber-300:oklch(.879 .169 91.605);--color-amber-400:oklch(.828 .189 84.429);--color-amber-500:oklch(.769 .188 70.08);--color-amber-600:oklch(.666 .179 58.318);--color-amber-700:oklch(.555 .163 48.998);--color-amber-800:oklch(.473 .137 46.201);--color-amber-900:oklch(.414 .112 45.904);--color-amber-950:oklch(.279 .077 45.635);--color-yellow-50:oklch(.987 .026 102.212);--color-yellow-100:oklch(.973 .071 103.193);--color-yellow-200:oklch(.945 .129 101.54);--color-yellow-300:oklch(.905 .182 98.111);--color-yellow-400:oklch(.852 .199 91.936);--color-yellow-500:oklch(.795 .184 86.047);--color-yellow-600:oklch(.681 .162 75.834);--color-yellow-700:oklch(.554 .135 66.442);--color-yellow-800:oklch(.476 .114 61.907);--color-yellow-900:oklch(.421 .095 57.708);--color-yellow-950:oklch(.286 .066 53.813);--color-lime-50:oklch(.986 .031 120.757);--color-lime-100:oklch(.967 .067 122.328);--color-lime-200:oklch(.938 .127 124.321);--color-lime-300:oklch(.897 .196 126.665);--color-lime-400:oklch(.841 .238 128.85);--color-lime-500:oklch(.768 .233 130.85);--color-lime-600:oklch(.648 .2 131.684);--color-lime-700:oklch(.532 .157 131.589);--color-lime-800:oklch(.453 .124 130.933);--color-lime-900:oklch(.405 .101 131.063);--color-lime-950:oklch(.274 .072 132.109);--color-green-50:oklch(.982 .018 155.826);--color-green-100:oklch(.962 .044 156.743);--color-green-200:oklch(.925 .084 155.995);--color-green-300:oklch(.871 .15 154.449);--color-green-400:oklch(.792 .209 151.711);--color-green-500:oklch(.723 .219 149.579);--color-green-600:oklch(.627 .194 149.214);--color-green-700:oklch(.527 .154 150.069);--color-green-800:oklch(.448 .119 151.328);--color-green-900:oklch(.393 .095 152.535);--color-green-950:oklch(.266 .065 152.934);--color-emerald-50:oklch(.979 .021 166.113);--color-emerald-100:oklch(.95 .052 163.051);--color-emerald-200:oklch(.905 .093 164.15);--color-emerald-300:oklch(.845 .143 164.978);--color-emerald-400:oklch(.765 .177 163.223);--color-emerald-500:oklch(.696 .17 162.48);--color-emerald-600:oklch(.596 .145 163.225);--color-emerald-700:oklch(.508 .118 165.612);--color-emerald-800:oklch(.432 .095 166.913);--color-emerald-900:oklch(.378 .077 168.94);--color-emerald-950:oklch(.262 .051 172.552);--color-teal-50:oklch(.984 .014 180.72);--color-teal-100:oklch(.953 .051 180.801);--color-teal-200:oklch(.91 .096 180.426);--color-teal-300:oklch(.855 .138 181.071);--color-teal-400:oklch(.777 .152 181.912);--color-teal-500:oklch(.704 .14 182.503);--color-teal-600:oklch(.6 .118 184.704);--color-teal-700:oklch(.511 .096 186.391);--color-teal-800:oklch(.437 .078 188.216);--color-teal-900:oklch(.386 .063 188.416);--color-teal-950:oklch(.277 .046 192.524);--color-cyan-50:oklch(.984 .019 200.873);--color-cyan-100:oklch(.956 .045 203.388);--color-cyan-200:oklch(.917 .08 205.041);--color-cyan-300:oklch(.865 .127 207.078);--color-cyan-400:oklch(.789 .154 211.53);--color-cyan-500:oklch(.715 .143 215.221);--color-cyan-600:oklch(.609 .126 221.723);--color-cyan-700:oklch(.52 .105 223.128);--color-cyan-800:oklch(.45 .085 224.283);--color-cyan-900:oklch(.398 .07 227.392);--color-cyan-950:oklch(.302 .056 229.695);--color-sky-50:oklch(.977 .013 236.62);--color-sky-100:oklch(.951 .026 236.824);--color-sky-200:oklch(.901 .058 230.902);--color-sky-300:oklch(.828 .111 230.318);--color-sky-400:oklch(.746 .16 232.661);--color-sky-500:oklch(.685 .169 237.323);--color-sky-600:oklch(.588 .158 241.966);--color-sky-700:oklch(.5 .134 242.749);--color-sky-800:oklch(.443 .11 240.79);--color-sky-900:oklch(.391 .09 240.876);--color-sky-950:oklch(.293 .066 243.157);--color-blue-50:oklch(.97 .014 254.604);--color-blue-100:oklch(.932 .032 255Line truncated
|
@layer theme{:root{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-serif:ui-serif,Georgia,Cambria,"Times New Roman",Times,serif;--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-50:oklch(.971 .013 17.38);--color-red-100:oklch(.936 .032 17.717);--color-red-200:oklch(.885 .062 18.334);--color-red-300:oklch(.808 .114 19.571);--color-red-400:oklch(.704 .191 22.216);--color-red-500:oklch(.637 .237 25.331);--color-red-600:oklch(.577 .245 27.325);--color-red-700:oklch(.505 .213 27.518);--color-red-800:oklch(.444 .177 26.899);--color-red-900:oklch(.396 .141 25.723);--color-red-950:oklch(.258 .092 26.042);--color-orange-50:oklch(.98 .016 73.684);--color-orange-100:oklch(.954 .038 75.164);--color-orange-200:oklch(.901 .076 70.697);--color-orange-300:oklch(.837 .128 66.29);--color-orange-400:oklch(.75 .183 55.934);--color-orange-500:oklch(.705 .213 47.604);--color-orange-600:oklch(.646 .222 41.116);--color-orange-700:oklch(.553 .195 38.402);--color-orange-800:oklch(.47 .157 37.304);--color-orange-900:oklch(.408 .123 38.172);--color-orange-950:oklch(.266 .079 36.259);--color-amber-50:oklch(.987 .022 95.277);--color-amber-100:oklch(.962 .059 95.617);--color-amber-200:oklch(.924 .12 95.746);--color-amber-300:oklch(.879 .169 91.605);--color-amber-400:oklch(.828 .189 84.429);--color-amber-500:oklch(.769 .188 70.08);--color-amber-600:oklch(.666 .179 58.318);--color-amber-700:oklch(.555 .163 48.998);--color-amber-800:oklch(.473 .137 46.201);--color-amber-900:oklch(.414 .112 45.904);--color-amber-950:oklch(.279 .077 45.635);--color-yellow-50:oklch(.987 .026 102.212);--color-yellow-100:oklch(.973 .071 103.193);--color-yellow-200:oklch(.945 .129 101.54);--color-yellow-300:oklch(.905 .182 98.111);--color-yellow-400:oklch(.852 .199 91.936);--color-yellow-500:oklch(.795 .184 86.047);--color-yellow-600:oklch(.681 .162 75.834);--color-yellow-700:oklch(.554 .135 66.442);--color-yellow-800:oklch(.476 .114 61.907);--color-yellow-900:oklch(.421 .095 57.708);--color-yellow-950:oklch(.286 .066 53.813);--color-lime-50:oklch(.986 .031 120.757);--color-lime-100:oklch(.967 .067 122.328);--color-lime-200:oklch(.938 .127 124.321);--color-lime-300:oklch(.897 .196 126.665);--color-lime-400:oklch(.841 .238 128.85);--color-lime-500:oklch(.768 .233 130.85);--color-lime-600:oklch(.648 .2 131.684);--color-lime-700:oklch(.532 .157 131.589);--color-lime-800:oklch(.453 .124 130.933);--color-lime-900:oklch(.405 .101 131.063);--color-lime-950:oklch(.274 .072 132.109);--color-green-50:oklch(.982 .018 155.826);--color-green-100:oklch(.962 .044 156.743);--color-green-200:oklch(.925 .084 155.995);--color-green-300:oklch(.871 .15 154.449);--color-green-400:oklch(.792 .209 151.711);--color-green-500:oklch(.723 .219 149.579);--color-green-600:oklch(.627 .194 149.214);--color-green-700:oklch(.527 .154 150.069);--color-green-800:oklch(.448 .119 151.328);--color-green-900:oklch(.393 .095 152.535);--color-green-950:oklch(.266 .065 152.934);--color-emerald-50:oklch(.979 .021 166.113);--color-emerald-100:oklch(.95 .052 163.051);--color-emerald-200:oklch(.905 .093 164.15);--color-emerald-300:oklch(.845 .143 164.978);--color-emerald-400:oklch(.765 .177 163.223);--color-emerald-500:oklch(.696 .17 162.48);--color-emerald-600:oklch(.596 .145 163.225);--color-emerald-700:oklch(.508 .118 165.612);--color-emerald-800:oklch(.432 .095 166.913);--color-emerald-900:oklch(.378 .077 168.94);--color-emerald-950:oklch(.262 .051 172.552);--color-teal-50:oklch(.984 .014 180.72);--color-teal-100:oklch(.953 .051 180.801);--color-teal-200:oklch(.91 .096 180.426);--color-teal-300:oklch(.855 .138 181.071);--color-teal-400:oklch(.777 .152 181.912);--color-teal-500:oklch(.704 .14 182.503);--color-teal-600:oklch(.6 .118 184.704);--color-teal-700:oklch(.511 .096 186.391);--color-teal-800:oklch(.437 .078 188.216);--color-teal-900:oklch(.386 .063 188.416);--color-teal-950:oklch(.277 .046 192.524);--color-cyan-50:oklch(.984 .019 200.873);--color-cyan-100:oklch(.956 .045 203.388);--color-cyan-200:oklch(.917 .08 205.041);--color-cyan-300:oklch(.865 .127 207.078);--color-cyan-400:oklch(.789 .154 211.53);--color-cyan-500:oklch(.715 .143 215.221);--color-cyan-600:oklch(.609 .126 221.723);--color-cyan-700:oklch(.52 .105 223.128);--color-cyan-800:oklch(.45 .085 224.283);--color-cyan-900:oklch(.398 .07 227.392);--color-cyan-950:oklch(.302 .056 229.695);--color-sky-50:oklch(.977 .013 236.62);--color-sky-100:oklch(.951 .026 236.824);--color-sky-200:oklch(.901 .058 230.902);--color-sky-300:oklch(.828 .111 230.318);--color-sky-400:oklch(.746 .16 232.661);--color-sky-500:oklch(.685 .169 237.323);--color-sky-600:oklch(.588 .158 241.966);--color-sky-700:oklch(.5 .134 242.749);--color-sky-800:oklch(.443 .11 240.79);--color-sky-900:oklch(.391 .09 240.876);--color-sky-950:oklch(.293 .066 243.157);--color-blue-50:oklch(.97 .014 254.604);--color-blue-100:oklch(.932 .032 255Line truncated
|
||||||
@@ -20,7 +20,8 @@ use crate::{
|
|||||||
storage::{
|
storage::{
|
||||||
db::delete_item,
|
db::delete_item,
|
||||||
types::{
|
types::{
|
||||||
knowledge_entity::KnowledgeEntity, knowledge_relationship::KnowledgeRelationship,
|
knowledge_entity::{KnowledgeEntity, KnowledgeEntityType},
|
||||||
|
knowledge_relationship::KnowledgeRelationship,
|
||||||
user::User,
|
user::User,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -146,6 +147,7 @@ pub async fn show_knowledge_page(
|
|||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub struct EntityData {
|
pub struct EntityData {
|
||||||
entity: KnowledgeEntity,
|
entity: KnowledgeEntity,
|
||||||
|
entity_types: Vec<String>,
|
||||||
user: User,
|
user: User,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +162,12 @@ pub async fn show_edit_knowledge_entity_form(
|
|||||||
None => return Ok(Redirect::to("/signin").into_response()),
|
None => return Ok(Redirect::to("/signin").into_response()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get entity types
|
||||||
|
let entity_types: Vec<String> = KnowledgeEntityType::variants()
|
||||||
|
.iter()
|
||||||
|
.map(|s| s.to_string())
|
||||||
|
.collect();
|
||||||
|
|
||||||
// Get the entity and validate ownership
|
// Get the entity and validate ownership
|
||||||
let entity = User::get_and_validate_knowledge_entity(&id, &user.id, &state.surreal_db_client)
|
let entity = User::get_and_validate_knowledge_entity(&id, &user.id, &state.surreal_db_client)
|
||||||
.await
|
.await
|
||||||
@@ -167,7 +175,11 @@ pub async fn show_edit_knowledge_entity_form(
|
|||||||
|
|
||||||
let output = render_template(
|
let output = render_template(
|
||||||
"knowledge/edit_knowledge_entity_modal.html",
|
"knowledge/edit_knowledge_entity_modal.html",
|
||||||
EntityData { entity, user },
|
EntityData {
|
||||||
|
entity,
|
||||||
|
user,
|
||||||
|
entity_types,
|
||||||
|
},
|
||||||
state.templates,
|
state.templates,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
@@ -184,6 +196,7 @@ pub struct EntityListData {
|
|||||||
pub struct PatchKnowledgeEntityParams {
|
pub struct PatchKnowledgeEntityParams {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
pub entity_type: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,17 +212,18 @@ pub async fn patch_knowledge_entity(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Get the existing entity and validate that the user is allowed
|
// Get the existing entity and validate that the user is allowed
|
||||||
let existing_entity =
|
User::get_and_validate_knowledge_entity(&form.id, &user.id, &state.surreal_db_client)
|
||||||
User::get_and_validate_knowledge_entity(&form.id, &user.id, &state.surreal_db_client)
|
.await
|
||||||
.await
|
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;
|
||||||
.map_err(|e| HtmlError::new(e, state.templates.clone()))?;
|
|
||||||
|
let entity_type: KnowledgeEntityType = KnowledgeEntityType::from(form.entity_type);
|
||||||
|
|
||||||
// Update the entity
|
// Update the entity
|
||||||
KnowledgeEntity::patch(
|
KnowledgeEntity::patch(
|
||||||
&form.id,
|
&form.id,
|
||||||
&form.name,
|
&form.name,
|
||||||
&form.description,
|
&form.description,
|
||||||
&existing_entity.entity_type,
|
&entity_type,
|
||||||
&state.surreal_db_client,
|
&state.surreal_db_client,
|
||||||
&state.openai_client,
|
&state.openai_client,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,10 +2,7 @@ use crate::{
|
|||||||
error::AppError, storage::db::SurrealDbClient, stored_object,
|
error::AppError, storage::db::SurrealDbClient, stored_object,
|
||||||
utils::embedding::generate_embedding,
|
utils::embedding::generate_embedding,
|
||||||
};
|
};
|
||||||
use async_openai::{
|
use async_openai::{config::OpenAIConfig, Client};
|
||||||
config::{Config, OpenAIConfig},
|
|
||||||
Client,
|
|
||||||
};
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
@@ -17,6 +14,11 @@ pub enum KnowledgeEntityType {
|
|||||||
TextSnippet,
|
TextSnippet,
|
||||||
// Add more types as needed
|
// Add more types as needed
|
||||||
}
|
}
|
||||||
|
impl KnowledgeEntityType {
|
||||||
|
pub fn variants() -> &'static [&'static str] {
|
||||||
|
&["Idea", "Project", "Document", "Page", "TextSnippet"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<String> for KnowledgeEntityType {
|
impl From<String> for KnowledgeEntityType {
|
||||||
fn from(s: String) -> Self {
|
fn from(s: String) -> Self {
|
||||||
@@ -101,6 +103,7 @@ impl KnowledgeEntity {
|
|||||||
SET name = $name,
|
SET name = $name,
|
||||||
description = $description,
|
description = $description,
|
||||||
updated_at = $updated_at,
|
updated_at = $updated_at,
|
||||||
|
entity_type = $entity_type,
|
||||||
embedding = $embedding
|
embedding = $embedding
|
||||||
RETURN AFTER",
|
RETURN AFTER",
|
||||||
)
|
)
|
||||||
@@ -108,6 +111,7 @@ impl KnowledgeEntity {
|
|||||||
.bind(("id", id.to_string()))
|
.bind(("id", id.to_string()))
|
||||||
.bind(("name", name.to_string()))
|
.bind(("name", name.to_string()))
|
||||||
.bind(("updated_at", Utc::now()))
|
.bind(("updated_at", Utc::now()))
|
||||||
|
.bind(("entity_type", entity_type.to_owned()))
|
||||||
.bind(("embedding", embedding))
|
.bind(("embedding", embedding))
|
||||||
.bind(("description", description.to_string()))
|
.bind(("description", description.to_string()))
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ hx-swap="outerHTML"
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-control">
|
<div class="form-control relative" style="margin-top: -1.5rem;">
|
||||||
<label class="floating-label">
|
<span class="absolute left-2.5 top-2.5 z-[100] p-0.5 bg-white text-xs text-light">Type</span>
|
||||||
<span class="label-text">Type</span>
|
<select name="entity_type" class="select select-bordered w-full">
|
||||||
<input type="text" name="name" value="{{ entity.entity_type}}" class="input input-bordered w-full">
|
{% for et in entity_types %}
|
||||||
</label>
|
<option value="{{ et }}" {% if entity.entity_type==et %}selected{% endif %}>{{ et }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="text" name="id" value="{{ entity.id }}" class="hidden">
|
<input type="text" name="id" value="{{ entity.id }}" class="hidden">
|
||||||
|
|||||||
Reference in new issue
Block a user