From 3f9d9cb226ac173ab8bf676392945853b34a7117 Mon Sep 17 00:00:00 2001 From: "Pedro G. Bascoy" Date: Mon, 4 Mar 2024 09:01:35 +0100 Subject: [PATCH 1/3] deletes language property from body request @ stream.py (#150) --- src/extension/stream.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/extension/stream.ts b/src/extension/stream.ts index f919a92d..df915866 100644 --- a/src/extension/stream.ts +++ b/src/extension/stream.ts @@ -1,7 +1,31 @@ -import { StreamRequest } from '../common/types' +import { MessageRoleContent, MessageType, StreamRequest, StreamBodyOpenAI } from '../common/types' import { logStreamOptions, safeParseJsonResponse } from './utils' + + + +function deleteLanguageFromMessages(messages: MessageType[] | MessageRoleContent | undefined) +{ + // check if messages is MessageType[] -- role does not have a language property + if (Array.isArray(messages)) { + messages.forEach(element => { + delete element.language; + }); + } + +} + export async function streamResponse(request: StreamRequest) { + + // check if request.body is of type StreamBodyOpenAI + if ((request.body as StreamBodyOpenAI).messages){ + // delete language from request body as is not really part of the OpenAI specification + deleteLanguageFromMessages((request.body as StreamBodyOpenAI).messages) + } + + + + logStreamOptions(request) const { body, options, onData, onEnd, onError, onStart } = request const controller = new AbortController() From f92f098f6edac6992033f5db4bfef3dd53eb57bc Mon Sep 17 00:00:00 2001 From: rjmacarthy Date: Thu, 21 Mar 2024 12:30:12 +0000 Subject: [PATCH 2/3] remove non compliant openai api properties from payload --- src/extension/stream.ts | 26 +------------------------- src/webview/chat.tsx | 7 ++----- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/src/extension/stream.ts b/src/extension/stream.ts index df915866..f919a92d 100644 --- a/src/extension/stream.ts +++ b/src/extension/stream.ts @@ -1,31 +1,7 @@ -import { MessageRoleContent, MessageType, StreamRequest, StreamBodyOpenAI } from '../common/types' +import { StreamRequest } from '../common/types' import { logStreamOptions, safeParseJsonResponse } from './utils' - - - -function deleteLanguageFromMessages(messages: MessageType[] | MessageRoleContent | undefined) -{ - // check if messages is MessageType[] -- role does not have a language property - if (Array.isArray(messages)) { - messages.forEach(element => { - delete element.language; - }); - } - -} - export async function streamResponse(request: StreamRequest) { - - // check if request.body is of type StreamBodyOpenAI - if ((request.body as StreamBodyOpenAI).messages){ - // delete language from request body as is not really part of the OpenAI specification - deleteLanguageFromMessages((request.body as StreamBodyOpenAI).messages) - } - - - - logStreamOptions(request) const { body, options, onData, onEnd, onError, onStart } = request const controller = new AbortController() diff --git a/src/webview/chat.tsx b/src/webview/chat.tsx index b22ca7e9..3932611c 100644 --- a/src/webview/chat.tsx +++ b/src/webview/chat.tsx @@ -90,8 +90,6 @@ export const Chat = () => { { role: BOT_NAME, content: getCompletionContent(message), - type: message.value.type, - language: message.value.data } ] global.vscode.postMessage({ @@ -205,8 +203,7 @@ export const Chat = () => { { role: USER_NAME, content: input, - type: 'chat' - } + } ] } as ClientMessage) setMessages((prev) => [ @@ -329,7 +326,7 @@ export const Chat = () => { )} - Selected characters: {selection?.length} + {selection?.length} {apiProvider === ApiProviders.Ollama && ( Date: Thu, 21 Mar 2024 12:33:24 +0000 Subject: [PATCH 3/3] 3.8.9 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 37dd6ab7..499c30c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "twinny", - "version": "3.8.8", + "version": "3.8.9", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "twinny", - "version": "3.8.8", + "version": "3.8.9", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 50bc27e7..a27e32b9 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "twinny", "displayName": "twinny - AI Code Completion and Chat", "description": "Locally hosted AI code completion plugin for vscode", - "version": "3.8.8", + "version": "3.8.9", "icon": "assets/icon.png", "keywords": [ "code-inference",