mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
🤖 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:
parent
65888c274a
commit
b85c6206ab
3 changed files with 26 additions and 16 deletions
|
@ -842,27 +842,27 @@ class OpenAIClient extends BaseClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
const titleChatCompletion = async () => {
|
const titleChatCompletion = async () => {
|
||||||
modelOptions.model = model;
|
try {
|
||||||
|
modelOptions.model = model;
|
||||||
|
|
||||||
if (this.azure) {
|
if (this.azure) {
|
||||||
modelOptions.model = process.env.AZURE_OPENAI_DEFAULT_MODEL ?? modelOptions.model;
|
modelOptions.model = process.env.AZURE_OPENAI_DEFAULT_MODEL ?? modelOptions.model;
|
||||||
this.azureEndpoint = genAzureChatCompletion(this.azure, modelOptions.model, this);
|
this.azureEndpoint = genAzureChatCompletion(this.azure, modelOptions.model, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
const instructionsPayload = [
|
const instructionsPayload = [
|
||||||
{
|
{
|
||||||
role: this.options.titleMessageRole ?? (this.isOllama ? 'user' : 'system'),
|
role: this.options.titleMessageRole ?? (this.isOllama ? 'user' : 'system'),
|
||||||
content: `Please generate ${titleInstruction}
|
content: `Please generate ${titleInstruction}
|
||||||
|
|
||||||
${convo}
|
${convo}
|
||||||
|
|
||||||
||>Title:`,
|
||>Title:`,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const promptTokens = this.getTokenCountForMessage(instructionsPayload[0]);
|
const promptTokens = this.getTokenCountForMessage(instructionsPayload[0]);
|
||||||
|
|
||||||
try {
|
|
||||||
let useChatCompletion = true;
|
let useChatCompletion = true;
|
||||||
|
|
||||||
if (this.options.reverseProxyUrl === CohereConstants.API_URL) {
|
if (this.options.reverseProxyUrl === CohereConstants.API_URL) {
|
||||||
|
|
|
@ -329,7 +329,7 @@ class StreamRunManager {
|
||||||
}
|
}
|
||||||
} else if (typeof delta[key] === 'string' && typeof data[key] === 'string') {
|
} else if (typeof delta[key] === 'string' && typeof data[key] === 'string') {
|
||||||
// Concatenate strings
|
// Concatenate strings
|
||||||
data[key] += delta[key];
|
// data[key] += delta[key];
|
||||||
} else if (
|
} else if (
|
||||||
typeof delta[key] === 'object' &&
|
typeof delta[key] === 'object' &&
|
||||||
delta[key] !== null &&
|
delta[key] !== null &&
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import { EToolResources } from 'librechat-data-provider';
|
import { EToolResources } from 'librechat-data-provider';
|
||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
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 * as t from 'librechat-data-provider';
|
||||||
import type { UseMutationResult } from '@tanstack/react-query';
|
import type { UseMutationResult } from '@tanstack/react-query';
|
||||||
|
|
||||||
|
@ -27,8 +33,12 @@ export const useUploadFileMutation = (
|
||||||
const width = body.get('width') ?? '';
|
const width = body.get('width') ?? '';
|
||||||
const height = body.get('height') ?? '';
|
const height = body.get('height') ?? '';
|
||||||
const version = body.get('version') ?? '';
|
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);
|
return dataService.uploadImage(body, signal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue