Skip to content

Commit 3f895d3

Browse files
committed
chore: setup unstructured endpoint
1 parent 59133ce commit 3f895d3

File tree

7 files changed

+39
-13
lines changed

7 files changed

+39
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ yarn-error.log*
3333
*.sln
3434
.firebase
3535
/coverage
36+
*.log

firebase.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,17 @@
4343
"firestore": {
4444
"rules": "firestore.rules",
4545
"indexes": "firestore.indexes.json"
46+
},
47+
"emulators": {
48+
"firestore": {
49+
"port": 8096
50+
},
51+
"hosting": {
52+
"port": 5006
53+
},
54+
"ui": {
55+
"enabled": true
56+
},
57+
"singleProjectMode": true
4658
}
4759
}

quasar.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ module.exports = configure(function (/* ctx */) {
148148

149149
// https://v2.quasar.dev/quasar-cli-vite/developing-pwa/configuring-pwa
150150
pwa: {
151-
workboxMode: 'generateSW', // or 'injectManifest'
151+
workboxMode: 'injectManifest', // or 'generateSW'
152152
injectPwaMetaTags: true,
153153
swFilename: 'sw.js',
154154
manifestFilename: 'manifest.json',

src-pwa/custom-service-worker.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,38 @@
44
* quasar.config.js > pwa > workboxMode is set to "injectManifest"
55
*/
66

7-
declare const self: ServiceWorkerGlobalScope & typeof globalThis;
7+
declare const self: ServiceWorkerGlobalScope & typeof globalThis
88

9-
import { clientsClaim } from 'workbox-core';
9+
import {clientsClaim} from 'workbox-core'
1010
import {
1111
precacheAndRoute,
1212
cleanupOutdatedCaches,
1313
createHandlerBoundToURL,
14-
} from 'workbox-precaching';
15-
import { registerRoute, NavigationRoute } from 'workbox-routing';
14+
} from 'workbox-precaching'
15+
import {registerRoute, NavigationRoute} from 'workbox-routing'
1616

17-
self.skipWaiting();
18-
clientsClaim();
17+
self.skipWaiting()
18+
clientsClaim()
1919

2020
// Use with precache injection
21-
precacheAndRoute(self.__WB_MANIFEST);
21+
precacheAndRoute(self.__WB_MANIFEST)
2222

23-
cleanupOutdatedCaches();
23+
cleanupOutdatedCaches()
2424

2525
// Non-SSR fallback to index.html
2626
// Production SSR fallback to offline.html (except for dev)
2727
if (process.env.MODE !== 'ssr' || process.env.PROD) {
2828
registerRoute(
2929
new NavigationRoute(
3030
createHandlerBoundToURL(process.env.PWA_FALLBACK_HTML),
31-
{ denylist: [/sw\.js$/, /workbox-(.)*\.js$/] }
31+
{
32+
denylist: [
33+
/sw\.js$/,
34+
/workbox-(.)*\.js$/,
35+
/__\/auth/, // authentication callback
36+
/^\/general\//, // unstructured api endpoint
37+
]
38+
}
3239
)
33-
);
40+
)
3441
}

src/components/SettingsConfigEditor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const settings = ref({
8686
server: 'openai',
8787
azureSettings: {apiKey: '', basePath: ''},
8888
openaiSettings: {apiKey: ''},
89-
unstructuredSettings: {apiKey: '', endpoint: '/api/unstructured'}
89+
unstructuredSettings: {apiKey: '', endpoint: ''}
9090
})
9191
9292
const isSavingSettings = ref(false)

src/lib/ai/config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,8 @@ export function getChatGPTClient(cache:any) {
124124
const client = new ChatGPTClient(getOpenAIParams().apiKey, clientOptions, cache)
125125
return client
126126
}
127+
128+
export function getUnstructuredEndpoint() {
129+
const endpoint = aiUserSettings?.unstructuredSettings?.endpoint ?? ''
130+
return `${endpoint}/general/v0/general`
131+
}

src/lib/ai/unstructured.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from 'axios'
2+
import {getUnstructuredEndpoint} from 'src/lib/ai/config'
23

34
export interface UnstructuredMetadata {
45
filetype: string
@@ -24,7 +25,7 @@ export async function fileToText(file:File) {
2425
}
2526

2627
export async function fileToPartitions(file:File):Promise<Partial<UnstructuredElement>[]> {
27-
const url = 'https://unstructured-api-plgktvor2a-as.a.run.app/general/v0/general';
28+
const url = getUnstructuredEndpoint()
2829

2930
const formData = new FormData();
3031
formData.append('files', file, file.name);

0 commit comments

Comments
 (0)