@meaningfully/ui 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +3 -0
- package/dist/App.svelte +86 -0
- package/dist/App.svelte.d.ts +7 -0
- package/dist/assets/base.css +56 -0
- package/dist/assets/electron.svg +10 -0
- package/dist/assets/main.css +171 -0
- package/dist/components/ApiKeyPage.svelte +128 -0
- package/dist/components/ApiKeyPage.svelte.d.ts +9 -0
- package/dist/components/ApiKeyStatus.svelte +38 -0
- package/dist/components/ApiKeyStatus.svelte.d.ts +7 -0
- package/dist/components/CsvUpload.svelte +101 -0
- package/dist/components/CsvUpload.svelte.d.ts +5 -0
- package/dist/components/DatabaseConfig.svelte +485 -0
- package/dist/components/DatabaseConfig.svelte.d.ts +6 -0
- package/dist/components/ExistingDatabases.svelte +175 -0
- package/dist/components/ExistingDatabases.svelte.d.ts +11 -0
- package/dist/components/FrontPage.svelte +18 -0
- package/dist/components/FrontPage.svelte.d.ts +8 -0
- package/dist/components/HelpPage.svelte +119 -0
- package/dist/components/HelpPage.svelte.d.ts +18 -0
- package/dist/components/Preview.svelte +37 -0
- package/dist/components/Preview.svelte.d.ts +9 -0
- package/dist/components/Results.svelte +121 -0
- package/dist/components/Results.svelte.d.ts +10 -0
- package/dist/components/SearchPage.svelte +256 -0
- package/dist/components/SearchPage.svelte.d.ts +9 -0
- package/dist/components/Table.svelte +87 -0
- package/dist/components/Table.svelte.d.ts +11 -0
- package/dist/env.d.ts +39 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +14 -0
- package/dist/stores/fileDataStore.d.ts +8 -0
- package/dist/stores/fileDataStore.js +3 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.js +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
interface Props {
|
|
3
|
+
data?: Array<Record<string, any>>;
|
|
4
|
+
textColumn: string;
|
|
5
|
+
metadataColumns?: string[];
|
|
6
|
+
showSimilarity?: boolean;
|
|
7
|
+
showShowOriginal?: boolean;
|
|
8
|
+
originalDocumentClick?: (sourceNodeId: string) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
data = [],
|
|
13
|
+
textColumn,
|
|
14
|
+
metadataColumns = [],
|
|
15
|
+
showSimilarity = false,
|
|
16
|
+
showShowOriginal = false,
|
|
17
|
+
originalDocumentClick = () => {},
|
|
18
|
+
}: Props = $props();
|
|
19
|
+
|
|
20
|
+
// Combine all columns in display order: metadata, similarity
|
|
21
|
+
// text column is always called text internally, but we rename just the header.
|
|
22
|
+
let columns = $derived([textColumn, ...metadataColumns, ...(showSimilarity ? ['similarity'] : [])]);
|
|
23
|
+
|
|
24
|
+
function sanitizeAndFormatText(text: string): string {
|
|
25
|
+
text = text.trim().replace(/^\\n/, '').replace(/\\n$/, '');
|
|
26
|
+
// First escape special characters
|
|
27
|
+
const escaped = text.replace(/[&<>"']/g, char => ({
|
|
28
|
+
'&': '&',
|
|
29
|
+
'<': '<',
|
|
30
|
+
'>': '>',
|
|
31
|
+
'"': '"',
|
|
32
|
+
"'": '''
|
|
33
|
+
}[char] ?? char));
|
|
34
|
+
|
|
35
|
+
// Then convert newlines to <br> tags
|
|
36
|
+
return escaped.replace(/\\n/g, '<br>');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function is_link(text: string): boolean {
|
|
40
|
+
if (typeof text !== 'string') return false;
|
|
41
|
+
const urlPattern = /(https?:\/\/[^\s]+)/g;
|
|
42
|
+
return urlPattern.test(text);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function linkify(text_that_is_a_link: string): string {
|
|
46
|
+
return `<a href="${text_that_is_a_link}" target="_blank" class="text-blue-500 hover:underline">${text_that_is_a_link}</a>`;
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div class="w-full overflow-x-auto">
|
|
51
|
+
<table class="min-w-full table-auto border-collapse">
|
|
52
|
+
<thead>
|
|
53
|
+
<tr class="bg-gray-100">
|
|
54
|
+
{#each columns as column}
|
|
55
|
+
<th class="px-4 py-2 text-left border-b">{column}</th>
|
|
56
|
+
{/each}
|
|
57
|
+
{#if showShowOriginal}
|
|
58
|
+
<th class="px-4 py-2 text-left border-b"></th><!-- blank column for show all button-->
|
|
59
|
+
{/if}
|
|
60
|
+
</tr>
|
|
61
|
+
</thead>
|
|
62
|
+
<tbody>
|
|
63
|
+
{#each data as row}
|
|
64
|
+
<tr class="border-b hover:bg-gray-50">
|
|
65
|
+
{#each columns as column}
|
|
66
|
+
<td class="px-4 py-2">
|
|
67
|
+
{#if column === 'similarity' && row[column] !== undefined}
|
|
68
|
+
{(row[column] * 100).toFixed(1)}%
|
|
69
|
+
{:else if column === textColumn}
|
|
70
|
+
{@html sanitizeAndFormatText(row[column] || '')}
|
|
71
|
+
{:else if is_link(row[column])}
|
|
72
|
+
{@html linkify(row[column])}
|
|
73
|
+
{:else}
|
|
74
|
+
{(row[column]) || ''}
|
|
75
|
+
{/if}
|
|
76
|
+
</td>
|
|
77
|
+
{/each}
|
|
78
|
+
{#if showShowOriginal}
|
|
79
|
+
<td class="px-4 py-2">
|
|
80
|
+
<button data-testid="result-modal-button" class="text-blue-500 hover:text-blue-700" onclick={() => originalDocumentClick(row.sourceNodeId)}>Original Document</button>
|
|
81
|
+
</td>
|
|
82
|
+
{/if}
|
|
83
|
+
</tr>
|
|
84
|
+
{/each}
|
|
85
|
+
</tbody>
|
|
86
|
+
</table>
|
|
87
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
data?: Array<Record<string, any>>;
|
|
3
|
+
textColumn: string;
|
|
4
|
+
metadataColumns?: string[];
|
|
5
|
+
showSimilarity?: boolean;
|
|
6
|
+
showShowOriginal?: boolean;
|
|
7
|
+
originalDocumentClick?: (sourceNodeId: string) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const Table: import("svelte").Component<Props, {}, "">;
|
|
10
|
+
type Table = ReturnType<typeof Table>;
|
|
11
|
+
export default Table;
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
/// <reference types="vite/client" />
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
interface Settings {
|
|
6
|
+
openAIKey: string;
|
|
7
|
+
oLlamaBaseURL: string;
|
|
8
|
+
azureOpenAIKey: string;
|
|
9
|
+
azureOpenAIEndpoint: string;
|
|
10
|
+
azureOpenAIApiVersion: string;
|
|
11
|
+
mistralApiKey: string;
|
|
12
|
+
geminiApiKey: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface SearchResult {
|
|
16
|
+
content: string;
|
|
17
|
+
similarity: number;
|
|
18
|
+
[key: string]: any; // For metadata fields
|
|
19
|
+
sourceNodeId: string | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface BaseUploadFormData {
|
|
23
|
+
datasetName: string;
|
|
24
|
+
description: string;
|
|
25
|
+
textColumns: string[];
|
|
26
|
+
metadataColumns: string[];
|
|
27
|
+
splitIntoSentences: boolean;
|
|
28
|
+
combineSentencesIntoChunks: boolean;
|
|
29
|
+
sploderMaxSize: number;
|
|
30
|
+
chunkSize: number;
|
|
31
|
+
chunkOverlap: number;
|
|
32
|
+
modelName: string;
|
|
33
|
+
modelProvider: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface UploadFormData extends BaseUploadFormData {
|
|
37
|
+
fileContent: string;
|
|
38
|
+
fileName: string;
|
|
39
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import App from './App.svelte';
|
|
2
|
+
import ApiKeyPage from './components/ApiKeyPage.svelte';
|
|
3
|
+
import ApiKeyStatus from './components/ApiKeyStatus.svelte';
|
|
4
|
+
import CsvUpload from './components/CsvUpload.svelte';
|
|
5
|
+
import DatabaseConfig from './components/DatabaseConfig.svelte';
|
|
6
|
+
import ExistingDatabases from './components/ExistingDatabases.svelte';
|
|
7
|
+
import FrontPage from './components/FrontPage.svelte';
|
|
8
|
+
import HelpPage from './components/HelpPage.svelte';
|
|
9
|
+
import Preview from './components/Preview.svelte';
|
|
10
|
+
import Results from './components/Results.svelte';
|
|
11
|
+
import SearchPage from './components/SearchPage.svelte';
|
|
12
|
+
import Table from './components/Table.svelte';
|
|
13
|
+
export { App, ApiKeyPage, ApiKeyStatus, CsvUpload, DatabaseConfig, ExistingDatabases, FrontPage, HelpPage, Preview, Results, SearchPage, Table };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Reexport your entry components here
|
|
2
|
+
import App from './App.svelte';
|
|
3
|
+
import ApiKeyPage from './components/ApiKeyPage.svelte';
|
|
4
|
+
import ApiKeyStatus from './components/ApiKeyStatus.svelte';
|
|
5
|
+
import CsvUpload from './components/CsvUpload.svelte';
|
|
6
|
+
import DatabaseConfig from './components/DatabaseConfig.svelte';
|
|
7
|
+
import ExistingDatabases from './components/ExistingDatabases.svelte';
|
|
8
|
+
import FrontPage from './components/FrontPage.svelte';
|
|
9
|
+
import HelpPage from './components/HelpPage.svelte';
|
|
10
|
+
import Preview from './components/Preview.svelte';
|
|
11
|
+
import Results from './components/Results.svelte';
|
|
12
|
+
import SearchPage from './components/SearchPage.svelte';
|
|
13
|
+
import Table from './components/Table.svelte';
|
|
14
|
+
export { App, ApiKeyPage, ApiKeyStatus, CsvUpload, DatabaseConfig, ExistingDatabases, FrontPage, HelpPage, Preview, Results, SearchPage, Table };
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './assets/main.css';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface DocumentSet {
|
|
2
|
+
documentSetId: number;
|
|
3
|
+
name: string;
|
|
4
|
+
uploadDate: Date;
|
|
5
|
+
parameters: Record<string, unknown>;
|
|
6
|
+
totalDocuments: number;
|
|
7
|
+
}
|
|
8
|
+
export interface DocumentSetMetadata {
|
|
9
|
+
documentSetId: number;
|
|
10
|
+
name: string;
|
|
11
|
+
uploadDate: Date;
|
|
12
|
+
parameters: Record<string, unknown>;
|
|
13
|
+
totalDocuments: number;
|
|
14
|
+
}
|
|
15
|
+
export interface MeaningfullyAPI {
|
|
16
|
+
listDocumentSets: (page: number, pageSize: number) => Promise<{
|
|
17
|
+
documents: DocumentSetMetadata[];
|
|
18
|
+
total: number;
|
|
19
|
+
}>;
|
|
20
|
+
uploadCsv: (formData: UploadFormData) => Promise<{
|
|
21
|
+
success: boolean;
|
|
22
|
+
documentSetId: number;
|
|
23
|
+
}>;
|
|
24
|
+
generatePreviewData: (formData: UploadFormData) => Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
nodes: Record<string, any>[];
|
|
27
|
+
estimatedPrice: number;
|
|
28
|
+
tokenCount: number;
|
|
29
|
+
pricePer1M: number;
|
|
30
|
+
}>;
|
|
31
|
+
searchDocumentSet: (params: {
|
|
32
|
+
documentSetId: number;
|
|
33
|
+
query: string;
|
|
34
|
+
n_results: number;
|
|
35
|
+
filters?: {
|
|
36
|
+
key: string;
|
|
37
|
+
operator: "==" | "in" | ">" | "<" | "!=" | ">=" | "<=" | "nin" | "any" | "all" | "text_match" | "contains" | "is_empty";
|
|
38
|
+
value: any;
|
|
39
|
+
}[];
|
|
40
|
+
}) => Promise<SearchResult[]>;
|
|
41
|
+
getDocument: (params: {
|
|
42
|
+
documentSetId: number;
|
|
43
|
+
documentId: string;
|
|
44
|
+
}) => Promise<{
|
|
45
|
+
text: string;
|
|
46
|
+
metadata: Record<string, any>;
|
|
47
|
+
}>;
|
|
48
|
+
getSettings: () => Promise<Settings>;
|
|
49
|
+
setSettings: (settings: Settings) => Promise<{
|
|
50
|
+
success: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
deleteDocumentSet: (documentSetId: number) => Promise<void>;
|
|
53
|
+
getDocumentSet: (documentSetId: number) => Promise<DocumentSet>;
|
|
54
|
+
getUploadProgress: () => Promise<{
|
|
55
|
+
progress: number;
|
|
56
|
+
total: number;
|
|
57
|
+
elapsedTimeMs: number;
|
|
58
|
+
estimatedTimeRemainingMs: number | null;
|
|
59
|
+
}>;
|
|
60
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@meaningfully/ui",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Svelte components for meaningfully semantic search",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite dev",
|
|
8
|
+
"build": "vite build && npm run prepack",
|
|
9
|
+
"preview": "vite preview",
|
|
10
|
+
"prepare": "svelte-kit sync || echo ''",
|
|
11
|
+
"prepack": "svelte-kit sync && svelte-package && publint",
|
|
12
|
+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
13
|
+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
14
|
+
"format": "prettier --write .",
|
|
15
|
+
"lint": "prettier --check . && eslint .",
|
|
16
|
+
"test:unit": "vitest",
|
|
17
|
+
"test": "npm run test:unit -- --run"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"!dist/**/*.spec.*"
|
|
23
|
+
],
|
|
24
|
+
"sideEffects": [
|
|
25
|
+
"**/*.css"
|
|
26
|
+
],
|
|
27
|
+
"svelte": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"svelte": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./style.css": "./dist/style.css"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"svelte": "^5.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@eslint/compat": "^1.2.5",
|
|
42
|
+
"@eslint/js": "^9.18.0",
|
|
43
|
+
"@sveltejs/adapter-auto": "^6.0.0",
|
|
44
|
+
"@sveltejs/kit": "^2.22.0",
|
|
45
|
+
"@sveltejs/package": "^2.0.0",
|
|
46
|
+
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
|
47
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
48
|
+
"@types/papaparse": "^5.3.16",
|
|
49
|
+
"@vitest/browser": "^3.2.3",
|
|
50
|
+
"eslint": "^9.18.0",
|
|
51
|
+
"eslint-config-prettier": "^10.0.1",
|
|
52
|
+
"eslint-plugin-svelte": "^3.0.0",
|
|
53
|
+
"globals": "^16.0.0",
|
|
54
|
+
"lodash": "^4.17.21",
|
|
55
|
+
"papaparse": "^5.5.3",
|
|
56
|
+
"playwright": "^1.53.0",
|
|
57
|
+
"prettier": "^3.4.2",
|
|
58
|
+
"prettier-plugin-svelte": "^3.3.3",
|
|
59
|
+
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
60
|
+
"publint": "^0.3.2",
|
|
61
|
+
"svelte": "^5.0.0",
|
|
62
|
+
"svelte-check": "^4.0.0",
|
|
63
|
+
"svelte-routing": "^2.13.0",
|
|
64
|
+
"tailwindcss": "^4.0.0",
|
|
65
|
+
"typescript": "^5.0.0",
|
|
66
|
+
"typescript-eslint": "^8.20.0",
|
|
67
|
+
"vite": "^7.0.4",
|
|
68
|
+
"vitest": "^3.2.3",
|
|
69
|
+
"vitest-browser-svelte": "^0.1.0"
|
|
70
|
+
},
|
|
71
|
+
"keywords": [
|
|
72
|
+
"svelte"
|
|
73
|
+
]
|
|
74
|
+
}
|