feat(providers): Add Anthropic extended thinking and adapt providers to new streaming/file APIs; bump dependencies and update docs, tests and configuration
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as plugins from './plugins.js';
|
||||
import * as paths from './paths.js';
|
||||
import { Readable } from 'stream';
|
||||
import { toFile } from 'openai';
|
||||
|
||||
// Custom type definition for chat completion messages
|
||||
export type TChatCompletionRequestMessage = {
|
||||
@@ -405,16 +406,19 @@ export class OpenAiProvider extends MultiModalModel {
|
||||
const model = optionsArg.model || this.options.imageModel || 'gpt-image-1';
|
||||
|
||||
try {
|
||||
// Convert Buffer to uploadable file format for OpenAI API
|
||||
const imageFile = await toFile(optionsArg.image, 'image.png', { type: 'image/png' });
|
||||
|
||||
const requestParams: any = {
|
||||
model,
|
||||
image: optionsArg.image,
|
||||
image: imageFile,
|
||||
prompt: optionsArg.prompt,
|
||||
n: optionsArg.n || 1,
|
||||
};
|
||||
|
||||
// Add mask if provided
|
||||
// Add mask if provided (also convert to file format)
|
||||
if (optionsArg.mask) {
|
||||
requestParams.mask = optionsArg.mask;
|
||||
requestParams.mask = await toFile(optionsArg.mask, 'mask.png', { type: 'image/png' });
|
||||
}
|
||||
|
||||
// Add gpt-image-1 specific parameters
|
||||
|
||||
Reference in New Issue
Block a user