Skip to content

Commit

Permalink
fix system message for openai model
Browse files Browse the repository at this point in the history
  • Loading branch information
fegloff committed May 30, 2024
1 parent 64cfa38 commit 48b53cf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/modules/llms/api/athropic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const anthropicStreamCompletion = async (
stream: true,
system: config.openAi.chatGpt.chatCompletionContext,
max_tokens: limitTokens ? +config.openAi.chatGpt.maxTokens : undefined,
messages: conversation.filter(c => c.model === model) // .map(m => { return { content: m.content, role: m.role } })
messages: conversation.filter(c => c.model === model && c.role !== 'system') // .map(m => { return { content: m.content, role: m.role } })
}
let wordCount = 0
let wordCountMinimum = 2
Expand Down Expand Up @@ -166,7 +166,7 @@ export const toolsChatCompletion = async (
stream: false,
system: config.openAi.chatGpt.chatCompletionContext,
max_tokens: +config.openAi.chatGpt.maxTokens,
messages: conversation.filter(c => c.model === model)
messages: conversation.filter(c => c.model === model && c.role !== 'system')
.map(m => { return { content: m.content, role: m.role } })
}
const url = `${API_ENDPOINT}/anthropic/completions/tools`
Expand Down
2 changes: 1 addition & 1 deletion src/modules/llms/api/vertex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const vertexStreamCompletion = async (
stream: true, // Set stream to true to receive the completion as a stream
system: config.openAi.chatGpt.chatCompletionContext,
max_tokens: limitTokens ? +config.openAi.chatGpt.maxTokens : undefined,
messages: conversation.filter(c => c.model === model)
messages: conversation.filter(c => c.model === model && c.role !== 'system')
// .map(m => { return { parts: { text: m.content }, role: m.role !== 'user' ? 'model' : 'user' } })
}
const url = `${API_ENDPOINT}/llms/completions` // `${API_ENDPOINT}/vertex/completions/gemini`
Expand Down
3 changes: 2 additions & 1 deletion src/modules/llms/llmsBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ export abstract class LlmsBase implements PayableBot {
if (chatConversation.length === 0) {
chatConversation.push({
role: 'system',
content: config.openAi.chatGpt.chatCompletionContext
content: config.openAi.chatGpt.chatCompletionContext,
model
})
}
// const hasCode = hasCodeSnippet(ctx)
Expand Down

0 comments on commit 48b53cf

Please sign in to comment.