Modernize codebase
This commit is contained in:
@@ -1,25 +1,18 @@
|
||||
import fs from 'fs';
|
||||
import { GoogleGenerativeAI } from '@google/generative-ai';
|
||||
import { VisionProvider, VisionProviderConfig, VisionResult, BatchContext } from '../../interfaces';
|
||||
|
||||
type GoogleGenerativeAI = any;
|
||||
type GenerativeModel = any;
|
||||
|
||||
/**
|
||||
* Google Gemini Vision Provider Implementation
|
||||
*/
|
||||
export class GeminiVisionProvider implements VisionProvider {
|
||||
private config: VisionProviderConfig;
|
||||
private genAI: GoogleGenerativeAI;
|
||||
private model: GenerativeModel;
|
||||
private model: any;
|
||||
|
||||
constructor(config: VisionProviderConfig) {
|
||||
this.config = config;
|
||||
|
||||
// Import the Google Generative AI SDK
|
||||
const { GoogleGenerativeAI } = require("@google/generative-ai");
|
||||
|
||||
// Initialize the API
|
||||
this.genAI = new GoogleGenerativeAI(config.apiKey);
|
||||
this.genAI = new GoogleGenerativeAI(config.apiKey!);
|
||||
this.model = this.genAI.getGenerativeModel({ model: config.model });
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export class OpenAIVisionProvider implements VisionProvider {
|
||||
]
|
||||
}
|
||||
],
|
||||
max_tokens: this.config.maxTokens || 300
|
||||
max_completion_tokens: this.config.maxTokens || 300
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -101,7 +101,7 @@ export class OpenAIVisionProvider implements VisionProvider {
|
||||
]
|
||||
}
|
||||
],
|
||||
max_tokens: this.config.maxTokens || 300
|
||||
max_completion_tokens: this.config.maxTokens || 300
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -171,7 +171,7 @@ export class OpenAIVisionProvider implements VisionProvider {
|
||||
const response = await this.openai.chat.completions.create({
|
||||
model: this.config.model,
|
||||
messages,
|
||||
max_tokens: this.config.maxTokens || 300
|
||||
max_completion_tokens: this.config.maxTokens || 300
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user