web search done right
remove summarizer
Mikkel Denkere39987a2f775
diff --git a/crates/core/examples/search_preindexed.rs b/crates/core/examples/search_preindexed.rsindex b8c0b38a..07e80b43 100644--- a/crates/core/examples/search_preindexed.rs+++ b/crates/core/examples/search_preindexed.rs@@ -3,8 +3,8 @@ use rand::seq::SliceRandom;use stract::{bangs::Bangs,config::{- defaults, ApiConfig, ApiThresholds, CollectorConfig, CorrectionConfig, LLMConfig,- SnippetConfig, WidgetsConfig,+ defaults, ApiConfig, ApiThresholds, CollectorConfig, CorrectionConfig, SnippetConfig,+ WidgetsConfig,},index::Index,searcher::{@@ -29,7 +29,6 @@ pub async fn main() {lambda_model_path: None,dual_encoder_model_path: None,bangs_path: "data/bangs.json".to_string(),- summarizer_path: "data/summarizer".to_string(),query_store_db_host: None,cluster_id: "api".to_string(),gossip_seed_nodes: None,@@ -44,11 +43,6 @@ pub async fn main() {path: "data/web_spell".to_string(),correction_config: CorrectionConfig::default(),}),- llm: LLMConfig {- api_base: "http://localhost:4000/v1".to_string(),- model: "data/mistral-7b-instruct-v0.2.Q4_K_M.gguf".to_string(),- api_key: None,- },max_concurrent_searches: defaults::Api::max_concurrent_searches(),max_similar_hosts: defaults::Api::max_similar_hosts(),};diff --git a/crates/core/src/api/docs.rs b/crates/core/src/api/docs.rsindex 959e74a9..cffb5767 100644--- a/crates/core/src/api/docs.rs+++ b/crates/core/src/api/docs.rs@@ -14,7 +14,7 @@// You should have received a copy of the GNU Affero General Public License// along with this program. If not, see <https://www.gnu.org/licenses/>.-use super::{autosuggest, explore, hosts, search, summarize, webgraph};+use super::{autosuggest, explore, hosts, search, webgraph};use axum::Router;use utoipa::{Modify, OpenApi};use utoipa_swagger_ui::SwaggerUi;@@ -33,7 +33,6 @@ use utoipa_swagger_ui::SwaggerUi;webgraph::page::ingoing_pages,webgraph::page::outgoing_pages,autosuggest::route,- summarize::summarize_route,hosts::hosts_export_optic,explore::explore_export_optic,),diff --git a/crates/core/src/api/mod.rs b/crates/core/src/api/mod.rsindex ece870a5..64f7c8a6 100644--- a/crates/core/src/api/mod.rs+++ b/crates/core/src/api/mod.rs@@ -39,7 +39,7 @@ use crate::{webgraph::remote::RemoteWebgraph,};-use crate::{ranking::models::cross_encoder::CrossEncoderModel, summarizer::Summarizer};+use crate::ranking::models::cross_encoder::CrossEncoderModel;use anyhow::Result;use std::{@@ -61,7 +61,6 @@ mod hosts;pub mod improvement;mod metrics;pub mod search;-mod summarize;pub mod user_count;mod webgraph;@@ -79,7 +78,6 @@ pub struct State {pub host_webgraph: Arc<RemoteWebgraph>,pub autosuggest: Autosuggest,pub counters: Counters,- pub summarizer: Arc<Summarizer>,pub improvement_queue: Option<Arc<Mutex<LeakyQueue<ImprovementEvent>>>>,pub _cluster: Arc<Cluster>,pub similar_hosts: SimilarHostsFinder,@@ -123,7 +121,6 @@ fn build_router(state: Arc<State>) -> Router {.route("/api/search/spellcheck", post(search::spellcheck)).route("/api/autosuggest", post(autosuggest::route)).route("/api/autosuggest/browser", get(autosuggest::browser))- .route("/api/summarize", get(summarize::summarize_route)).route("/api/webgraph/host/similar", post(webgraph::host::similar)).route("/api/webgraph/host/knows", post(webgraph::host::knows)).route(@@ -226,12 +223,6 @@ pub async fn router(config: &ApiConfig, counters: Counters) -> Result<Router> {counters,host_webgraph,page_webgraph,- summarizer: Arc::new(Summarizer::new(- &config.summarizer_path,- config.llm.api_base.clone(),- config.llm.model.clone(),- config.llm.api_key.clone(),- )?),improvement_queue: query_store_queue,_cluster: cluster,similar_hosts,diff --git a/crates/core/src/api/summarize.rs b/crates/core/src/api/summarize.rsdeleted file mode 100644index 99dbf94e..00000000--- a/crates/core/src/api/summarize.rs+++ /dev/null@@ -1,82 +0,0 @@-// Stract is an open source web search engine.-// Copyright (C) 2023 Stract ApS-//-// This program is free software: you can redistribute it and/or modify-// it under the terms of the GNU Affero General Public License as-// published by the Free Software Foundation, either version 3 of the-// License, or (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU Affero General Public License for more details.-//-// You should have received a copy of the GNU Affero General Public License-// along with this program. If not, see <https://www.gnu.org/licenses/>.--use std::convert::Infallible;-use std::sync::Arc;--use axum::extract;-use axum::response::sse::KeepAlive;-use axum::response::{sse::Event, Sse};-use futures::stream::Stream;-use http::StatusCode;-use serde::Deserialize;-use tokio_stream::StreamExt as _;-use utoipa::IntoParams;--use super::State;-use crate::Result;--#[derive(Deserialize, Debug, IntoParams)]-pub struct SummarizeParams {- pub url: String,- pub query: String,-}--async fn summarize(- params: SummarizeParams,- state: Arc<State>,-) -> Result<Sse<impl Stream<Item = std::result::Result<Event, Infallible>>>> {- let webpage = state- .searcher- .get_webpage(¶ms.url)- .await?- .ok_or_else(|| anyhow::anyhow!("Webpage not found: {}", params.url))?;-- if webpage.body.is_empty() {- return Err(anyhow::anyhow!("Webpage body is empty"));- }-- let stream = state- .summarizer- .summarize(¶ms.query, &webpage.body)- .await?;-- Ok(- Sse::new(stream.map(|term| Event::default().data(term)).map(Ok))- .keep_alive(KeepAlive::default()),- )-}--#[utoipa::path(- get,- path = "/beta/api/summarize",- params(SummarizeParams),- responses(- (status = 200, description = "Summarize a website", body = String, content_type = "text/event-stream"),- )-)]-pub async fn summarize_route(- extract::Query(params): extract::Query<SummarizeParams>,- extract::State(state): extract::State<Arc<State>>,-) -> std::result::Result<Sse<impl Stream<Item = std::result::Result<Event, Infallible>>>, StatusCode>-{- // err might actually happen if url contains more than 255 tokens- // as these might be dropped by tantivy.- match summarize(params, state).await {- Ok(stream) => Ok(stream),- Err(_) => Err(StatusCode::NO_CONTENT),- }-}diff --git a/crates/core/src/config/mod.rs b/crates/core/src/config/mod.rsindex 8c9925bd..72fb9a4e 100644--- a/crates/core/src/config/mod.rs+++ b/crates/core/src/config/mod.rs@@ -212,13 +212,6 @@ impl Default for ApiThresholds {}}-#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]-pub struct LLMConfig {- pub api_base: String,- pub model: String,- pub api_key: Option<String>,-}-#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]pub struct ApiSpellCheck {pub path: String,@@ -229,7 +222,6 @@ pub struct ApiSpellCheck {#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]pub struct ApiConfig {- pub summarizer_path: String,pub queries_csv_path: String,pub host: SocketAddr,pub prometheus_host: SocketAddr,@@ -247,8 +239,6 @@ pub struct ApiConfig {pub spell_check: Option<ApiSpellCheck>,- pub llm: LLMConfig,-#[serde(default)]pub thresholds: ApiThresholds,diff --git a/crates/core/src/entrypoint/configure.rs b/crates/core/src/entrypoint/configure.rsindex 9ff0f853..bcb7857b 100644--- a/crates/core/src/entrypoint/configure.rs+++ b/crates/core/src/entrypoint/configure.rs@@ -48,7 +48,6 @@ fn download_files() {"english-wordnet-2022-subset.ttl","lambdamart.txt","test.zim",- "mistral-7b-instruct-v0.2.Q4_K_M.gguf","internet_archive.warc.gz",] {let path = Path::new(DATA_PATH).join(name);diff --git a/crates/core/src/lib.rs b/crates/core/src/lib.rsindex 49b8a522..10e474a8 100644--- a/crates/core/src/lib.rs+++ b/crates/core/src/lib.rs@@ -66,7 +66,6 @@ mod intmap;mod kahan_sum;mod leaky_queue;mod live_index;-mod llm_utils;mod metrics;mod models;pub mod naive_bayes;diff --git a/crates/core/src/llm_utils.rs b/crates/core/src/llm_utils.rsdeleted file mode 100644index 4f4c65da..00000000--- a/crates/core/src/llm_utils.rs+++ /dev/null@@ -1,186 +0,0 @@-// Stract is an open source web search engine.-// Copyright (C) 2023 Stract ApS-//-// This program is free software: you can redistribute it and/or modify-// it under the terms of the GNU Affero General Public License as-// published by the Free Software Foundation, either version 3 of the-// License, or (at your option) any later version.-//-// This program is distributed in the hope that it will be useful,-// but WITHOUT ANY WARRANTY; without even the implied warranty of-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-// GNU Affero General Public License for more details.-//-// You should have received a copy of the GNU Affero General Public License-// along with this program. If not, see <https://www.gnu.org/licenses/>.--use crate::Result;-use anyhow::anyhow;-use eventsource_stream::Eventsource;-use futures::stream::Stream;-use tokio_stream::StreamExt;--pub struct OpenAiApi {- api: String,- key: Option<String>,- top_p: f64,- temp: f64,- model: String,- max_tokens: Option<u64>,- stop: Vec<String>,-}--impl OpenAiApi {- pub fn builder(api: String, model: String) -> OpenAiApiBuilder {- OpenAiApiBuilder::new(api, model)- }-- fn payload(&self, prompt: &str) -> Result<serde_json::Value> {- let mut payload = serde_json::json!({- "prompt": prompt,- "temperature": self.temp,- "top_p": self.top_p,- "stop": self.stop.clone(),- "model": self.model.clone(),- });-- if let Some(max_tokens) = self.max_tokens {- payload["max_tokens"] = serde_json::json!(max_tokens);- }-- Ok(payload)- }-- pub async fn generate(&self, prompt: &str) -> Result<String> {- let client = reqwest::Client::new();- let mut req = client.post(format!("{}/completions", &self.api));-- if let Some(key) = &self.key {- req = req.bearer_auth(key);- }-- let res = req- .json(&self.payload(prompt)?)- .send()- .await?- .text()- .await?;-- let res: serde_json::Value = serde_json::from_str(&res)?;-- let res = res- .get("choices")- .ok_or(anyhow!("unexepected response format"))?- .get(0)- .ok_or(anyhow!("unexpected response format"))?- .get("text")- .ok_or(anyhow!("unexpected response format"))?- .as_str()- .ok_or(anyhow!("unexpected response format"))?;-- Ok(String::from(res))- }-- pub async fn stream(&self, prompt: &str) -> Result<impl Stream<Item = Result<String>>> {- let client = reqwest::Client::new();-- let mut payload = self.payload(prompt)?;- payload["stream"] = serde_json::json!(true);-- let mut req = client.post(format!("{}/completions", &self.api));-- if let Some(key) = &self.key {- req = req.bearer_auth(key);- }-- Ok(req- .json(&payload)- .send()- .await?- .bytes_stream()- .eventsource()- .map(|event| {- let event = event?;- let data: serde_json::Value = serde_json::from_str(&event.data)?;-- let text = data- .get("choices")- .ok_or(anyhow!("unexpected response format"))?- .get(0)- .ok_or(anyhow!("unexpected response format"))?- .get("text")- .ok_or(anyhow!("unexpected response format"))?- .as_str()- .ok_or(anyhow!("unexpected response format"))?;-- Ok(text.to_string())- }))- }-}--pub struct OpenAiApiBuilder {- api: String,- key: Option<String>,- model: String,- top_p: f64,- temp: f64,- max_tokens: Option<u64>,- stop: Vec<String>,-}--impl OpenAiApiBuilder {- pub fn new(api: String, model: String) -> Self {- let mut api = api;-- if let Some(p) = api.strip_suffix('/') {- api = p.to_string();- }-- Self {- api,- model,- top_p: 0.9,- temp: 1.0,- max_tokens: None,- stop: vec![],- key: None,- }- }-- pub fn api_key(mut self, key: String) -> Self {- self.key = Some(key);- self- }-- pub fn top_p(mut self, top_p: f64) -> Self {- self.top_p = top_p;- self- }-- pub fn temp(mut self, temp: f64) -> Self {- self.temp = temp;- self- }-- pub fn max_tokens(mut self, max_tokens: u64) -> Self {- self.max_tokens = Some(max_tokens);- self- }-- pub fn stop(mut self, stop: Vec<&str>) -> Self {- self.stop = stop.iter().map(|s| s.to_string()).collect();- self- }-- pub fn build(self) -> OpenAiApi {- OpenAiApi {- api: self.api,- top_p: self.top_p,- temp: self.temp,- key: self.key,- max_tokens: self.max_tokens,- stop: self.stop,- model: self.model,- }- }-}diff --git a/crates/core/src/summarizer.rs b/crates/core/src/summarizer.rsindex 8c489dc2..2e847da6 100644--- a/crates/core/src/summarizer.rs+++ b/crates/core/src/summarizer.rs@@ -15,16 +15,14 @@// along with this program. If not, see <https://www.gnu.org/licenses/>.use candle_core::Tensor;-use futures::stream::Stream;use std::{cmp::Reverse,collections::{BinaryHeap, VecDeque},ops::Range,path::Path,};-use tokio_stream::StreamExt;-use crate::{llm_utils::OpenAiApi, models::dual_encoder::DualEncoder, Result};+use crate::{models::dual_encoder::DualEncoder, Result};use itertools::{intersperse, Itertools};use crate::ceil_char_boundary;@@ -249,39 +247,6 @@ impl ExtractiveSummarizer {}}-pub struct Summarizer {- extractive: ExtractiveSummarizer,- abstractive: AbstractiveSummarizer,-}--impl Summarizer {- pub fn new<P: AsRef<Path>>(- path: P,- llm_api_base: String,- model_name: String,- api_key: Option<String>,- ) -> Result<Self> {- Ok(Self {- extractive: ExtractiveSummarizer::open(- path.as_ref().join("dual_encoder").as_path(),- 16,- )?,- abstractive: AbstractiveSummarizer::new(llm_api_base, model_name, api_key),- })- }-- pub async fn summarize(&self, query: &str, text: &str) -> Result<impl Stream<Item = String>> {- let words = text.split_whitespace().count();-- if words < 2000 {- self.abstractive.summarize(text).await- } else {- let summary = self.extractive.summarize(query, text);- self.abstractive.summarize(&summary).await- }- }-}-impl PassageScorer for DualEncoder {type QueryEmbedding = Tensor;@@ -310,101 +275,6 @@ impl PassageScorer for DualEncoder {}}-const TRUNCATE_WORDS_ABSTRACTIVE: usize = 1024;--pub struct AbstractiveSummarizer {- api: String,- model: String,- api_key: Option<String>,-}--impl AbstractiveSummarizer {- pub fn new(api: String, model: String, api_key: Option<String>) -> Self {- Self {- api,- model,- api_key,- }- }-- fn client(&self, max_tokens: Option<u64>) -> OpenAiApi {- let mut builder = OpenAiApi::builder(self.api.clone(), self.model.clone())- .top_p(0.9)- .temp(0.0)- .stop(vec!["</s>", "<|endoftext|>"]);-- if let Some(api_key) = &self.api_key {- builder = builder.api_key(api_key.clone());- }-- if let Some(max_tokens) = max_tokens {- builder = builder.max_tokens(max_tokens);- }-- builder.build()- }-- fn first_prompt(&self, text: &str) -> String {- let wc = 100;- format!(- r##"[INST] I will provide you with piece of content (e.g. articles, papers, documentation, etc.)--You will generate summaries of the content. Refer to the content using words as "this article discusses" etc.-The summaries should be -{wc} words.--After you have generated the summary, identify 1-3 informative entities from the content which are missing from the summary that can be used to make a more concise summary.--A Missing Entity is:--Relevant: to the main story.-Specific: descriptive yet concise (5 words or fewer).-Novel: not in the previous summary.-Faithful: present in the content piece.-Anywhere: located anywhere in the Article.--Finaly, give guidance on how to improve the summary.--Content to summarize:-{text}-[/INST]"##,- )- }-- fn final_prompt(&self, text: &str, prev_summary: &str) -> String {- let wc = 100;- format!(- r##"[INST] I will provide you with piece of content (e.g. articles, papers, documentation, etc.) and a summary of the content.--You will improve upon the previous summary to generate a highly consice summary of the content. The summary should be -{wc} words.--Content to summarize:-{text}--Previous summary:-{prev_summary}-[/INST] Summary:"##,- )- }-- pub async fn summarize(&self, text: &str) -> Result<impl Stream<Item = String>> {- let text = text- .split_ascii_whitespace()- .take(TRUNCATE_WORDS_ABSTRACTIVE)- .join(" ");-- let prompt = self.first_prompt(&text);- let first_summary = self.client(Some(2048)).generate(&prompt).await?;-- let prompt = self.final_prompt(&text, &first_summary);-- Ok(self- .client(Some(128))- .stream(&prompt)- .await?- .filter_map(|tok| tok.ok()))- }-}-#[cfg(test)]mod tests {use super::*;diff --git a/frontend/src/lib/stores.ts b/frontend/src/lib/stores.tsindex a9534a30..deafbb04 100644--- a/frontend/src/lib/stores.ts+++ b/frontend/src/lib/stores.ts@@ -2,8 +2,6 @@ import { browser } from '$app/environment';import { writable } from 'svelte/store';import type { OpticOption } from './optics';import type { SiteRankings } from './rankings';-import { api, type DisplayedWebpage } from './api';-import { match } from 'ts-pattern';const parseJSONWithFallback = <T>(json: string, fallback: T, message = '') => {try {@@ -96,43 +94,3 @@ if (browser)const theme = $theme?.toLowerCase() || '';document.documentElement.className = `${c} ${theme}`.trim();});--type SummaryState = { inProgress: boolean; tokens: string[] } | undefined;-export const summariesStore = writable<Record<string, SummaryState>>({});--// Actions--export const summarize = (query: string, site: DisplayedWebpage) => {- const updateSummary = (update: (summary: SummaryState) => SummaryState) => {- summariesStore.update(($summaries) => ({- ...$summaries,- [site.url]: update($summaries[site.url]),- }));- };-- updateSummary(() => ({ inProgress: true, tokens: [] }));-- const { listen, cancel } = api.summarize({ query, url: site.url });-- listen((e) => {- match(e)- .with({ type: 'message' }, ({ data }) =>- updateSummary((summary) => ({- inProgress: true,- tokens: [...(summary?.tokens ?? []), data],- })),- )- .with({ type: 'error' }, () => {- cancel();- updateSummary((summary) => ({- inProgress: false,- tokens: [...(summary?.tokens ?? [])],- }));- })- .exhaustive();- });-};--export const clearSummary = (site: DisplayedWebpage) => {- summariesStore.update(($summaries) => ({ ...$summaries, [site.url]: void 0 }));-};diff --git a/frontend/src/routes/search/Modal.svelte b/frontend/src/routes/search/Modal.svelteindex a2c8eee1..9dee7858 100644--- a/frontend/src/routes/search/Modal.svelte+++ b/frontend/src/routes/search/Modal.svelte@@ -22,7 +22,7 @@<script lang="ts">import { Ranking } from '$lib/rankings';- import { hostRankingsStore, summarize } from '$lib/stores';+ import { hostRankingsStore } from '$lib/stores';import type { DisplayedWebpage, SignalEnumDiscriminants, SignalScore } from '$lib/api';import { twJoin } from 'tailwind-merge';import Button from '$lib/components/Button.svelte';@@ -33,7 +33,6 @@import { match } from 'ts-pattern';import SignalInfo from './SignalInfo.svelte';- export let query: string;export let modal: { top: number; left: number; site: DisplayedWebpage };const mediumWidthCutoff = 768;@@ -168,8 +167,6 @@[site.site]: $rankings[site.site] == ranking ? void 0 : ranking,}));};-- const summarizeSite = (site: DisplayedWebpage) => () => summarize(query, site);</script><svelte:window bind:innerWidth />@@ -205,9 +202,6 @@</Button>{/each}</div>- <div class="mt-4 flex justify-center">- <Button pale on:click={summarizeSite(modal.site)}>Summarize Result</Button>- </div>{#if signalGroups.length > 0}<h3 class="mt-4 font-medium">Ranking Explanation</h3><div class="flex flex-col gap-y-1">diff --git a/frontend/src/routes/search/Result.svelte b/frontend/src/routes/search/Result.svelteindex cd848443..d198ce96 100644--- a/frontend/src/routes/search/Result.svelte+++ b/frontend/src/routes/search/Result.svelte@@ -4,14 +4,7 @@import AdjustVertical from '~icons/heroicons/adjustments-vertical';import type { DisplayedWebpage } from '$lib/api';import { createEventDispatcher } from 'svelte';- import {- clearSummary,- summariesStore,- markPagesWithAdsStore,- markPagesWithPaywallStore,- } from '$lib/stores';- import Summary from './Summary.svelte';- import { derived } from 'svelte/store';+ import { markPagesWithAdsStore, markPagesWithPaywallStore } from '$lib/stores';import TextSnippet from '$lib/components/TextSnippet.svelte';import StackOverflowSnippet from './StackOverflowSnippet.svelte';import ResultLink from './ResultLink.svelte';@@ -19,8 +12,6 @@export let webpage: DisplayedWebpage;export let resultIndex: number;- const summary = derived(summariesStore, ($summaries) => $summaries[webpage.url]);-let button: HTMLButtonElement;const dispatch = createEventDispatcher<{ modal: HTMLButtonElement }>();@@ -71,9 +62,7 @@</button></div><p class="snippet text-sm font-normal text-neutral-focus [&>b]:font-bold">- {#if $summary}- <Summary url={webpage.url} on:hide={() => clearSummary(webpage)} />- {:else if webpage.richSnippet && webpage.richSnippet._type == 'stackOverflowQA'}+ {#if webpage.richSnippet && webpage.richSnippet._type == 'stackOverflowQA'}<StackOverflowSnippetquestion={webpage.richSnippet.question}answers={webpage.richSnippet.answers}diff --git a/frontend/src/routes/search/Serp.svelte b/frontend/src/routes/search/Serp.svelteindex 2bfa4376..409e0f4b 100644--- a/frontend/src/routes/search/Serp.svelte+++ b/frontend/src/routes/search/Serp.svelte@@ -63,7 +63,7 @@</script>{#if modal}- <Modal {query} {modal} />+ <Modal {modal} />{/if}{#if results._type == 'websites'}diff --git a/frontend/src/routes/search/SignalInfo.svelte b/frontend/src/routes/search/SignalInfo.svelteindex 5c6484c0..6d8c390d 100644--- a/frontend/src/routes/search/SignalInfo.svelte+++ b/frontend/src/routes/search/SignalInfo.svelte@@ -76,7 +76,10 @@title: 'Liked/Disliked',description: 'Another page you have liked/disliked influences the ranking of this page',}))- .with('urlSymbols', () => ({ title: '', description: '' }))+ .with('urlSymbols', () => ({+ title: 'URL Symbols',+ description: 'The URL contains few non-alphanumeric characters',+ })).with('linkDensity', () => ({title: 'Link Density',description: 'The page has a low number of links compared to the amount of text',diff --git a/frontend/src/routes/search/Summary.svelte b/frontend/src/routes/search/Summary.sveltedeleted file mode 100644index f1bb2135..00000000--- a/frontend/src/routes/search/Summary.svelte+++ /dev/null@@ -1,36 +0,0 @@-<script lang="ts">- import XMark from '~icons/heroicons/x-mark-20-solid';- import Callout from '$lib/components/Callout.svelte';- import { createEventDispatcher } from 'svelte';- import { summariesStore } from '$lib/stores';- import { fade } from 'svelte/transition';-- export let url: string;-- $: tokens = $summariesStore[url]?.tokens ?? [];- $: inProgress = $summariesStore[url]?.inProgress ?? false;-- const dispatch = createEventDispatcher<{ hide: null }>();-</script>--<Callout kind="neutral" title="Summary">- <button slot="top-right" on:click={() => dispatch('hide')} title="Hide summary">- <XMark />- </button>-- <p class="line-clamp-3" aria-live="polite" aria-busy={inProgress ? 'true' : 'false'}>- {#if inProgress && tokens.length === 0}- <span class="flex">- <span class="inline-block animate-bounce [animation-delay:000ms]">.</span>- <span class="inline-block animate-bounce [animation-delay:100ms]">.</span>- <span class="inline-block animate-bounce [animation-delay:200ms]">.</span>- </span>- {:else if !inProgress && tokens.length === 0}- <span>No summary available</span>- {:else}- {#each tokens as tok}- <span transition:fade={{ duration: 500 }}>{tok}</span>- {/each}- {/if}- </p>-</Callout>