feat: adjust schema and queries for Unbody project migration

This commit is contained in:
Hossein Mehrabi 2024-01-08 19:37:05 +03:30
parent 8657a4e95f
commit 951c93f3be
No known key found for this signature in database
GPG Key ID: 45C04964191AFAA1
6 changed files with 15370 additions and 6544 deletions

View File

@ -21,6 +21,9 @@ const config: CodegenConfig = {
],
documents: ['src/**/*.{ts,tsx}'],
generates: {
'src/lib/unbody/unbody.graphql': {
plugins: ['schema-ast'],
},
'src/lib/unbody/unbody.generated.ts': {
plugins: ['typescript', 'typescript-operations', 'typed-document-node'],
presetConfig: {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,7 +63,7 @@ export default async function handler(
if (postTypes.length > 0) {
const response = await unbodyApi.searchPosts({
tags,
query: Array.isArray(q) ? q.join(' ') : q,
query: Array.isArray(q) ? q.join(' ').trim() : q.trim(),
type: postTypes as LPE.PostType[],

View File

@ -16,7 +16,7 @@ export const GET_POSTS_QUERY = gql`
$filter: GetObjectsGoogleDocWhereInpObj
$sort: [GetObjectsGoogleDocSortInpObj]
$searchResult: Boolean = false
$nearText: Txt2VecOpenAIGetObjectsGoogleDocNearTextInpObj
$nearText: Txt2VecC11yGetObjectsGoogleDocNearTextInpObj
$hybrid: GetObjectsGoogleDocHybridInpObj
$nearObject: GetObjectsGoogleDocNearObjectInpObj
$skip: Int = 0
@ -120,8 +120,8 @@ export const SEARCH_BLOCKS_QUERY = gql`
query SearchBlocks(
$limit: Int
$skip: Int
$textNearText: Txt2VecOpenAIGetObjectsTextBlockNearTextInpObj
$imageNearText: Txt2VecOpenAIGetObjectsImageBlockNearTextInpObj
$textNearText: Txt2VecC11yGetObjectsTextBlockNearTextInpObj
$imageNearText: Txt2VecC11yGetObjectsImageBlockNearTextInpObj
$textFilter: GetObjectsTextBlockWhereInpObj
$imageFilter: GetObjectsImageBlockWhereInpObj
$textHybrid: GetObjectsTextBlockHybridInpObj

View File

@ -17,7 +17,7 @@ import {
GetPostsDocument,
GetPostsQueryVariables,
SearchBlocksDocument,
Txt2VecOpenAiGetObjectsTextBlockNearTextInpObj,
Txt2VecC11yGetObjectsTextBlockNearTextInpObj,
} from '../../lib/unbody/unbody.generated'
import { getWebhookData } from '../../pages/api/webhook'
import {
@ -1228,7 +1228,7 @@ export class UnbodyService {
({
concepts: [q, ...tags],
certainty: 0.75,
} as Txt2VecOpenAiGetObjectsTextBlockNearTextInpObj)
} as Txt2VecC11yGetObjectsTextBlockNearTextInpObj)
const filter = {
operator: 'And',
@ -1345,10 +1345,14 @@ export class UnbodyService {
skip,
limit,
filter,
hybrid: {
query: query || '',
alpha: 0.75,
},
...(query && query.length > 0
? {
hybrid: {
query,
alpha: 0.75,
},
}
: {}),
})
const { data: shows } = await this.getPodcastShows({
@ -1415,7 +1419,7 @@ export class UnbodyService {
({
concepts: [query],
certainty,
} as Txt2VecOpenAiGetObjectsTextBlockNearTextInpObj)
} as Txt2VecC11yGetObjectsTextBlockNearTextInpObj)
const filter = {
operator: 'And',