Skip to content

web search done right

remove alice improvements

Mikkel Denkerd2719b333e2e
diff --git a/README.md b/README.md
index 5c05540a..3bd76d2f 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,6 @@
</p>
<br />
-
Stract is an open source web search engine hosted at [trystract.com](https://trystract.com/) targeted towards tinkerers and developers.
<br />
diff --git a/core/src/api/improvement.rs b/core/src/api/improvement.rs
index 6a831c91..b861d410 100644
--- a/core/src/api/improvement.rs
+++ b/core/src/api/improvement.rs
@@ -22,7 +22,7 @@ use serde::Deserialize;
use url::Url;
use uuid::Uuid;
-use crate::improvement::{AliceMessage, ImprovementEvent, StoredQuery};
+use crate::improvement::{ImprovementEvent, StoredQuery};
use super::{HtmlTemplate, State};
@@ -82,29 +82,6 @@ pub async fn store(
}
}
-#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
-pub struct AliceConversation {
- pub id: Uuid,
- pub messages: Vec<AliceMessage>,
-}
-
-#[allow(clippy::unused_async)]
-pub async fn new_chat_id() -> impl IntoResponse {
- Uuid::new_v4().to_string()
-}
-
-#[allow(clippy::unused_async)]
-pub async fn store_chat(
- extract::State(state): extract::State<Arc<State>>,
- extract::Json(params): extract::Json<AliceConversation>,
-) {
- if let Some(q) = state.improvement_queue.as_ref() {
- q.lock().await.push(ImprovementEvent::Chat {
- chat: params.into(),
- })
- }
-}
-
#[allow(clippy::unused_async)]
pub async fn settings(extract::State(state): extract::State<Arc<State>>) -> impl IntoResponse {
let template = SettingsTemplate {
diff --git a/core/src/api/mod.rs b/core/src/api/mod.rs
index 58494798..c3786182 100644
--- a/core/src/api/mod.rs
+++ b/core/src/api/mod.rs
@@ -197,14 +197,6 @@ pub async fn router(config: &FrontendConfig, counters: Counters) -> Result<Route
.route("/opensearch.xml", get(opensearch::route))
.route("/improvement/click", post(improvement::click))
.route("/improvement/store", post(improvement::store))
- .route(
- "/improvement/alice/new_chat_id",
- post(improvement::new_chat_id),
- )
- .route(
- "/improvement/alice/store_chat",
- post(improvement::store_chat),
- )
.fallback(get_service(ServeDir::new("frontend/dist/")))
.layer(CompressionLayer::new())
.merge(docs::router())
diff --git a/core/src/improvement.rs b/core/src/improvement.rs
index 2b8ef358..439299a7 100644
--- a/core/src/improvement.rs
+++ b/core/src/improvement.rs
@@ -16,14 +16,14 @@
use std::{sync::Arc, time::Duration};
-use chrono::{DateTime, NaiveDate, Timelike, Utc};
+use chrono::{DateTime, Timelike, Utc};
use scylla::{prepared_statement::PreparedStatement, SessionBuilder};
use thiserror::Error;
use tokio::{sync::Mutex, time};
use url::Url;
use uuid::Uuid;
-use crate::{api::improvement::AliceConversation, leaky_queue::LeakyQueue};
+use crate::leaky_queue::LeakyQueue;
#[derive(Debug, Error)]
enum Error {
@@ -44,43 +44,10 @@ pub struct StoredQuery {
timestamp: Option<DateTime<Utc>>, // it is extremely important that we strip minutes, seconds and nanoseconds here for privacy
}
-#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
-pub struct StoredAliceConversation {
- pub id: Uuid,
- messages: Vec<AliceMessage>,
- date: NaiveDate,
-}
-
-#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
-pub struct AliceMessage {
- from: String,
- message: String,
- queries: Vec<AliceQuery>,
-}
-
-#[derive(serde::Serialize, serde::Deserialize, Clone, Debug)]
-pub struct AliceQuery {
- query: String,
- results: Vec<crate::alice::SimplifiedWebsite>,
-}
-
-impl From<AliceConversation> for StoredAliceConversation {
- fn from(value: AliceConversation) -> Self {
- let date = chrono::Utc::now().date_naive();
-
- Self {
- id: value.id,
- messages: value.messages,
- date,
- }
- }
-}
-
#[derive(Clone)]
pub enum ImprovementEvent {
StoreQuery(StoredQuery),
Click { qid: Uuid, idx: usize },
- Chat { chat: StoredAliceConversation },
}
impl StoredQuery {
@@ -135,7 +102,6 @@ pub async fn store_improvements_loop(
scylla.store_click(qid, idx).await
}
}
- ImprovementEvent::Chat { chat } => scylla.store_chat(chat).await,
}
}
}
@@ -145,7 +111,6 @@ struct ScyllaConn {
session: scylla::Session,
prepared_insert: PreparedStatement,
prepared_click: PreparedStatement,
- prepared_chat: PreparedStatement,
}
impl ScyllaConn {
@@ -167,13 +132,6 @@ impl ScyllaConn {
)
.await?;
- session
- .query(
- "CREATE TABLE IF NOT EXISTS ks.chats (id uuid, json_encoded text, date date, primary key (id))",
- &[],
- )
- .await?;
-
let prepared_insert: PreparedStatement = session
.prepare("INSERT INTO ks.queries (qid, query, urls, timestamp) VALUES(?, ?, ?, ?)")
.await?;
@@ -182,15 +140,10 @@ impl ScyllaConn {
.prepare("INSERT INTO ks.clicks (qid, click) VALUES(?, ?)")
.await?;
- let prepared_chat: PreparedStatement = session
- .prepare("INSERT INTO ks.chats (id, json_encoded, date) VALUES(?, ?, ?)")
- .await?;
-
Ok(Self {
session,
prepared_insert,
prepared_click,
- prepared_chat,
})
}
@@ -227,17 +180,4 @@ impl ScyllaConn {
tracing::error!("scylla store_click error: {err}");
}
}
-
- async fn store_chat(&self, chat: StoredAliceConversation) {
- if let Ok(json_encoded) = serde_json::to_string(&chat) {
- let res = self
- .session
- .execute(&self.prepared_chat, (chat.id, json_encoded, chat.date))
- .await;
-
- if let Err(err) = res {
- tracing::error!("scylla store_chat error: {err}");
- }
- }
- }
}
diff --git a/frontend/src/pages/chat.astro b/frontend/src/pages/chat.astro
index f3425ec2..aa76f352 100644
--- a/frontend/src/pages/chat.astro
+++ b/frontend/src/pages/chat.astro
@@ -133,8 +133,6 @@ import OpticSelector from "../components/OpticSelector.astro";
const statusTemplate: HTMLDivElement = document.querySelector(".status-template")!;
const opticSelector: HTMLSelectElement = document.querySelector("#optics-selector")!;
- const allowStats = window.localStorage.getItem("allowAliceImprovements") === "true";
-
let prevState: any | null = null;
let chatId: string | null = null;
@@ -369,8 +367,6 @@ import OpticSelector from "../components/OpticSelector.astro";
messageInput.disabled = false;
sendButton.style.color = originalSendButtonColor;
messageInput.focus();
-
- improvements();
}
async function sendMessageToAlice(message: string) {
@@ -653,46 +649,4 @@ import OpticSelector from "../components/OpticSelector.astro";
codeBlock.style.background = "none";
}
}
-
- // improvements
- async function newChatId(): Promise<string> {
- let url = "/improvement/alice/new_chat_id";
-
- // post request using fetch api
- let response = await fetch(url, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json'
- }
- });
-
- return await response.text();
- }
-
- async function storeChat() {
- if (chatId == null) {
- chatId = await newChatId();
- }
-
- let chat = {
- messages: messages,
- id: chatId
- };
-
- let url = "/improvement/alice/store_chat";
-
- await fetch(url, {
- method: 'POST',
- body: JSON.stringify(chat),
- headers: {
- 'Content-Type': 'application/json'
- }
- });
- }
-
- function improvements() {
- if (allowStats) {
- storeChat();
- }
- }
</script>
\ No newline at end of file
diff --git a/frontend/src/pages/settings/privacy.astro b/frontend/src/pages/settings/privacy.astro
index 6c0ebe17..79061aa5 100644
--- a/frontend/src/pages/settings/privacy.astro
+++ b/frontend/src/pages/settings/privacy.astro
@@ -12,7 +12,7 @@ import SettingsLayout from "../../layouts/Settings.astro";
<div class="text-sm">
It is important to note, that <b class="font-extrabold">no</b> personal information is stored about your search. We don't store your IP, browser fingerprint or even a precise timestamp.
- In fact, you can see exactly what gets stored <a href="https://github.com/StractOrg/Stract/blob/main/core/src/improvement.rs#L36-#L64">here</a>.
+ In fact, you can see exactly what gets stored <a href="https://github.com/StractOrg/Stract/blob/main/core/src/improvement.rs#L37-#L51">here</a>.
</div>
<div class="text-sm">
@@ -24,15 +24,6 @@ import SettingsLayout from "../../layouts/Settings.astro";
<input type="checkbox" id="allowStats" x-model="allowStats">
<label for="allowStats">Allow usage statistics</label>
</div>
-
- {
- askama.if_("with_alice.unwrap_or(true)", () => (
- <div class="flex space-x-1 pl-1 text-sm" x-data="{ allowAliceImprovements: $persist(true).as('allowAliceImprovements') }">
- <input type="checkbox" id="allowAliceImprovements" x-model="allowAliceImprovements">
- <label for="allowAliceImprovements">Allow Alice conversations to be stored and used for training</label>
- </div>
- ))
- }
</div>
</SettingsLayout>