Skip to content

Commit

Permalink
chore: use gpt-4o-mini for title generation by default
Browse files Browse the repository at this point in the history
feat: support more customizable parameters
  • Loading branch information
CNSeniorious000 committed Aug 13, 2024
1 parent 5bd1ba4 commit c9a1575
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/pages/api/title-gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ You should respond in valid JSON format, with a single string field \`title\`.
The title should be in Chinese if you think the user is Chinese.
`.trim()

const model = import.meta.env.TITLE_GEN_MODEL ?? import.meta.env.OPENAI_API_MODEL ?? 'gpt-4o-mini'

export const POST: APIRoute = async(context) => {
const content = await context.request.text()

Expand All @@ -27,7 +29,7 @@ export const POST: APIRoute = async(context) => {
{ role: 'system', content: systemPrompt },
{ role: 'user', content: `"""\n${content}\n"""` },
],
model: 'gpt-3.5-turbo-0125',
model,
temperature: 0,
response_format: { type: 'json_object' },
stream: true,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { OpenAI } from 'openai'
import { openaiBaseUrl } from './constants'
export const openai = new OpenAI({ apiKey: import.meta.env.OPENAI_API_KEY ?? '', baseURL: `${openaiBaseUrl}/v1`, timeout: 10000, maxRetries: 5 })
export const openai = new OpenAI({ apiKey: import.meta.env.OPENAI_API_KEY ?? '', baseURL: openaiBaseUrl, timeout: 10000, maxRetries: 5 })
2 changes: 1 addition & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const openaiBaseUrl = (import.meta.env.OPENAI_API_BASE_URL || 'https://api.openai.com').trim().replace(/\/$/, '')
export const openaiBaseUrl = (import.meta.env.OPENAI_BASE_URL ?? `${(import.meta.env.OPENAI_API_BASE_URL ?? 'https://api.openai.com').trim().replace(/\/$/, '')}/v1`).trim().replace(/\/$/, '')
export const promplateBaseUrl = import.meta.env.PUBLIC_PROMPLATE_DEMO_BASE_URL.replace(/\/$/, '')

1 comment on commit c9a1575

@vercel
Copy link

@vercel vercel bot commented on c9a1575 Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.