🤖 fix: Minor Assistants Issues (#4436)

* refactor(OpenAIClient): titleChatCompletion try/catch

* fix: remove duplicate concatenation as seems to be handled by client SDK now

* fix: assistants image upload

* chore: imports order
This commit is contained in:
Danny Avila 2024-10-16 15:04:10 -04:00 committed by GitHub
parent 65888c274a
commit b85c6206ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 16 deletions

View file

@ -842,27 +842,27 @@ class OpenAIClient extends BaseClient {
}
const titleChatCompletion = async () => {
modelOptions.model = model;
try {
modelOptions.model = model;
if (this.azure) {
modelOptions.model = process.env.AZURE_OPENAI_DEFAULT_MODEL ?? modelOptions.model;
this.azureEndpoint = genAzureChatCompletion(this.azure, modelOptions.model, this);
}
if (this.azure) {
modelOptions.model = process.env.AZURE_OPENAI_DEFAULT_MODEL ?? modelOptions.model;
this.azureEndpoint = genAzureChatCompletion(this.azure, modelOptions.model, this);
}
const instructionsPayload = [
{
role: this.options.titleMessageRole ?? (this.isOllama ? 'user' : 'system'),
content: `Please generate ${titleInstruction}
const instructionsPayload = [
{
role: this.options.titleMessageRole ?? (this.isOllama ? 'user' : 'system'),
content: `Please generate ${titleInstruction}
${convo}
||>Title:`,
},
];
},
];
const promptTokens = this.getTokenCountForMessage(instructionsPayload[0]);
const promptTokens = this.getTokenCountForMessage(instructionsPayload[0]);
try {
let useChatCompletion = true;
if (this.options.reverseProxyUrl === CohereConstants.API_URL) {

View file

@ -329,7 +329,7 @@ class StreamRunManager {
}
} else if (typeof delta[key] === 'string' && typeof data[key] === 'string') {
// Concatenate strings
data[key] += delta[key];
// data[key] += delta[key];
} else if (
typeof delta[key] === 'object' &&
delta[key] !== null &&

View file

@ -1,6 +1,12 @@
import { EToolResources } from 'librechat-data-provider';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { dataService, MutationKeys, QueryKeys, defaultOrderQuery } from 'librechat-data-provider';
import {
QueryKeys,
dataService,
MutationKeys,
defaultOrderQuery,
isAssistantsEndpoint,
} from 'librechat-data-provider';
import type * as t from 'librechat-data-provider';
import type { UseMutationResult } from '@tanstack/react-query';
@ -27,8 +33,12 @@ export const useUploadFileMutation = (
const width = body.get('width') ?? '';
const height = body.get('height') ?? '';
const version = body.get('version') ?? '';
const endpoint = (body.get('endpoint') ?? '') as string;
if (isAssistantsEndpoint(endpoint) && version === '2') {
return dataService.uploadFile(body, signal);
}
if (width !== '' && height !== '' && (version !== '' || version.toString() !== '2')) {
if (width !== '' && height !== '') {
return dataService.uploadImage(body, signal);
}