kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
feat: initialize default model providers
rodzic
94c33a81b2
commit
a5adc08ad0
|
@ -1,5 +1,7 @@
|
|||
import { Anthropic } from '@anthropic-ai/sdk'
|
||||
import { EventEmitter } from 'eventemitter3'
|
||||
import defaultKy from 'ky'
|
||||
import { OpenAIClient } from 'openai-fetch'
|
||||
import { SetOptional } from 'type-fest'
|
||||
|
||||
import * as types from './types'
|
||||
|
@ -49,8 +51,8 @@ export class Agentic extends EventEmitter {
|
|||
globalThis.__agentic = new WeakRef(this)
|
||||
}
|
||||
|
||||
this._openai = opts.openai
|
||||
this._anthropic = opts.anthropic
|
||||
this._openai = opts.openai || new OpenAIClient()
|
||||
this._anthropic = opts.anthropic || new Anthropic()
|
||||
|
||||
this._ky = opts.ky ?? defaultKy
|
||||
this._logger = opts.logger ?? defaultLogger
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export const DEFAULT_ANTHROPIC_MODEL = 'claude-instant-v1'
|
||||
export const DEFAULT_OPENAI_MODEL = 'gpt-3.5-turbo'
|
||||
export const DEFAULT_BOT_NAME = 'Agentic Bot'
|
||||
export const SKIP_HOOKS = Symbol('SKIP_HOOKS')
|
||||
export const SPACE = ' '
|
||||
|
|
|
@ -3,6 +3,7 @@ import { type SetOptional } from 'type-fest'
|
|||
|
||||
import * as types from '@/types'
|
||||
import { DEFAULT_ANTHROPIC_MODEL } from '@/constants'
|
||||
import { getEnv } from '@/env'
|
||||
|
||||
import { BaseChatCompletion } from './chat'
|
||||
|
||||
|
@ -34,7 +35,10 @@ export class AnthropicChatCompletion<
|
|||
) {
|
||||
super({
|
||||
provider: 'anthropic',
|
||||
model: options.modelParams?.model || DEFAULT_ANTHROPIC_MODEL,
|
||||
model:
|
||||
options.modelParams?.model ??
|
||||
getEnv('ANTHROPIC_MODEL') ??
|
||||
getEnv('ANTHROPIC_DEFAULT_MODEL', DEFAULT_ANTHROPIC_MODEL),
|
||||
...options
|
||||
})
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import type { SetOptional } from 'type-fest'
|
||||
|
||||
import * as types from '@/types'
|
||||
import { DEFAULT_OPENAI_MODEL } from '@/constants'
|
||||
import { getEnv } from '@/env'
|
||||
import { BaseTask } from '@/task'
|
||||
|
||||
|
@ -34,7 +35,7 @@ export class OpenAIChatCompletion<
|
|||
const model =
|
||||
options.modelParams?.model ??
|
||||
getEnv('OPENAI_MODEL') ??
|
||||
getEnv('OPENAI_DEFAULT_MODEL', 'gpt-3.5-turbo')
|
||||
getEnv('OPENAI_DEFAULT_MODEL', DEFAULT_OPENAI_MODEL)
|
||||
super({
|
||||
provider: 'openai',
|
||||
model,
|
||||
|
|
Ładowanie…
Reference in New Issue