Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,9 @@ export const MODEL_LIST = {
],

groq: [
'llama3-70b-8192', // Meta Llama 3 70B (default one, no daily token limit and 14 400 reqs/day)
'llama3-8b-8192', // Meta Llama 3 8B
'llama-guard-3-8b', // Llama Guard 3 8B
'llama-3.1-8b-instant', // Llama 3.1 8B (Preview)
'llama-3.1-70b-versatile', // Llama 3.1 70B (Preview)
'gemma-7b-it', // Gemma 7B
'gemma2-9b-it' // Gemma 2 9B
'openai/gpt-oss-120b', // GPT-OSS 120B (default one)
'openai/gpt-oss-20b', // GPT-OSS 20B
'llama-guard-3-8b' // Llama Guard 3 8B
],

mistral: [
Expand Down Expand Up @@ -932,7 +928,7 @@ export const RECOMMENDED_MODELS: Record<string, string> = {
[OCO_AI_PROVIDER_ENUM.OPENAI]: 'gpt-4o-mini',
[OCO_AI_PROVIDER_ENUM.ANTHROPIC]: 'claude-sonnet-4-6',
[OCO_AI_PROVIDER_ENUM.GEMINI]: 'gemini-1.5-flash',
[OCO_AI_PROVIDER_ENUM.GROQ]: 'llama3-70b-8192',
[OCO_AI_PROVIDER_ENUM.GROQ]: 'openai/gpt-oss-120b',
[OCO_AI_PROVIDER_ENUM.MISTRAL]: 'mistral-small-latest',
[OCO_AI_PROVIDER_ENUM.DEEPSEEK]: 'deepseek-v4-flash',
[OCO_AI_PROVIDER_ENUM.OPENROUTER]: 'openai/gpt-4o-mini',
Expand Down
11 changes: 11 additions & 0 deletions src/engine/groq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@ import { OpenAiConfig, OpenAiEngine } from './openAi';

interface GroqConfig extends OpenAiConfig {}

// Groq serves OpenAI's gpt-oss models as reasoning models: their reasoning
// counts toward the completion token limit.
export const isGroqReasoningModel = (model: string): boolean =>
/^openai\/gpt-oss/.test(model);

export class GroqEngine extends OpenAiEngine {
constructor(config: GroqConfig) {
config.baseURL = 'https://api.groq.com/openai/v1';
if (
typeof config.isReasoning !== 'boolean' &&
isGroqReasoningModel(config.model)
) {
config.isReasoning = true;
}
super(config);
}
}
6 changes: 5 additions & 1 deletion src/generateCommitMessageFromGitDiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
setGlobalConfig,
getGlobalConfig,
MODEL_LIST,
OCO_AI_PROVIDER_ENUM,
RECOMMENDED_MODELS
} from './commands/config';
import { isGroqReasoningModel } from './engine/groq';
import { getMainCommitPrompt } from './prompts';
import { getEngine } from './utils/engine';
import {
Expand Down Expand Up @@ -162,7 +164,9 @@ export const generateCommitMessageByDiff = async (
const isReasoningModel =
typeof currentConfig.OCO_REASONING === 'boolean'
? currentConfig.OCO_REASONING
: /^(o[1-9]|gpt-5)/.test(currentModel);
: /^(o[1-9]|gpt-5)/.test(currentModel) ||
(provider === OCO_AI_PROVIDER_ENUM.GROQ &&
isGroqReasoningModel(currentModel));

const maxInputTokens =
currentConfig.OCO_TOKENS_MAX_INPUT ??
Expand Down
2 changes: 1 addition & 1 deletion src/utils/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export function getRecommendedModel(provider: string): string | null {
case OCO_AI_PROVIDER_ENUM.GEMINI:
return 'gemini-1.5-flash';
case OCO_AI_PROVIDER_ENUM.GROQ:
return 'llama3-70b-8192';
return 'openai/gpt-oss-120b';
case OCO_AI_PROVIDER_ENUM.MISTRAL:
return 'mistral-small-latest';
case OCO_AI_PROVIDER_ENUM.DEEPSEEK:
Expand Down
28 changes: 28 additions & 0 deletions test/unit/openAi.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { OpenAI } from 'openai';
import { getConfig } from '../../src/commands/config';
import { GroqEngine } from '../../src/engine/groq';
import { OpenAiEngine } from '../../src/engine/openAi';
import { getEngine } from '../../src/utils/engine';
import { prepareFile } from './utils';
Expand Down Expand Up @@ -136,6 +137,33 @@ describe('OpenAiEngine', () => {
);
});

it('uses max_completion_tokens for Groq gpt-oss reasoning models', async () => {
const engine = new GroqEngine({
...baseConfig,
model: 'openai/gpt-oss-120b'
});

const create = jest
.spyOn(engine.client.chat.completions, 'create')
.mockResolvedValue({
choices: [{ message: { content: 'feat(groq): reasoning path' } }]
} as any);

await engine.generateCommitMessage(messages);

expect(create).toHaveBeenCalledWith(
expect.objectContaining({
model: 'openai/gpt-oss-120b',
max_completion_tokens: 1024
})
);
expect(create).toHaveBeenCalledWith(
expect.not.objectContaining({
max_tokens: expect.anything()
})
);
});

it('auto-detects a reasoning model through the real default config and engine path', async () => {
const envFile = await prepareFile('.env', '');

Expand Down
Loading