From 78f0b0a78b2384677b99e617573decd81af7f9be Mon Sep 17 00:00:00 2001 From: Alexander Song Date: Thu, 31 Oct 2024 00:33:24 -0700 Subject: [PATCH] update ui --- app/schema.graphql | 7 ++---- app/src/pages/playground/PlaygroundOutput.tsx | 24 ++++++------------ .../PlaygroundOutputSubscription.graphql.ts | 25 ++++++------------- 3 files changed, 17 insertions(+), 39 deletions(-) diff --git a/app/schema.graphql b/app/schema.graphql index c73ca07cd0..386e3e46b5 100644 --- a/app/schema.graphql +++ b/app/schema.graphql @@ -96,11 +96,7 @@ enum ChatCompletionMessageRole { AI } -type ChatCompletionSubscriptionError { - message: String! -} - -union ChatCompletionSubscriptionPayload = TextChunk | ToolCallChunk | FinishedChatCompletion | ChatCompletionSubscriptionError +union ChatCompletionSubscriptionPayload = TextChunk | ToolCallChunk | FinishedChatCompletion input ClearProjectInput { id: GlobalID! @@ -835,6 +831,7 @@ type ExportedFile { type FinishedChatCompletion { span: Span! + errorMessage: String } type FunctionCallChunk { diff --git a/app/src/pages/playground/PlaygroundOutput.tsx b/app/src/pages/playground/PlaygroundOutput.tsx index db4e7df0f7..fa7391b219 100644 --- a/app/src/pages/playground/PlaygroundOutput.tsx +++ b/app/src/pages/playground/PlaygroundOutput.tsx @@ -200,9 +200,7 @@ function useChatCompletionSubscription({ span { id } - } - ... on ChatCompletionSubscriptionError { - message + errorMessage } } } @@ -378,20 +376,12 @@ function PlaygroundOutputText(props: PlaygroundInstanceProps) { spanId: chatCompletion.span.id, }, }); - } else if ( - chatCompletion.__typename === "ChatCompletionSubscriptionError" - ) { - markPlaygroundInstanceComplete(props.playgroundInstanceId); - updateInstance({ - instanceId: props.playgroundInstanceId, - patch: { - isRunning: false, - }, - }); - notifyError({ - title: "Chat completion failed", - message: chatCompletion.message, - }); + if (chatCompletion.errorMessage != null) { + notifyError({ + title: "Chat completion failed", + message: chatCompletion.errorMessage, + }); + } } }, onCompleted: () => { diff --git a/app/src/pages/playground/__generated__/PlaygroundOutputSubscription.graphql.ts b/app/src/pages/playground/__generated__/PlaygroundOutputSubscription.graphql.ts index ccd5b858e9..f09a473c08 100644 --- a/app/src/pages/playground/__generated__/PlaygroundOutputSubscription.graphql.ts +++ b/app/src/pages/playground/__generated__/PlaygroundOutputSubscription.graphql.ts @@ -1,5 +1,5 @@ /** - * @generated SignedSource<> + * @generated SignedSource<<4f7aeae517494561280d66dc85bb7845>> * @lightSyntaxTransform * @nogrep */ @@ -47,10 +47,8 @@ export type PlaygroundOutputSubscription$variables = { }; export type PlaygroundOutputSubscription$data = { readonly chatCompletion: { - readonly __typename: "ChatCompletionSubscriptionError"; - readonly message: string; - } | { readonly __typename: "FinishedChatCompletion"; + readonly errorMessage: string | null; readonly span: { readonly id: string; }; @@ -227,23 +225,16 @@ v7 = [ (v6/*: any*/) ], "storageKey": null - } - ], - "type": "FinishedChatCompletion", - "abstractKey": null - }, - { - "kind": "InlineFragment", - "selections": [ + }, { "alias": null, "args": null, "kind": "ScalarField", - "name": "message", + "name": "errorMessage", "storageKey": null } ], - "type": "ChatCompletionSubscriptionError", + "type": "FinishedChatCompletion", "abstractKey": null } ], @@ -282,16 +273,16 @@ return { "selections": (v7/*: any*/) }, "params": { - "cacheID": "96dec42dd14805e9b1adc1c112321064", + "cacheID": "0fbce83a7d4b1caf5bcd9536c1faaebf", "id": null, "metadata": {}, "name": "PlaygroundOutputSubscription", "operationKind": "subscription", - "text": "subscription PlaygroundOutputSubscription(\n $messages: [ChatCompletionMessageInput!]!\n $model: GenerativeModelInput!\n $invocationParameters: InvocationParameters!\n $tools: [JSON!]\n $templateOptions: TemplateOptions\n $apiKey: String\n) {\n chatCompletion(input: {messages: $messages, model: $model, invocationParameters: $invocationParameters, tools: $tools, template: $templateOptions, apiKey: $apiKey}) {\n __typename\n ... on TextChunk {\n content\n }\n ... on ToolCallChunk {\n id\n function {\n name\n arguments\n }\n }\n ... on FinishedChatCompletion {\n span {\n id\n }\n }\n ... on ChatCompletionSubscriptionError {\n message\n }\n }\n}\n" + "text": "subscription PlaygroundOutputSubscription(\n $messages: [ChatCompletionMessageInput!]!\n $model: GenerativeModelInput!\n $invocationParameters: InvocationParameters!\n $tools: [JSON!]\n $templateOptions: TemplateOptions\n $apiKey: String\n) {\n chatCompletion(input: {messages: $messages, model: $model, invocationParameters: $invocationParameters, tools: $tools, template: $templateOptions, apiKey: $apiKey}) {\n __typename\n ... on TextChunk {\n content\n }\n ... on ToolCallChunk {\n id\n function {\n name\n arguments\n }\n }\n ... on FinishedChatCompletion {\n span {\n id\n }\n errorMessage\n }\n }\n}\n" } }; })(); -(node as any).hash = "c29d5c7acf3f5090b92480ce34101fa6"; +(node as any).hash = "2733e53429666a3aa69f68622c8db833"; export default node;