Skip to content

Commit

Permalink
feat: support custom URL and model.
Browse files Browse the repository at this point in the history
  • Loading branch information
Okysu committed Feb 4, 2024
1 parent 0587b88 commit d2c8e44
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
OPENAI_API_KEY=
MODEL_NAME="gpt-3.5-turbo-1106"
AI_SERVICE_URL="https://api.openai.com/v1"
2 changes: 2 additions & 0 deletions packages/ai/.env.example
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
OPENAI_API_KEY=
MODEL_NAME="gpt-3.5-turbo-1106"
AI_SERVICE_URL="https://api.openai.com/v1"
6 changes: 4 additions & 2 deletions packages/ai/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import OpenAI from 'openai'

const deepseekApiUrl = 'https://api.deepseek.com/v1'

const aiServiceUrl = process.env.AI_SERVICE_URL || deepseekApiUrl

export const openai = new OpenAI({
baseURL: deepseekApiUrl,
baseURL: aiServiceUrl,
apiKey: process.env.OPENAI_API_KEY, // This is the default and can be omitted
})

export const baseModel = 'deepseek-chat'
export const baseModel = process.env.MODEL_NAME || 'deepseek-chat'

export const baseChatCompletionCreateParams: Partial<OpenAI.ChatCompletionCreateParamsNonStreaming> = {
max_tokens: 300,
Expand Down

0 comments on commit d2c8e44

Please sign in to comment.