diff --git a/app.vue b/app.vue index 2c417ae..8a3e7bc 100644 --- a/app.vue +++ b/app.vue @@ -1,99 +1,5 @@ - - - + \ No newline at end of file diff --git a/components/cover.vue b/components/cover.vue new file mode 100644 index 0000000..39256b4 --- /dev/null +++ b/components/cover.vue @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/components/loading.vue b/components/loading.vue new file mode 100644 index 0000000..aeb0df2 --- /dev/null +++ b/components/loading.vue @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/components/results.vue b/components/results.vue new file mode 100644 index 0000000..29f0660 --- /dev/null +++ b/components/results.vue @@ -0,0 +1,32 @@ + + + \ No newline at end of file diff --git a/components/search.vue b/components/search.vue new file mode 100644 index 0000000..3b8e7a9 --- /dev/null +++ b/components/search.vue @@ -0,0 +1,26 @@ + + + + \ No newline at end of file diff --git a/nuxt.config.ts b/nuxt.config.ts index 4882451..def7859 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -8,5 +8,14 @@ export default defineNuxtConfig({ weaviateToken: '', openai: '', cohere: '', + }, + nitro: { + experimental: { + tasks: true + }, + scheduledTasks: { + // Run `db:migrate` task every minute + '15 13 * * 1-5': ['db:migrate'] + } } }) diff --git a/package.json b/package.json index f50aa68..58b587e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "nuxt": "^3.11.1", "vue": "^3.4.21", "vue-router": "^4.3.0", - "weaviate-client": "^3.0.0-beta.22", + "weaviate-client": "^3.0.0-beta.23", "zod": "^3.22.4" }, "devDependencies": { diff --git a/pages/index.vue b/pages/index.vue new file mode 100644 index 0000000..7247b56 --- /dev/null +++ b/pages/index.vue @@ -0,0 +1,27 @@ + + + + + \ No newline at end of file diff --git a/server/api/newsearch.ts b/server/api/newsearch.ts deleted file mode 100644 index 6371497..0000000 --- a/server/api/newsearch.ts +++ /dev/null @@ -1,40 +0,0 @@ -import weaviate, { WeaviateClient } from "weaviate-client" -import { z } from 'zod' - -const responseSchema = z.object({ - query: z.string(), -}) - -export default defineEventHandler<{query: { query: string } }>(async (event) => { - const config = useRuntimeConfig(event) - - const client: WeaviateClient = await weaviate.connectToWCS( - config.weaviateURL, - { - authCredentials: new weaviate.ApiKey(config.weaviateToken), - headers: { - 'X-OpenAI-Api-Key': config.openai, - 'X-Cohere-Api-Key': config.cohere, - } - } - ) - - const result = await getValidatedQuery(event, body => responseSchema.safeParse(body)) - if (!result.success) - throw result.error.issues - - - - // User object is validated and typed! - const searchTerm = result.data.query - // add search - const myCollection = client.collections.get('TrackSearch') - const response = await myCollection.generate.nearText(searchTerm, { - groupedTask: `pick your favourite pleeeease and tell me why. also say how confident you are based off results`, - } - ,{ - limit: 5 - }) - - return response.generated -}) diff --git a/server/api/search.ts b/server/api/search.ts index bc316fb..65ee1bd 100644 --- a/server/api/search.ts +++ b/server/api/search.ts @@ -1,35 +1,36 @@ import weaviate, { WeaviateClient } from "weaviate-client" import { z } from 'zod' -const responseSchema = z.object({ - query: z.string(), -}) -export default defineEventHandler<{query: { query: string } }>(async (event) => { - const config = useRuntimeConfig(event) +export default defineLazyEventHandler(async () => { + const config = useRuntimeConfig() - const client: WeaviateClient = await weaviate.connectToWCS( - config.weaviateURL, - { - authCredentials: new weaviate.ApiKey(config.weaviateToken), - headers: { - 'X-OpenAI-Api-Key': config.openai, - 'X-Cohere-Api-Key': config.cohere, - } +const client: WeaviateClient = await weaviate.connectToWCS( + config.weaviateURL, + { + authCredentials: new weaviate.ApiKey(config.weaviateToken), + headers: { + 'X-OpenAI-Api-Key': config.openai, } - ) + } +) - const result = await getValidatedQuery(event, body => responseSchema.safeParse(body)) - if (!result.success) - throw result.error.issues +const responseSchema = z.object({ + query: z.string(), +}) - // User object is validated and typed! - const searchTerm = result.data.query - const myCollection = client.collections.get('TrackSearcher') +async function vectorSearch(query:string) { + +} - const response = await myCollection.query.nearText(searchTerm, { - limit: 5 + return defineEventHandler<{query: { query: string } }>(async (event) => { + + const result = await getValidatedQuery(event, body => responseSchema.safeParse(body)) + if (!result.success) + throw result.error.issues + + const searchTerm = result.data.query + + return searchTerm }) - - return response.objects -}) +}) \ No newline at end of file diff --git a/types.ts b/types.ts index 1885106..4656998 100644 --- a/types.ts +++ b/types.ts @@ -1,4 +1,4 @@ -import weaviate, { type WeaviateObjectType } from 'weaviate-client' +import weaviate, { type GenerateObject, type GenerativeReturn, type WeaviateObjectType } from 'weaviate-client' export type QuoteType = { quote: string; @@ -12,15 +12,16 @@ export type JeopartyCollection = { } export type TrackSearcher = { + title: string, + artist: string, + album: string, year: number, - rank: number, - title: string - artist: string - album: string + rank: number } - + export type TrackSearchResult = { - response: WeaviateObjectType + response: GenerateObject + } export type SearchResult = { diff --git a/yarn.lock b/yarn.lock index e014c7a..05ab072 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6207,10 +6207,10 @@ vue@^3.4.21: "@vue/server-renderer" "3.4.21" "@vue/shared" "3.4.21" -weaviate-client@^3.0.0-beta.22: - version "3.0.0-beta.22" - resolved "https://registry.yarnpkg.com/weaviate-client/-/weaviate-client-3.0.0-beta.22.tgz#21891be2a38f208cbfbf6eebb09521cd10eac946" - integrity sha512-sFLblj2sLlrccqZQs4l5gXDlbLnaqGVzrXajVguFsBofAZSJEv25TxQMxW1Ta1tsI7CPyy0S15f5QcY69Fx/XA== +weaviate-client@^3.0.0-beta.23: + version "3.0.0-beta.23" + resolved "https://registry.yarnpkg.com/weaviate-client/-/weaviate-client-3.0.0-beta.23.tgz#2d0ecc05899cdf67b3689dc89df3b3e3ef6df52a" + integrity sha512-K8JiW3XjMcvRNOXkXSAz2CwS7Vlzpgc5hV4ZY+5Vm2NxNTLpTbmBmCHecxB0baaDuzFo3l014wuMgIWFJVfPCg== dependencies: graphql "^16.8.1" graphql-request "^6.1.0"