From fb01c7568c936912c41b3ae84649407c762b612d Mon Sep 17 00:00:00 2001 From: Jorge Menjivar Date: Tue, 19 Dec 2023 15:23:53 -0800 Subject: [PATCH] build fixes --- apps/desktop/package.json | 2 +- apps/desktop/providers/messages.tsx | 7 +- .../storage/supabase/helpers/conversation.ts | 4 +- .../storage/supabase/helpers/conversations.ts | 2 +- .../app/storage/supabase/types/supabase.ts | 94 ++++++++++++++++++- pnpm-lock.yaml | 18 +++- 6 files changed, 117 insertions(+), 10 deletions(-) diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 29c782a1..55f06d98 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -81,7 +81,7 @@ "prettier": "^2.8.8", "prettier-eslint": "^16.1.2", "prettier-plugin-tailwindcss": "^0.2.8", - "supabase": "^1.113.2", + "supabase": "^1.123.4", "tailwindcss": "^3.3.5", "tsconfig": "workspace:*", "typescript": "^5.2.2" diff --git a/apps/desktop/providers/messages.tsx b/apps/desktop/providers/messages.tsx index afeac4e0..70341c31 100644 --- a/apps/desktop/providers/messages.tsx +++ b/apps/desktop/providers/messages.tsx @@ -121,12 +121,17 @@ export const MessagesProvider = ({ stream: ReadableStream | null; controller: AbortController | null; }> { + if (selectedConversation.model === null) { + error('No model selected'); + return { stream: null, controller: null }; + } + let customPrompt = selectedConversation.systemPrompt; if (!selectedConversation.systemPrompt) { customPrompt = builtInSystemPrompts.filter( (prompt) => - prompt.name === `${selectedConversation.model.vendor} Built-In`, + prompt.name === `${selectedConversation.model!.vendor} Built-In`, )[0]; } diff --git a/apps/desktop/utils/app/storage/supabase/helpers/conversation.ts b/apps/desktop/utils/app/storage/supabase/helpers/conversation.ts index 3f300343..5a820cbf 100644 --- a/apps/desktop/utils/app/storage/supabase/helpers/conversation.ts +++ b/apps/desktop/utils/app/storage/supabase/helpers/conversation.ts @@ -11,7 +11,7 @@ export const supaCreateConversation = async ( { id: newConversation.id, name: newConversation.name, - model_id: newConversation.model.id, + model_id: newConversation.model?.id, system_prompt_id: newConversation.systemPrompt?.id, folder_id: newConversation.folderId, timestamp: newConversation.timestamp, @@ -38,7 +38,7 @@ export const supaUpdateConversation = async ( { id: updatedConversation.id, name: updatedConversation.name, - model_id: updatedConversation.model.id, + model_id: updatedConversation.model?.id, system_prompt_id: updatedConversation.systemPrompt?.id, folder_id: updatedConversation.folderId, timestamp: updatedConversation.timestamp, diff --git a/apps/desktop/utils/app/storage/supabase/helpers/conversations.ts b/apps/desktop/utils/app/storage/supabase/helpers/conversations.ts index 1d9dfd7c..a22f1715 100644 --- a/apps/desktop/utils/app/storage/supabase/helpers/conversations.ts +++ b/apps/desktop/utils/app/storage/supabase/helpers/conversations.ts @@ -70,7 +70,7 @@ export const supaUpdateConversations = async ( .upsert({ id: conversation.id, name: conversation.name, - model_id: conversation.model.id, + model_id: conversation.model?.id, system_prompt_id: conversation.systemPrompt?.id || null, folder_id: conversation.folderId, timestamp: conversation.timestamp, diff --git a/apps/desktop/utils/app/storage/supabase/types/supabase.ts b/apps/desktop/utils/app/storage/supabase/types/supabase.ts index fd9446c5..a291f57f 100644 --- a/apps/desktop/utils/app/storage/supabase/types/supabase.ts +++ b/apps/desktop/utils/app/storage/supabase/types/supabase.ts @@ -13,7 +13,7 @@ export interface SupaDatabase { Row: { folder_id: string | null; id: string; - model_id: string; + model_id: string | null; name: string; params: Json; system_prompt_id: string | null; @@ -24,7 +24,7 @@ export interface SupaDatabase { Insert: { folder_id?: string | null; id?: string; - model_id: string; + model_id?: string | null; name: string; params?: Json; system_prompt_id?: string | null; @@ -35,7 +35,7 @@ export interface SupaDatabase { Update: { folder_id?: string | null; id?: string; - model_id?: string; + model_id?: string | null; name?: string; params?: Json; system_prompt_id?: string | null; @@ -233,3 +233,91 @@ export interface SupaDatabase { }; }; } + +export type Tables< + PublicTableNameOrOptions extends + | keyof (SupaDatabase['public']['Tables'] & SupaDatabase['public']['Views']) + | { schema: keyof SupaDatabase }, + TableName extends PublicTableNameOrOptions extends { + schema: keyof SupaDatabase; + } + ? keyof (SupaDatabase[PublicTableNameOrOptions['schema']]['Tables'] & + SupaDatabase[PublicTableNameOrOptions['schema']]['Views']) + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof SupaDatabase } + ? (SupaDatabase[PublicTableNameOrOptions['schema']]['Tables'] & + SupaDatabase[PublicTableNameOrOptions['schema']]['Views'])[TableName] extends { + Row: infer R; + } + ? R + : never + : PublicTableNameOrOptions extends keyof (SupaDatabase['public']['Tables'] & + SupaDatabase['public']['Views']) + ? (SupaDatabase['public']['Tables'] & + SupaDatabase['public']['Views'])[PublicTableNameOrOptions] extends { + Row: infer R; + } + ? R + : never + : never; + +export type TablesInsert< + PublicTableNameOrOptions extends + | keyof SupaDatabase['public']['Tables'] + | { schema: keyof SupaDatabase }, + TableName extends PublicTableNameOrOptions extends { + schema: keyof SupaDatabase; + } + ? keyof SupaDatabase[PublicTableNameOrOptions['schema']]['Tables'] + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof SupaDatabase } + ? SupaDatabase[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Insert: infer I; + } + ? I + : never + : PublicTableNameOrOptions extends keyof SupaDatabase['public']['Tables'] + ? SupaDatabase['public']['Tables'][PublicTableNameOrOptions] extends { + Insert: infer I; + } + ? I + : never + : never; + +export type TablesUpdate< + PublicTableNameOrOptions extends + | keyof SupaDatabase['public']['Tables'] + | { schema: keyof SupaDatabase }, + TableName extends PublicTableNameOrOptions extends { + schema: keyof SupaDatabase; + } + ? keyof SupaDatabase[PublicTableNameOrOptions['schema']]['Tables'] + : never = never, +> = PublicTableNameOrOptions extends { schema: keyof SupaDatabase } + ? SupaDatabase[PublicTableNameOrOptions['schema']]['Tables'][TableName] extends { + Update: infer U; + } + ? U + : never + : PublicTableNameOrOptions extends keyof SupaDatabase['public']['Tables'] + ? SupaDatabase['public']['Tables'][PublicTableNameOrOptions] extends { + Update: infer U; + } + ? U + : never + : never; + +export type Enums< + PublicEnumNameOrOptions extends + | keyof SupaDatabase['public']['Enums'] + | { schema: keyof SupaDatabase }, + EnumName extends PublicEnumNameOrOptions extends { + schema: keyof SupaDatabase; + } + ? keyof SupaDatabase[PublicEnumNameOrOptions['schema']]['Enums'] + : never = never, +> = PublicEnumNameOrOptions extends { schema: keyof SupaDatabase } + ? SupaDatabase[PublicEnumNameOrOptions['schema']]['Enums'][EnumName] + : PublicEnumNameOrOptions extends keyof SupaDatabase['public']['Enums'] + ? SupaDatabase['public']['Enums'][PublicEnumNameOrOptions] + : never; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 378b95e2..4eb7bcaf 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -229,8 +229,8 @@ importers: specifier: ^0.2.8 version: 0.2.8(@trivago/prettier-plugin-sort-imports@4.3.0)(prettier@2.8.8) supabase: - specifier: ^1.113.2 - version: 1.113.2 + specifier: ^1.123.4 + version: 1.123.4 tailwindcss: specifier: ^3.3.5 version: 3.3.5 @@ -15069,6 +15069,20 @@ packages: - supports-color dev: true + /supabase@1.123.4: + resolution: {integrity: sha512-HFQOU+n73Ah9sYbja7tdjuqT6QNDzkKXfLCCIbD9GdggbTvGZa3D+0hJPADL4y0vAfsoB5tlx3WBXswnbWIXiw==} + engines: {npm: '>=8'} + hasBin: true + requiresBuild: true + dependencies: + bin-links: 4.0.3 + https-proxy-agent: 7.0.2 + node-fetch: 3.3.2 + tar: 6.2.0 + transitivePeerDependencies: + - supports-color + dev: true + /supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} engines: {node: '>=0.8.0'}