mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-24 17:58:31 +02:00
fix: vector search formatting, surrealdb bug
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
{"schemas":"--- original\n+++ modified\n@@ -147,6 +147,7 @@\n\n DEFINE FIELD OVERWRITE script_name ON script_migration TYPE string;\n DEFINE FIELD OVERWRITE executed_at ON script_migration TYPE datetime VALUE time::now() READONLY;\n+\n # Defines the schema for the 'system_settings' table.\n\n DEFINE TABLE IF NOT EXISTS system_settings SCHEMALESS;\n","events":null}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"schemas":"--- original\n+++ modified\n@@ -198,11 +198,11 @@\n DEFINE FIELD IF NOT EXISTS file_info ON text_content TYPE option<object>;\n # UrlInfo is a struct, store as object\n DEFINE FIELD IF NOT EXISTS url_info ON text_content TYPE option<object>;\n-DEFINE FIELD IF NOT EXISTS instructions ON text_content TYPE string;\n+DEFINE FIELD IF NOT EXISTS context ON text_content TYPE option<string>;\n DEFINE FIELD IF NOT EXISTS category ON text_content TYPE string;\n DEFINE FIELD IF NOT EXISTS user_id ON text_content TYPE string;\n\n-# Indexes based on query patterns (get_latest_text_contents, get_text_contents_by_category)\n+# Indexes based on query patterns\n DEFINE INDEX IF NOT EXISTS text_content_user_id_idx ON text_content FIELDS user_id;\n DEFINE INDEX IF NOT EXISTS text_content_created_at_idx ON text_content FIELDS created_at;\n DEFINE INDEX IF NOT EXISTS text_content_category_idx ON text_content FIELDS category;\n","events":null}
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -78,7 +78,11 @@ impl SurrealDbClient {
|
|||||||
pub async fn rebuild_indexes(&self) -> Result<(), Error> {
|
pub async fn rebuild_indexes(&self) -> Result<(), Error> {
|
||||||
self.client
|
self.client
|
||||||
.query("REBUILD INDEX IF EXISTS idx_embedding_chunks ON text_chunk")
|
.query("REBUILD INDEX IF EXISTS idx_embedding_chunks ON text_chunk")
|
||||||
.query("REBUILD INDEX IF EXISTS idx_embeddings_entities ON knowledge_entity")
|
.await?;
|
||||||
|
self.client
|
||||||
|
.query("REBUILD INDEX IF EXISTS idx_embedding_entities ON knowledge_entity")
|
||||||
|
.await?;
|
||||||
|
self.client
|
||||||
.query("REBUILD INDEX IF EXISTS text_content_fts_idx ON text_content")
|
.query("REBUILD INDEX IF EXISTS text_content_fts_idx ON text_content")
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ where
|
|||||||
let input_embedding = generate_embedding(openai_client, input_text).await?;
|
let input_embedding = generate_embedding(openai_client, input_text).await?;
|
||||||
|
|
||||||
// Construct the query
|
// Construct the query
|
||||||
let closest_query = format!("SELECT *, vector::distance::knn() AS distance FROM {} WHERE embedding <|{},40|> {:?} AND user_id = '{}' ORDER BY distance", table, take, input_embedding, user_id);
|
let closest_query = format!("SELECT *, vector::distance::knn() AS distance FROM {} WHERE user_id = '{}' AND embedding <|{},40|> {:?} ORDER BY distance", table, user_id, take, input_embedding);
|
||||||
|
|
||||||
// Perform query and deserialize to struct
|
// Perform query and deserialize to struct
|
||||||
let closest_entities: Vec<T> = db_client.query(closest_query).await?.take(0)?;
|
let closest_entities: Vec<T> = db_client.query(closest_query).await?.take(0)?;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ pub async fn show_active_jobs(
|
|||||||
let active_jobs = User::get_unfinished_ingestion_tasks(&user.id, &state.db).await?;
|
let active_jobs = User::get_unfinished_ingestion_tasks(&user.id, &state.db).await?;
|
||||||
|
|
||||||
Ok(TemplateResponse::new_partial(
|
Ok(TemplateResponse::new_partial(
|
||||||
"index/signed_in/active_jobs.html",
|
"dashboard/active_jobs.html",
|
||||||
"active_jobs_section",
|
"active_jobs_section",
|
||||||
ActiveJobsData {
|
ActiveJobsData {
|
||||||
user: user.clone(),
|
user: user.clone(),
|
||||||
|
|||||||
@@ -63,7 +63,7 @@
|
|||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<!-- View mode -->
|
<!-- View mode -->
|
||||||
<div class="flex w-full px-2 py-2">
|
<div class="flex w-full pl-4 pr-2 py-2">
|
||||||
<a hx-boost="true" href="/chat/{{ conversation.id }}" class="flex-grow text-sm truncate">
|
<a hx-boost="true" href="/chat/{{ conversation.id }}" class="flex-grow text-sm truncate">
|
||||||
<span>{{ conversation.title }}</span>
|
<span>{{ conversation.title }}</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -94,9 +94,17 @@
|
|||||||
<span>Account</span>
|
<span>Account</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% if user.admin %}
|
||||||
|
<li>
|
||||||
|
<a hx-boost="true" href="/admin" class="flex btn btn-ghost justify-start items-center gap-3">
|
||||||
|
{% include "icons/wrench_screwdriver_icon.html" %}
|
||||||
|
<span>Admin</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
<li>
|
<li>
|
||||||
<a hx-boost="true" href="/signout"
|
<a hx-boost="true" href="/signout"
|
||||||
class="btn btn-error btn-outline w-full flex items-center gap-3 justify-start !mt-1">
|
class="btn btn-error btn-outline w-full flex items-center gap-3 justify-start !mt-2">
|
||||||
{% include "icons/logout_icon.html" %}
|
{% include "icons/logout_icon.html" %}
|
||||||
<span>Logout</span>
|
<span>Logout</span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user