feat: initialize default model providers

old-agentic-v1^2
Philipp Burckhardt 2023-07-09 17:31:59 -04:00
rodzic 94c33a81b2
commit a5adc08ad0
4 zmienionych plików z 12 dodań i 4 usunięć

Wyświetl plik

@ -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

Wyświetl plik

@ -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 = ' '

Wyświetl plik

@ -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
})

Wyświetl plik

@ -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,