web search done right
Generate frontend API using abeye (#105)
Oliver Bøvinga2a3d7d97d4b
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 86822921..85806988 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -29,9 +29,10 @@ The process is simple and fast. Upon your first pull request, you will be prompt* Install rust by following the steps outlined [here](https://www.rust-lang.org/tools/install)* Install clang and npm* Update ulimit. RocksDB tends to exceed the max number of allowed open files, so you will have to run `ulimit -n 10240` to increase the allowed max number of open files.-* Install just by running `cargo install just`. This allows you to run the scripts in the `justfile` file. A justfile is basically a simple Makefile. Since libtorch requires some specific environment variables to be set, you need to preface all `cargo run` and `cargo test` commands with `just` (so they becom `just cargo run` and `just cargo test`) .+* Install [just](https://github.com/casey/just) by running `cargo install just`. This allows you to run the scripts in the `justfile` file. A justfile is basically a simple Makefile. Since libtorch requires some specific environment variables to be set, you need to preface all `cargo run` and `cargo test` commands with `just` (so they becom `just cargo run` and `just cargo test`) .* Run the command `just configure` which should automatically configures the rest of your dev environment. The script creates a python virtual environment, installs relevant dependencies, traces and exports the ML models and creates a small local index which you can use for development.* (Optional) run `just configure --alice` to download the weights for Alice (the AI assistant that can search on the web).-* (Optional) Install cargo-watch by running `cargo install cargo-watch`. This makes frontend development easier.+* (Optional) Install [cargo-watch](https://github.com/watchexec/cargo-watch) by running `cargo install cargo-watch`. This makes frontend development easier.+* (Optional) Install [abeye](https://github.com/oeb25/abeye) by running `cargo install --git https://github.com/oeb25/abeye --locked`. This is used for generating the API client used by the frontend by running `just openapi`.After the non optional steps you can now run `just cargo test` and should see all tests passing. If you have installced `cargo-watch`, you should be able to run `just dev` to start the search server and launch the frontend at `0.0.0.0:8000`.diff --git a/core/src/api/alice.rs b/core/src/api/alice.rsindex cf6828f6..b4dffd75 100644--- a/core/src/api/alice.rs+++ b/core/src/api/alice.rs@@ -137,7 +137,7 @@ pub struct AliceParams {path = "/beta/api/alice",params(AliceParams),responses(- (status = 200, description = "Interact with Alice", body = ExecutionState),+ (status = 200, description = "Interact with Alice", body = ExecutionState, content_type = "text/event-stream"),))]pub async fn alice_route(diff --git a/core/src/api/docs.rs b/core/src/api/docs.rsindex 35f0a3c2..80c19975 100644--- a/core/src/api/docs.rs+++ b/core/src/api/docs.rs@@ -55,6 +55,7 @@ use utoipa_swagger_ui::SwaggerUi;crate::snippet::TextSnippet,crate::snippet::TextSnippetFragment,+ crate::snippet::TextSnippetFragmentKind,crate::entity_index::entity::EntitySnippet,crate::entity_index::entity::EntitySnippetFragment,diff --git a/core/src/api/summarize.rs b/core/src/api/summarize.rsindex b8656b3a..0c20a30c 100644--- a/core/src/api/summarize.rs+++ b/core/src/api/summarize.rs@@ -72,7 +72,7 @@ async fn summarize(path = "/beta/api/summarize",params(SummarizeParams),responses(- (status = 200, description = "Summarize a website", body = String),+ (status = 200, description = "Summarize a website", body = String, content_type = "text/event-stream"),))]pub async fn summarize_route(diff --git a/frontend/package.json b/frontend/package.jsonindex 232cc0dd..1a09dec4 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -11,7 +11,7 @@"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch","lint": "prettier --plugin prettier-plugin-svelte --plugin prettier-plugin-tailwindcss --check . && eslint .","format": "prettier --plugin prettier-plugin-svelte --plugin prettier-plugin-tailwindcss --write .",- "openapi": "openapi-typescript http://localhost:3000/beta/api/docs/openapi.json -o src/lib/api/schema.d.ts",+ "openapi": "abeye generate http://localhost:3000/beta/api/docs/openapi.json -t ts --api-prefix /beta/api -o src/lib/api/index.ts && prettier --write src/lib/api/index.ts","test:integration": "playwright test","test:unit": "vitest"},diff --git a/frontend/src/lib/api/com.ts b/frontend/src/lib/api/com.tsdeleted file mode 100644index 6dd120ad..00000000--- a/frontend/src/lib/api/com.ts+++ /dev/null@@ -1,130 +0,0 @@-import { env } from '$env/dynamic/public';-import type { paths } from './schema.d.ts';--type Values<T> = T[keyof T];--export type Props<P extends keyof paths, M extends keyof paths[P]> = paths[P][M] extends {- requestBody: { content: { 'application/json': infer B extends NonNullable<unknown> } };-}- ? B- : paths[P][M] extends { parameters: { path: infer B extends NonNullable<unknown> } }- ? B- : paths[P][M] extends { parameters: { query: infer B extends NonNullable<unknown> } }- ? B- : never;-export type Produces<P extends keyof paths, M extends keyof paths[P]> = paths[P][M] extends {- responses: infer R;-}- ? {- [C in keyof R]: Values<Values<R[C]>>;- }- : never;--export const apiBaseFromEnv = () => env.PUBLIC_API_BASE || 'http://localhost:3000';-export const API_BASE = apiBaseFromEnv();--export type ApiOptions = {- fetch?: typeof fetch;-};--export const send = <- P extends keyof paths,- M extends string & keyof paths[P],- B extends 'requestBody' extends keyof paths[P][M]- ? 'json'- : 'parameters' extends keyof paths[P][M]- ? 'parameters'- : never,->(- path: P,- method: M,- kind: B,- content: Props<P, M>,- options: ApiOptions = {},-): {- data: Promise<Produces<P, M>>;- cancel: (reason?: string) => void;-} => {- const [params, body, headers] =- kind == 'json'- ? ['', JSON.stringify(content), { 'Content-Type': 'application/json' }]- : [`?${new URLSearchParams(content)}`, void 0, {}];-- let inFlight = true;- const controller = new AbortController();- const data = (options.fetch ?? fetch)(`${API_BASE}${path}${params}`, {- method: method.toUpperCase(),- body,- signal: controller.signal,- headers,- }).then(async (res) => {- inFlight = false;- if (res.ok) {- const text = await res.text();- try {- return { [res.status]: JSON.parse(text) } as Produces<P, M>;- } catch (_) {- throw text;- }- } else {- throw res.text();- }- });-- return {- data,- cancel: (reason) => {- if (inFlight) controller.abort(reason);- },- };-};--type SSEStream<P extends keyof paths, M extends keyof paths[P]> = Produces<P, M> extends {- [200]: infer D;-}- ? (- event:- | { type: 'message'; data: D }- | {- type: 'error';- event: Event;- },- ) => void- : never;--export const sse = <- P extends keyof paths,- M extends string & keyof paths[P],- B extends 'requestBody' extends keyof paths[P][M]- ? 'json'- : 'parameters' extends keyof paths[P][M]- ? 'parameters'- : never,->(- path: P,- kind: B,- content: Props<P, M>,- // eslint-disable-next-line @typescript-eslint/no-unused-vars- options?: ApiOptions,-): {- cancel: () => void;- listen: (stream: SSEStream<P, M>) => void;-} => {- const [params] = kind == 'json' ? [''] : [`?${new URLSearchParams(content)}`];-- const source = new EventSource(`${API_BASE}${path}${params}`);-- let stream: SSEStream<P, M> | null = null;-- source.onmessage = (event) => {- const data = event.data;- stream?.({ type: 'message', data });- };- source.onerror = (event) => {- stream?.({ type: 'error', event });- };- return {- cancel: () => source.close(),- listen: (newStream) => (stream = newStream),- };-};diff --git a/frontend/src/lib/api/index.ts b/frontend/src/lib/api/index.tsindex 1de87444..221d86bc 100644--- a/frontend/src/lib/api/index.ts+++ b/frontend/src/lib/api/index.ts@@ -1,159 +1,449 @@-// deno-lint-ignore-file ban-types+type Method = 'DELETE' | 'GET' | 'PUT' | 'POST' | 'HEAD' | 'TRACE' | 'PATCH';-import { match } from 'ts-pattern';-import type { components } from './schema.d.ts';-import { send, sse, type Props, API_BASE, type ApiOptions } from './com';+let GLOBAL_API_BASE = '';+export const getApiBase = (options?: ApiOptions) => options?.apiBase ?? GLOBAL_API_BASE;+export const setGlobalApiBase = (apiBase: string) => (GLOBAL_API_BASE = apiBase);-export const api = {- search: (props: Props<'/beta/api/search', 'post'>, options?: ApiOptions) => {- const { data, cancel } = send('/beta/api/search', 'post', 'json', props, options);+export type ApiOptions = {+ fetch?: typeof fetch;+ apiBase?: string;+};- return { data: data.then((res) => res[200]), cancel };- },+export const requestPlain = (+ method: Method,+ url: string,+ body?: unknown,+ options?: ApiOptions & { headers?: Record<string, string> },+): {+ data: Promise<string>;+ cancel: (reason?: string) => void;+} => {+ let inFlight = true;+ const controller = new AbortController();+ const data = (options?.fetch ?? fetch)(`${getApiBase(options)}${url}`, {+ method: method.toUpperCase(),+ body: typeof body != 'undefined' ? JSON.stringify(body) : void 0,+ signal: controller.signal,+ headers: {+ ...options?.headers,+ ...(typeof body != 'undefined' ? { 'Content-Type': 'application/json' } : {}),+ },+ }).then(async (res) => {+ inFlight = false;+ if (res.ok) {+ const text = await res.text();+ try {+ return text;+ } catch (_) {+ throw text;+ }+ } else {+ throw res.text();+ }+ });- autosuggest: (props: Props<'/beta/api/autosuggest', 'post'>, options?: ApiOptions) => {- const { data, cancel } = send('/beta/api/autosuggest', 'post', 'parameters', props, options);- return { data: data.then((res) => res[200]), cancel };- },+ return {+ data,+ cancel: (reason) => {+ if (inFlight) controller.abort(reason);+ },+ };+};- similarSites: (props: Props<'/beta/api/webgraph/host/similar', 'post'>, options?: ApiOptions) => {- const { data, cancel } = send(- '/beta/api/webgraph/host/similar',- 'post',- 'json',- props,- options,- );- return { data: data.then((res) => res[200]), cancel };- },+export const requestJson = <T>(+ method: Method,+ url: string,+ body?: unknown,+ options: ApiOptions = {},+): {+ data: Promise<T>;+ cancel: (reason?: string) => void;+} => {+ const { data, cancel } = requestPlain(method, url, body, options);+ return { data: data.then((text) => JSON.parse(text) as T), cancel };+};- knowsSite: (props: Props<'/beta/api/webgraph/host/knows', 'post'>, options?: ApiOptions) => {- const { data, cancel } = send(- '/beta/api/webgraph/host/knows',- 'post',- 'parameters',- props,- options,- );- return { data: data.then((res) => res[200]), cancel };- },+export type SSEStream<T> = (+ event:+ | { type: 'message'; data: T }+ | {+ type: 'error';+ event: Event;+ },+) => void;++const sse = <T>(+ _method: Method,+ url: string,+ options?: ApiOptions,+): {+ cancel: () => void;+ listen: (stream: SSEStream<T>) => void;+} => {+ const source = new EventSource(`${getApiBase(options)}${url}`);++ let stream: SSEStream<T> | null = null;- factCheck: (props: Props<'/beta/api/fact_check', 'post'>, options?: ApiOptions) => {- const { data, cancel } = send('/beta/api/fact_check', 'post', 'json', props, options);- return { data: data.then((res) => res[200]), cancel };- },+ source.onmessage = (event) => {+ const data = event.data;+ stream?.({ type: 'message', data });+ };+ source.onerror = (event) => {+ stream?.({ type: 'error', event });+ };+ return {+ cancel: () => source.close(),+ listen: (newStream) => (stream = newStream),+ };+};+export const api = {alice: (- props: Props<'/beta/api/alice', 'get'>,- stream: (- msg:- | { type: 'begin' }- | { type: 'content'; data: ExecutionState }- | {- type: 'done';- },- ) => void,+ query: {+ message: string;+ optic: string;+ prevState: EncodedSavedState;+ },options?: ApiOptions,- ) => {- const { cancel, listen } = sse('/beta/api/alice', 'parameters', props, options);- stream({ type: 'begin' });- listen((e) => {- match(e)- .with({ type: 'message' }, ({ data }) => stream({ type: 'content', data }))- .with({ type: 'error' }, () => {- stream({ type: 'done' });- cancel();- })- .exhaustive();- });- },-+ ) => sse<ExecutionState>('GET', `/beta/api/alice?${new URLSearchParams(query)}`, options),+ autosuggest: (+ params: {+ q: string;+ },+ options?: ApiOptions,+ ) =>+ requestJson<Suggestion[]>(+ 'POST',+ `/beta/api/autosuggest?${new URLSearchParams(params)}`,+ options,+ ),+ exploreExport: (body: ExploreExportOpticParams, options?: ApiOptions) =>+ requestPlain('POST', `/beta/api/explore/export`, body, options),+ factCheck: (body: FactCheckParams, options?: ApiOptions) =>+ requestJson<FactCheckResponse>('POST', `/beta/api/fact_check`, body, options),+ search: (body: ApiSearchQuery, options?: ApiOptions) =>+ requestJson<ApiSearchResult>('POST', `/beta/api/search`, body, options),+ sitesExport: (body: SitesExportOpticParams, options?: ApiOptions) =>+ requestPlain('POST', `/beta/api/sites/export`, body, options),summarize: (- props: Props<'/beta/api/summarize', 'get'>,- stream: (- msg:- | { type: 'begin' }- | { type: 'content'; data: string }- | {- type: 'done';- },- ) => void,+ query: {+ query: string;+ url: string;+ },options?: ApiOptions,- ) => {- const { cancel, listen } = sse('/beta/api/summarize', 'parameters', props, options);- stream({ type: 'begin' });- listen((e) => {- match(e)- .with({ type: 'message' }, ({ data }) => stream({ type: 'content', data }))- .with({ type: 'error' }, () => {- stream({ type: 'done' });- cancel();- })- .exhaustive();- });- },-- sitesExportOptic: (props: Props<'/beta/api/sites/export', 'post'>, options?: ApiOptions) => {- const { data, cancel } = send('/beta/api/sites/export', 'post', 'json', props, options);- return { data: data.then((res) => res[200]), cancel };- },-- exploreExportOptic: (props: Props<'/beta/api/explore/export', 'post'>, options?: ApiOptions) => {- const { data, cancel } = send('/beta/api/explore/export', 'post', 'json', props, options);- return { data: data.then((res) => res[200]), cancel };- },+ ) => sse<string>('GET', `/beta/api/summarize?${new URLSearchParams(query)}`, options),+ webgraphHostIngoing: (+ query: {+ site: string;+ },+ options?: ApiOptions,+ ) =>+ requestJson<FullEdge[]>(+ 'POST',+ `/beta/api/webgraph/host/ingoing?${new URLSearchParams(query)}`,+ options,+ ),+ webgraphHostKnows: (+ query: {+ site: string;+ },+ options?: ApiOptions,+ ) =>+ requestJson<KnowsSite>(+ 'POST',+ `/beta/api/webgraph/host/knows?${new URLSearchParams(query)}`,+ options,+ ),+ webgraphHostOutgoing: (+ query: {+ site: string;+ },+ options?: ApiOptions,+ ) =>+ requestJson<FullEdge[]>(+ 'POST',+ `/beta/api/webgraph/host/outgoing?${new URLSearchParams(query)}`,+ options,+ ),+ webgraphHostSimilar: (body: SimilarSitesParams, options?: ApiOptions) =>+ requestJson<ScoredSite[]>('POST', `/beta/api/webgraph/host/similar`, body, options),+ webgraphPageIngoing: (+ query: {+ page: string;+ },+ options?: ApiOptions,+ ) =>+ requestJson<FullEdge[]>(+ 'POST',+ `/beta/api/webgraph/page/ingoing?${new URLSearchParams(query)}`,+ options,+ ),+ webgraphPageOutgoing: (+ query: {+ page: string;+ },+ options?: ApiOptions,+ ) =>+ requestJson<FullEdge[]>(+ 'POST',+ `/beta/api/webgraph/page/outgoing?${new URLSearchParams(query)}`,+ options,+ ),+};- queryId: ({ query, urls }: { query: string; urls: string[] }, options?: ApiOptions) => {- const { signal, abort } = new AbortController();- let finished = false;- const data = (options?.fetch ?? fetch)(`${API_BASE}/improvement/store`, {- method: 'POST',- signal,- headers: {- 'Content-Type': 'application/json',- },- body: JSON.stringify({- query: query,- urls: urls,- }),+export type ApiSearchQuery = {+ fetchDiscussions?: boolean;+ flattenResponse?: boolean;+ numResults?: number;+ optic?: string;+ page?: number;+ query: string;+ returnRankingSignals?: boolean;+ safeSearch?: boolean;+ selectedRegion?: Region;+ siteRankings?: SiteRankings;+};+export type ApiSearchResult =+ | (WebsitesResult & {+ type: 'websites';})- .then((response) => response.text())- .then((data) => {- finished = true;- return data;- });-- return {- data,- abort: () => {- if (!finished) {- abort();- }- },+ | (BangHit & {+ type: 'bang';+ });+export type Bang = {+ c?: string;+ d?: string;+ r?: number;+ s?: string;+ sc?: string;+ t: string;+ u: string;+};+export type BangHit = {+ bang: Bang;+ redirectTo: UrlWrapper;+};+export type Calculation = {+ input: string;+ result: string;+};+export type CodeOrText =+ | {+ type: 'code';+ value: string;+ }+ | {+ type: 'text';+ value: string;};- },-- sendImprovementClick: ({ queryId, clickIndex }: { queryId: string; clickIndex: number }) => {- window.navigator.sendBeacon(`${API_BASE}/improvement/click?qid=${queryId}&click=${clickIndex}`);- },+export type Definition = string;+export type DisplayedAnswer = {+ answer: string;+ prettyUrl: string;+ snippet: string;+ title: string;+ url: string;+};+export type DisplayedEntity = {+ imageBase64?: string;+ info: string & EntitySnippet[][];+ matchScore: number;+ relatedEntities: DisplayedEntity[];+ smallAbstract: EntitySnippet;+ title: string;+};+export type DisplayedSidebar =+ | {+ type: 'entity';+ value: DisplayedEntity;+ }+ | {+ type: 'stackOverflow';+ value: {+ answer: StackOverflowAnswer;+ title: string;+ };+ };+export type DisplayedWebpage = {+ domain: string;+ prettyUrl: string;+ rankingSignals?: {};+ site: string;+ snippet: Snippet;+ title: string;+ url: string;+};+export type EncodedEncryptedState = string;+export type EncodedSavedState = string;+export type EntitySnippet = {+ fragments: EntitySnippetFragment[];+};+export type EntitySnippetFragment =+ | {+ kind: 'normal';+ text: string;+ }+ | {+ href: string;+ kind: 'link';+ text: string;+ };+export type Example = string;+export type ExecutionState =+ | {+ query: string;+ type: 'beginSearch';+ }+ | {+ query: string;+ result: SimplifiedWebsite[];+ type: 'searchResult';+ }+ | {+ text: string;+ type: 'speaking';+ }+ | {+ state: EncodedEncryptedState;+ type: 'done';+ };+export type ExploreExportOpticParams = {+ chosenSites: string[];+ similarSites: string[];+};+export type FactCheckParams = {+ claim: string;+ evidence: string;+};+export type FactCheckResponse = {+ score: number;+};+export type FullEdge = {+ from: Node;+ label: string;+ to: Node;+};+export type HighlightedSpellCorrection = {+ highlighted: string;+ raw: string;+};+export type KnowsSite =+ | {+ site: string;+ type: 'known';+ }+ | {+ type: 'unknown';+ };+export type Lemma = string;+export type Node = {+ name: string;+};+export type PartOfSpeech = 'noun' | 'verb' | 'adjective' | 'adjectiveSatellite' | 'adverb';+export const PART_OF_SPEECHES = [+ 'noun',+ 'verb',+ 'adjective',+ 'adjectiveSatellite',+ 'adverb',+] satisfies PartOfSpeech[];+export type PartOfSpeechMeaning = {+ meanings: WordMeaning[];+ pos: PartOfSpeech;+};+export type Region = 'All' | 'Denmark' | 'France' | 'Germany' | 'Spain' | 'US';+export const REGIONS = ['All', 'Denmark', 'France', 'Germany', 'Spain', 'US'] satisfies Region[];+export type ScoredSite = {+ description?: string;+ score: number;+ site: string;+};+export type SignalScore = {+ coefficient: number;+ value: number;+};+export type SimilarSitesParams = {+ sites: string[];+ topN: number;+};+export type SimplifiedWebsite = {+ site: string;+ text: string;+ title: string;+ url: string;+};+export type SiteRankings = {+ blocked: string[];+ disliked: string[];+ liked: string[];+};+export type SitesExportOpticParams = {+ siteRankings: SiteRankings;+};+export type Snippet =+ | {+ date?: string;+ text: TextSnippet;+ type: 'normal';+ }+ | {+ answers: StackOverflowAnswer[];+ question: StackOverflowQuestion;+ type: 'stackOverflowQA';+ };+export type StackOverflowAnswer = {+ accepted: boolean;+ body: CodeOrText[];+ date: string;+ upvotes: number;+ url: string;+};+export type StackOverflowQuestion = {+ body: CodeOrText[];+};+export type Suggestion = {+ highlighted: string;+ raw: string;+};+export type TextSnippet = {+ fragments: TextSnippetFragment[];+};+export type TextSnippetFragment = {+ kind: TextSnippetFragmentKind;+ text: string;+};+export type TextSnippetFragmentKind = 'normal' | 'highlighted';+export const TEXT_SNIPPET_FRAGMENT_KINDS = [+ 'normal',+ 'highlighted',+] satisfies TextSnippetFragmentKind[];+export type ThesaurusWidget = {+ meanings: PartOfSpeechMeaning[];+ term: Lemma;+};+export type UrlWrapper = string;+export type WebsitesResult = {+ directAnswer?: DisplayedAnswer;+ discussions?: DisplayedWebpage[];+ hasMoreResults: boolean;+ numHits: number;+ searchDurationMs: number;+ sidebar?: DisplayedSidebar;+ spellCorrectedQuery?: HighlightedSpellCorrection;+ webpages: DisplayedWebpage[];+ widget?: Widget;+};+export type Widget =+ | {+ type: 'calculator';+ value: Calculation;+ }+ | {+ type: 'thesaurus';+ value: ThesaurusWidget;+ };+export type WordMeaning = {+ definition: Definition;+ examples: Example[];+ similar: Lemma[];};--export type SearchResults = components['schemas']['ApiSearchResult'];-export type WebsitesResult = components['schemas']['WebsitesResult'];-export type Webpage = components['schemas']['DisplayedWebpage'];-export type TextSnippet = components['schemas']['TextSnippet'];-export type Sidebar = components['schemas']['DisplayedSidebar'];-export type Entity = components['schemas']['DisplayedEntity'];-export type EntitySnippet = components['schemas']['EntitySnippet'];-export type Widget = components['schemas']['Widget'];-export type ThesaurusWidget = components['schemas']['ThesaurusWidget'];-export type DisplayedAnswer = components['schemas']['DisplayedAnswer'];-export type ScoredSite = components['schemas']['ScoredSite'];-export type Suggestion = components['schemas']['Suggestion'];-export type Region = components['schemas']['Region'];--export type StackOverflowAnswer = components['schemas']['StackOverflowAnswer'];-export type StackOverflowQuestion = components['schemas']['StackOverflowQuestion'];--export type FactCheckResponse = components['schemas']['FactCheckResponse'];-export type ExecutionState = components['schemas']['ExecutionState'];diff --git a/frontend/src/lib/api/schema.d.ts b/frontend/src/lib/api/schema.d.tsdeleted file mode 100644index 85735d40..00000000--- a/frontend/src/lib/api/schema.d.ts+++ /dev/null@@ -1,529 +0,0 @@-/**- * This file was auto-generated by openapi-typescript.- * Do not make direct changes to the file.- */---export interface paths {- "/beta/api/alice": {- get: operations["alice_route"];- };- "/beta/api/autosuggest": {- post: operations["route"];- };- "/beta/api/explore/export": {- post: operations["explore_export_optic"];- };- "/beta/api/fact_check": {- post: operations["fact_check_route"];- };- "/beta/api/search": {- post: operations["api"];- };- "/beta/api/sites/export": {- post: operations["sites_export_optic"];- };- "/beta/api/summarize": {- get: operations["summarize_route"];- };- "/beta/api/webgraph/host/ingoing": {- post: operations["ingoing_hosts"];- };- "/beta/api/webgraph/host/knows": {- post: operations["knows"];- };- "/beta/api/webgraph/host/outgoing": {- post: operations["outgoing_hosts"];- };- "/beta/api/webgraph/host/similar": {- post: operations["similar"];- };- "/beta/api/webgraph/page/ingoing": {- post: operations["ingoing_pages"];- };- "/beta/api/webgraph/page/outgoing": {- post: operations["outgoing_pages"];- };-}--export type webhooks = Record<string, never>;--export interface components {- schemas: {- /**- * SearchQuery- * @example {- * "query": "hello world"- * }- */- ApiSearchQuery: {- fetchDiscussions?: boolean;- flattenResponse?: boolean;- numResults?: number | null;- optic?: string | null;- page?: number | null;- query: string;- returnRankingSignals?: boolean;- safeSearch?: boolean | null;- selectedRegion?: components["schemas"]["Region"] | null;- siteRankings?: components["schemas"]["SiteRankings"] | null;- };- ApiSearchResult: (components["schemas"]["WebsitesResult"] & {- /** @enum {string} */- type: "websites";- }) | (components["schemas"]["BangHit"] & {- /** @enum {string} */- type: "bang";- });- Bang: {- c?: string | null;- d?: string | null;- r?: number | null;- s?: string | null;- sc?: string | null;- t: string;- u: string;- };- BangHit: {- bang: components["schemas"]["Bang"];- redirectTo: components["schemas"]["UrlWrapper"];- };- Calculation: {- input: string;- result: string;- };- CodeOrText: {- /** @enum {string} */- type: "code";- value: string;- } | {- /** @enum {string} */- type: "text";- value: string;- };- Definition: string;- DisplayedAnswer: {- answer: string;- prettyUrl: string;- snippet: string;- title: string;- url: string;- };- DisplayedEntity: {- imageBase64?: string | null;- info: ((string & components["schemas"]["EntitySnippet"])[])[];- /** Format: float */- matchScore: number;- relatedEntities: components["schemas"]["DisplayedEntity"][];- smallAbstract: components["schemas"]["EntitySnippet"];- title: string;- };- DisplayedSidebar: {- /** @enum {string} */- type: "entity";- value: components["schemas"]["DisplayedEntity"];- } | {- /** @enum {string} */- type: "stackOverflow";- value: {- answer: components["schemas"]["StackOverflowAnswer"];- title: string;- };- };- DisplayedWebpage: {- domain: string;- prettyUrl: string;- rankingSignals?: {- [key: string]: components["schemas"]["SignalScore"];- } | null;- site: string;- snippet: components["schemas"]["Snippet"];- title: string;- url: string;- };- /** @description base64 encoded `EncryptedState` */- EncodedEncryptedState: string;- EncodedSavedState: string;- EntitySnippet: {- fragments: components["schemas"]["EntitySnippetFragment"][];- };- EntitySnippetFragment: {- /** @enum {string} */- kind: "normal";- text: string;- } | {- href: string;- /** @enum {string} */- kind: "link";- text: string;- };- Example: string;- ExecutionState: {- query: string;- /** @enum {string} */- type: "beginSearch";- } | {- query: string;- result: components["schemas"]["SimplifiedWebsite"][];- /** @enum {string} */- type: "searchResult";- } | {- text: string;- /** @enum {string} */- type: "speaking";- } | {- state: components["schemas"]["EncodedEncryptedState"];- /** @enum {string} */- type: "done";- };- ExploreExportOpticParams: {- chosenSites: string[];- similarSites: string[];- };- FactCheckParams: {- claim: string;- evidence: string;- };- FactCheckResponse: {- /** Format: double */- score: number;- };- FullEdge: {- from: components["schemas"]["Node"];- label: string;- to: components["schemas"]["Node"];- };- HighlightedSpellCorrection: {- highlighted: string;- raw: string;- };- KnowsSite: {- site: string;- /** @enum {string} */- type: "known";- } | {- /** @enum {string} */- type: "unknown";- };- Lemma: string;- Node: {- name: string;- };- /** @enum {string} */- PartOfSpeech: "noun" | "verb" | "adjective" | "adjectiveSatellite" | "adverb";- PartOfSpeechMeaning: {- meanings: components["schemas"]["WordMeaning"][];- pos: components["schemas"]["PartOfSpeech"];- };- /** @enum {string} */- Region: "All" | "Denmark" | "France" | "Germany" | "Spain" | "US";- ScoredSite: {- description?: string | null;- /** Format: double */- score: number;- site: string;- };- SignalScore: {- /** Format: double */- coefficient: number;- /** Format: double */- value: number;- };- SimilarSitesParams: {- sites: string[];- topN: number;- };- SimplifiedWebsite: {- site: string;- text: string;- title: string;- url: string;- };- SiteRankings: {- blocked: string[];- disliked: string[];- liked: string[];- };- SitesExportOpticParams: {- siteRankings: components["schemas"]["SiteRankings"];- };- Snippet: ({- date?: string | null;- text: components["schemas"]["TextSnippet"];- /** @enum {string} */- type: "normal";- }) | {- answers: components["schemas"]["StackOverflowAnswer"][];- question: components["schemas"]["StackOverflowQuestion"];- /** @enum {string} */- type: "stackOverflowQA";- };- StackOverflowAnswer: {- accepted: boolean;- body: components["schemas"]["CodeOrText"][];- date: string;- /** Format: int32 */- upvotes: number;- url: string;- };- StackOverflowQuestion: {- body: components["schemas"]["CodeOrText"][];- };- Suggestion: {- highlighted: string;- raw: string;- };- TextSnippet: {- fragments: components["schemas"]["TextSnippetFragment"][];- };- TextSnippetFragment: {- kind: components["schemas"]["TextSnippetFragmentKind"];- text: string;- };- ThesaurusWidget: {- meanings: components["schemas"]["PartOfSpeechMeaning"][];- term: components["schemas"]["Lemma"];- };- /**- * Url- * @description Wrapper around `Url` that implements `ToSchema` for `Url`.- */- UrlWrapper: string;- WebsitesResult: {- directAnswer?: components["schemas"]["DisplayedAnswer"] | null;- discussions?: components["schemas"]["DisplayedWebpage"][] | null;- hasMoreResults: boolean;- numHits: number;- searchDurationMs: number;- sidebar?: components["schemas"]["DisplayedSidebar"] | null;- spellCorrectedQuery?: components["schemas"]["HighlightedSpellCorrection"] | null;- webpages: components["schemas"]["DisplayedWebpage"][];- widget?: components["schemas"]["Widget"] | null;- };- Widget: {- /** @enum {string} */- type: "calculator";- value: components["schemas"]["Calculation"];- } | {- /** @enum {string} */- type: "thesaurus";- value: components["schemas"]["ThesaurusWidget"];- };- WordMeaning: {- definition: components["schemas"]["Definition"];- examples: components["schemas"]["Example"][];- similar: components["schemas"]["Lemma"][];- };- };- responses: never;- parameters: never;- requestBodies: never;- headers: never;- pathItems: never;-}--export type $defs = Record<string, never>;--export type external = Record<string, never>;--export interface operations {-- alice_route: {- parameters: {- query: {- message: string;- optic?: string | null;- prevState?: components["schemas"]["EncodedSavedState"] | null;- };- };- responses: {- /** @description Interact with Alice */- 200: {- content: {- "application/json": components["schemas"]["ExecutionState"];- };- };- };- };- route: {- parameters: {- path: {- q: string;- };- };- responses: {- /** @description Autosuggest */- 200: {- content: {- "application/json": components["schemas"]["Suggestion"][];- };- };- };- };- explore_export_optic: {- requestBody: {- content: {- "application/json": components["schemas"]["ExploreExportOpticParams"];- };- };- responses: {- /** @description Export explored sites as an optic */- 200: {- content: {- "text/plain": string;- };- };- };- };- fact_check_route: {- requestBody: {- content: {- "application/json": components["schemas"]["FactCheckParams"];- };- };- responses: {- /** @description Fact check the given claim against the given evidence */- 200: {- content: {- "application/json": components["schemas"]["FactCheckResponse"];- };- };- };- };- api: {- requestBody: {- content: {- "application/json": components["schemas"]["ApiSearchQuery"];- };- };- responses: {- /** @description Search results */- 200: {- content: {- "application/json": components["schemas"]["ApiSearchResult"];- };- };- };- };- sites_export_optic: {- requestBody: {- content: {- "application/json": components["schemas"]["SitesExportOpticParams"];- };- };- responses: {- /** @description Export site rankings as an optic */- 200: {- content: {- "text/plain": string;- };- };- };- };- summarize_route: {- parameters: {- query: {- url: string;- query: string;- };- };- responses: {- /** @description Summarize a website */- 200: {- content: {- "text/plain": string;- };- };- };- };- ingoing_hosts: {- parameters: {- query: {- site: string;- };- };- responses: {- /** @description Incoming links for a particular host */- 200: {- content: {- "application/json": components["schemas"]["FullEdge"][];- };- };- };- };- knows: {- parameters: {- query: {- site: string;- };- };- responses: {- /** @description Whether the site is known */- 200: {- content: {- "application/json": components["schemas"]["KnowsSite"];- };- };- };- };- outgoing_hosts: {- parameters: {- query: {- site: string;- };- };- responses: {- /** @description Outgoing links for a particular host */- 200: {- content: {- "application/json": components["schemas"]["FullEdge"][];- };- };- };- };- similar: {- requestBody: {- content: {- "application/json": components["schemas"]["SimilarSitesParams"];- };- };- responses: {- /** @description List of similar sites */- 200: {- content: {- "application/json": components["schemas"]["ScoredSite"][];- };- };- };- };- ingoing_pages: {- parameters: {- query: {- page: string;- };- };- responses: {- /** @description Incoming links for a particular page */- 200: {- content: {- "application/json": components["schemas"]["FullEdge"][];- };- };- };- };- outgoing_pages: {- parameters: {- query: {- page: string;- };- };- responses: {- /** @description Outgoing links for a particular page */- 200: {- content: {- "application/json": components["schemas"]["FullEdge"][];- };- };- };- };-}diff --git a/frontend/src/lib/components/RegionSelect.svelte b/frontend/src/lib/components/RegionSelect.svelteindex daefaa5d..442da79c 100644--- a/frontend/src/lib/components/RegionSelect.svelte+++ b/frontend/src/lib/components/RegionSelect.svelte@@ -1,12 +1,11 @@<script lang="ts">- import type { Region } from '$lib/api';- import { ALL_REGIONS } from '$lib/regions';+ import { type Region, REGIONS } from '$lib/api';import Select from './Select.svelte';export let searchOnChange: boolean;- export let selected: Region = ALL_REGIONS[0];+ export let selected: Region = REGIONS[0];- $: options = ALL_REGIONS.map((region) => ({+ $: options = REGIONS.map((region) => ({value: region,label: region == 'All' ? 'All Languages' : region,}));diff --git a/frontend/src/lib/improvements.ts b/frontend/src/lib/improvements.tsindex 1cbfeba7..8f8456ea 100644--- a/frontend/src/lib/improvements.ts+++ b/frontend/src/lib/improvements.ts@@ -1,12 +1,17 @@import type { Action } from 'svelte/action';import { writable } from 'svelte/store';-import { api, type Webpage } from './api';+import { getApiBase, type ApiOptions, type DisplayedWebpage, requestPlain } from './api';import { allowStatsStore } from './stores';const queryIdStore = writable<string | undefined>();-export const updateQueryId = async ({ query, webpages }: { query: string; webpages: Webpage[] }) =>- queryIdStore.set(await api.queryId({ query, urls: webpages.map((wp) => wp.url) }).data);+export const updateQueryId = async ({+ query,+ webpages,+}: {+ query: string;+ webpages: DisplayedWebpage[];+}) => queryIdStore.set(await queryId({ query, urls: webpages.map((wp) => wp.url) }).data);export const improvements: Action<HTMLAnchorElement, number> = (node, webpageIndex) => {let queryId: string | undefined;@@ -17,7 +22,7 @@ export const improvements: Action<HTMLAnchorElement, number> = (node, webpageIndconst listener = () => {if (!queryId || !allowStats) return;- api.sendImprovementClick({ queryId, clickIndex: webpageIndex });+ sendImprovementClick({ queryId, clickIndex: webpageIndex });};node.addEventListener('click', listener);@@ -26,3 +31,15 @@ export const improvements: Action<HTMLAnchorElement, number> = (node, webpageInddestroy: () => node.removeEventListener('click', listener),};};++const queryId = ({ query, urls }: { query: string; urls: string[] }, options?: ApiOptions) =>+ requestPlain('POST', '/improvement/store', { query, urls }, options);++const sendImprovementClick = (+ { queryId, clickIndex }: { queryId: string; clickIndex: number },+ options?: ApiOptions,+) => {+ window.navigator.sendBeacon(+ `${getApiBase(options)}/improvement/click?qid=${queryId}&click=${clickIndex}`,+ );+};diff --git a/frontend/src/lib/regions.ts b/frontend/src/lib/regions.tsdeleted file mode 100644index 19de4245..00000000--- a/frontend/src/lib/regions.ts+++ /dev/null@@ -1,10 +0,0 @@-import type { Region } from './api';--export const ALL_REGIONS = [- 'All',- 'Denmark',- 'France',- 'Germany',- 'Spain',- 'US',-] satisfies Region[];diff --git a/frontend/src/lib/stores.ts b/frontend/src/lib/stores.tsindex 16ec5aef..37db7651 100644--- a/frontend/src/lib/stores.ts+++ b/frontend/src/lib/stores.ts@@ -2,7 +2,7 @@ import { browser } from '$app/environment';import { writable } from 'svelte/store';import type { OpticOption } from './optics';import type { SiteRakings } from './rankings';-import { api, type Webpage } from './api';+import { api, type DisplayedWebpage } from './api';import { match } from 'ts-pattern';const parseJSONWithFallback = <T>(json: string, fallback: T, message = '') => {@@ -70,38 +70,42 @@ if (browser)document.documentElement.className = `${c} ${theme}`.trim();});-export const summariesStore = writable<- Record<string, { inProgress: boolean; data: string } | undefined>->({});+type SummaryState = { inProgress: boolean; data: string } | undefined;+export const summariesStore = writable<Record<string, SummaryState>>({});// Actions-export const summarize = (query: string, site: Webpage) => {- api.summarize({ query, url: site.url }, (e) => {- summariesStore.update(($summaries) =>- match(e)- .with({ type: 'begin' }, () => ({- ...$summaries,- [site.url]: { inProgress: true, data: '' },- }))- .with({ type: 'content' }, ({ data }) => ({- ...$summaries,- [site.url]: {- inProgress: true,- data: ($summaries[site.url]?.data ?? '') + data,- },- }))- .with({ type: 'done' }, () => ({- ...$summaries,- [site.url]: {- inProgress: false,- data: $summaries[site.url]?.data ?? '',- },- }))- .exhaustive(),- );+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, data: '' }));++ const { listen, cancel } = api.summarize({ query, url: site.url });++ listen((e) => {+ match(e)+ .with({ type: 'message' }, ({ data }) =>+ updateSummary((summary) => ({+ inProgress: true,+ data: (summary?.data ?? '') + data,+ })),+ )+ .with({ type: 'error' }, () => {+ cancel();+ updateSummary((summary) => ({+ inProgress: false,+ data: summary?.data ?? '',+ }));+ })+ .exhaustive();});};-export const clearSummary = (site: Webpage) => {++export const clearSummary = (site: DisplayedWebpage) => {summariesStore.update(($summaries) => ({ ...$summaries, [site.url]: void 0 }));};diff --git a/frontend/src/routes/+layout.ts b/frontend/src/routes/+layout.tsindex 24a3a786..911a3f6e 100644--- a/frontend/src/routes/+layout.ts+++ b/frontend/src/routes/+layout.ts@@ -1,4 +1,8 @@+import { env } from '$env/dynamic/public';+import { setGlobalApiBase } from '$lib/api';import { globals } from '$lib/globals';import type { LayoutLoad } from './$types';+setGlobalApiBase(env.PUBLIC_API_BASE || 'http://0.0.0.0:3000');+export const load: LayoutLoad = async () => ({ globals: await globals() });diff --git a/frontend/src/routes/explore/+page.svelte b/frontend/src/routes/explore/+page.svelteindex f6000223..57e20c71 100644--- a/frontend/src/routes/explore/+page.svelte+++ b/frontend/src/routes/explore/+page.svelte@@ -22,7 +22,9 @@let errorMessage = false;$: {- api.similarSites({ sites: chosenSites, topN: limit }).data.then((res) => (similarSites = res));+ api+ .webgraphHostSimilar({ sites: chosenSites, topN: limit })+ .data.then((res) => (similarSites = res));}const removeWebsite = async (site: string) => {@@ -35,7 +37,7 @@site = site.trim();if (!site) return;- const result = await api.knowsSite({ site }).data;+ const result = await api.webgraphHostKnows({ site }).data;match(result).with({ type: 'unknown' }, () => {errorMessage = true;@@ -48,7 +50,7 @@};const exportAsOptic = async () => {- const { data } = api.exploreExportOptic({+ const { data } = api.exploreExport({chosenSites,similarSites: similarSites.map((site) => site.site),});diff --git a/frontend/src/routes/search/+page.svelte b/frontend/src/routes/search/+page.svelteindex 6ebaa1ab..24bc8132 100644--- a/frontend/src/routes/search/+page.svelte+++ b/frontend/src/routes/search/+page.svelte@@ -9,7 +9,7 @@import type { PageData } from './$types';import { scale } from 'svelte/transition';import RegionSelect from '$lib/components/RegionSelect.svelte';- import type { Webpage } from '$lib/api';+ import type { DisplayedWebpage } from '$lib/api';import { onMount } from 'svelte';import { twJoin } from 'tailwind-merge';import Button from '$lib/components/Button.svelte';@@ -29,7 +29,7 @@$: results = data.results;$: query = data.query;- let modal: { top: number; left: number; site: Webpage } | undefined;+ let modal: { top: number; left: number; site: DisplayedWebpage } | undefined;onMount(() => {const listener = () => {@@ -40,7 +40,7 @@});const openSearchModal =- (site: Webpage) =>+ (site: DisplayedWebpage) =>({ detail: button }: CustomEvent<HTMLButtonElement>) => {const rect = button.getBoundingClientRect();@@ -95,14 +95,14 @@},] as const;- const rankSite = (site: Webpage, ranking: Ranking) => () => {+ const rankSite = (site: DisplayedWebpage, ranking: Ranking) => () => {siteRankingsStore.update(($rankings) => ({...$rankings,[site.domain]: $rankings[site.domain] == ranking ? void 0 : ranking,}));};- const summarizeSite = (site: Webpage) => () => summarize(query, site);+ const summarizeSite = (site: DisplayedWebpage) => () => summarize(query, site);</script>{#if modal}diff --git a/frontend/src/routes/search/+page.ts b/frontend/src/routes/search/+page.tsindex 6897e9f4..d3a5a3f6 100644--- a/frontend/src/routes/search/+page.ts+++ b/frontend/src/routes/search/+page.ts@@ -1,4 +1,4 @@-import { api, type Region } from '$lib/api';+import { api } from '$lib/api';import { redirect } from '@sveltejs/kit';import type { PageLoad } from './$types';import { fetchRemoteOptic } from '$lib/optics';@@ -8,7 +8,7 @@ import { globals } from '$lib/globals';export const load: PageLoad = async (req) => {const { fetch, url } = req;- var params = extractSearchParams(url.searchParams);+ let params = extractSearchParams(url.searchParams);if (!params.query.trim()) {const form = req.data['form'];diff --git a/frontend/src/routes/search/Discussions.svelte b/frontend/src/routes/search/Discussions.svelteindex 0aed4567..142efeca 100644--- a/frontend/src/routes/search/Discussions.svelte+++ b/frontend/src/routes/search/Discussions.svelte@@ -1,11 +1,11 @@<script lang="ts">import ChevronDown from '~icons/heroicons/chevron-down';import ChatBubbleLeftRight from '~icons/heroicons/chat-bubble-left-right-20-solid';- import type { Webpage } from '$lib/api';+ import type { DisplayedWebpage } from '$lib/api';import TextSnippet from '$lib/components/TextSnippet.svelte';import Button from '$lib/components/Button.svelte';- export let discussions: Webpage[];+ export let discussions: DisplayedWebpage[];let showMore = false;diff --git a/frontend/src/routes/search/Entity.svelte b/frontend/src/routes/search/Entity.svelteindex 54627d22..1b9d7a2a 100644--- a/frontend/src/routes/search/Entity.svelte+++ b/frontend/src/routes/search/Entity.svelte@@ -1,8 +1,8 @@<script lang="ts">- import type { Entity } from '$lib/api';+ import type { DisplayedEntity } from '$lib/api';import EntitySnippet from '$lib/components/EntitySnippet.svelte';- export let entity: Entity;+ export let entity: DisplayedEntity;</script><div class="flex w-full justify-center">diff --git a/frontend/src/routes/search/Result.svelte b/frontend/src/routes/search/Result.svelteindex c82b486a..f6e2f028 100644--- a/frontend/src/routes/search/Result.svelte+++ b/frontend/src/routes/search/Result.svelte@@ -1,6 +1,6 @@<script lang="ts">import AdjustVertical from '~icons/heroicons/adjustments-vertical';- import type { Webpage } from '$lib/api';+ import type { DisplayedWebpage } from '$lib/api';import { createEventDispatcher } from 'svelte';import { clearSummary, summariesStore } from '$lib/stores';import Summary from './Summary.svelte';@@ -8,7 +8,7 @@import { improvements } from '$lib/improvements';import TextSnippet from '$lib/components/TextSnippet.svelte';- export let webpage: Webpage;+ export let webpage: DisplayedWebpage;export let resultIndex: number;const summary = derived(summariesStore, ($summaries) => $summaries[webpage.url]);diff --git a/frontend/src/routes/search/Sidebar.svelte b/frontend/src/routes/search/Sidebar.svelteindex 168b7c4e..80f1cd60 100644--- a/frontend/src/routes/search/Sidebar.svelte+++ b/frontend/src/routes/search/Sidebar.svelte@@ -1,9 +1,9 @@<script lang="ts">- import type { Sidebar } from '$lib/api';+ import type { DisplayedSidebar } from '$lib/api';import Entity from './Entity.svelte';import StackOverflow from './StackOverflow.svelte';- export let sidebar: Sidebar;+ export let sidebar: DisplayedSidebar;</script>{#if sidebar.type == 'entity'}diff --git a/frontend/src/routes/search/ThesaurusWidget.svelte b/frontend/src/routes/search/ThesaurusWidget.svelteindex bd789846..a158e9d4 100644--- a/frontend/src/routes/search/ThesaurusWidget.svelte+++ b/frontend/src/routes/search/ThesaurusWidget.svelte@@ -1,63 +1,65 @@<script lang="ts">- import type { ThesaurusWidget } from '$lib/api';+ import type { PartOfSpeech, ThesaurusWidget } from '$lib/api';- export let widget: ThesaurusWidget;+ export let widget: ThesaurusWidget;- const posName = (pos: "noun" | "verb" | "adjective" | "adjectiveSatellite" | "adverb"): String => {- switch (pos) {- case "noun":- return "Noun";- case "verb":- return "Verb";- case "adjective":- return "Adjective";- case "adjectiveSatellite":- return "Adjective Satellite";- case "adverb":- return "Adverb";- }+ const posName = (pos: PartOfSpeech): String => {+ switch (pos) {+ case 'noun':+ return 'Noun';+ case 'verb':+ return 'Verb';+ case 'adjective':+ return 'Adjective';+ case 'adjectiveSatellite':+ return 'Adjective Satellite';+ case 'adverb':+ return 'Adverb';}+ };</script>--<div class="rounded-xl border pl-5 pr-3 pt-5 pb-1">- <div class="text-neutral-focus">- <h2 class="font-bold text-2xl">{widget.term}</h2>- <div class="flex flex-col space-y-2">- {#each widget.meanings as {pos, meanings}}++<div class="rounded-xl border pb-1 pl-5 pr-3 pt-5">+ <div class="text-neutral-focus">+ <h2 class="text-2xl font-bold">{widget.term}</h2>+ <div class="flex flex-col space-y-2">+ {#each widget.meanings as { pos, meanings }}+ <div>+ <div class="text-sm italic">+ {posName(pos)}+ </div>+ <ol class="list-decimal space-y-2 pl-5">+ {#each meanings as meaning}+ <li><div>- <div class="italic text-sm">- {posName(pos)}- </div>- <ol class="list-decimal space-y-2 pl-5">- {#each meanings as meaning}- <li>- <div>- {meaning.definition}- </div>- {#if meaning.similar.length > 0}- <div class="flex space-x-1 text-sm">- <div class="text-primary-focus font-medium">- Similar:- </div>- <div class="inline-block space-x-1">- {#each meaning.similar as similar}- <div class="float-left inline [&:not(:last-child)]:after:content-[',']">- <a class="float-left hover:underline" href="/search?q={encodeURIComponent('definition of ' + similar)}">- {similar}- </a>- </div>- {/each}- </div>- </div>- {/if}- </li>- {/each}- </ol>+ {meaning.definition}</div>+ {#if meaning.similar.length > 0}+ <div class="flex space-x-1 text-sm">+ <div class="font-medium text-primary-focus">Similar:</div>+ <div class="inline-block space-x-1">+ {#each meaning.similar as similar}+ <div class="float-left inline [&:not(:last-child)]:after:content-[',']">+ <a+ class="float-left hover:underline"+ href="/search?q={encodeURIComponent('definition of ' + similar)}"+ >+ {similar}+ </a>+ </div>+ {/each}+ </div>+ </div>+ {/if}+ </li>{/each}+ </ol></div>- <div class="text-[0.75rem] italic text-neutral float-right mt-1">- Data from <a href="https://en-word.net/" class="hover:underline">Open English WordNet</a> and <a href="https://wordnet.princeton.edu/" class="hover:underline">Princeton WordNet</a>- </div>+ {/each}+ </div>+ <div class="float-right mt-1 text-[0.75rem] italic text-neutral">+ Data from <a href="https://en-word.net/" class="hover:underline">Open English WordNet</a> and+ <a href="https://wordnet.princeton.edu/" class="hover:underline">Princeton WordNet</a></div>-</div>\ No newline at end of file+ </div>+</div>diff --git a/frontend/src/routes/settings/sites/+page.svelte b/frontend/src/routes/settings/sites/+page.svelteindex 8470c4bc..18353e66 100644--- a/frontend/src/routes/settings/sites/+page.svelte+++ b/frontend/src/routes/settings/sites/+page.svelte@@ -43,7 +43,7 @@const clearAndExport =({ clear }: { clear: boolean }) =>async () => {- const { data } = api.sitesExportOptic({+ const { data } = api.sitesExport({siteRankings: $ranked,});const { default: fileSaver } = await import('file-saver');