Skip to content

Commit

Permalink
chore: add maxResponseTokenLength config
Browse files Browse the repository at this point in the history
  • Loading branch information
josStorer committed Mar 11, 2023
1 parent 52db82a commit 57e2d82
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/background/apis/openai-api.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// api version

import { Models } from '../../config'
import { maxResponseTokenLength, Models } from '../../config'
import { fetchSSE, getConversationPairs } from '../../utils'
import { isEmpty } from 'lodash-es'

Expand Down Expand Up @@ -52,7 +52,7 @@ export async function generateAnswersWithGptCompletionApi(
prompt: prompt,
model: Models[modelName].value,
stream: true,
max_tokens: 1000,
max_tokens: maxResponseTokenLength,
}),
onMessage(message) {
console.debug('sse message', message)
Expand Down Expand Up @@ -102,8 +102,6 @@ export async function generateAnswersWithChatgptApi(port, question, session, api
prompt.unshift({ role: 'system', content: chatgptPromptBase })
prompt.push({ role: 'user', content: question })

console.debug('dsdsd', prompt)

let answer = ''
await fetchSSE('https://api.openai.com/v1/chat/completions', {
method: 'POST',
Expand All @@ -116,7 +114,7 @@ export async function generateAnswersWithChatgptApi(port, question, session, api
messages: prompt,
model: Models[modelName].value,
stream: true,
max_tokens: 1000,
max_tokens: maxResponseTokenLength,
}),
onMessage(message) {
console.debug('sse message', message)
Expand Down
2 changes: 2 additions & 0 deletions src/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export const ThemeMode = {
auto: 'Auto',
}

export const maxResponseTokenLength = 1000

/**
* @typedef {typeof defaultConfig} UserConfig
*/
Expand Down

0 comments on commit 57e2d82

Please sign in to comment.