Skip to content

Commit 620e952

Browse files
committed
Add unified model_config.ts to make updating default models a little easier.
1 parent cd276ba commit 620e952

File tree

9 files changed

+126
-34
lines changed

9 files changed

+126
-34
lines changed

frontend/src/components/experiment_dashboard/agent_participant_configuration_dialog.ts

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import {ExperimentManager} from '../../services/experiment.manager';
1414
import {
1515
AgentPersonaConfig,
1616
CohortConfig,
17-
ApiKeyType,
18-
AgentPersonaType,
1917
createAgentModelSettings,
2018
DEFAULT_AGENT_PARTICIPANT_ID,
19+
GEMINI_MODELS,
20+
ModelOption,
2121
} from '@deliberation-lab/utils';
2222

2323
import {styles} from './cohort_settings_dialog.scss';
@@ -38,7 +38,7 @@ export class AgentParticipantDialog extends MobxLitElement {
3838
@property() agentId = '';
3939
@property() promptContext = '';
4040
@property() agent: AgentPersonaConfig | undefined = undefined;
41-
@property() model: string = '';
41+
@property() selectedModel: ModelOption | null = null;
4242

4343
private close() {
4444
this.dispatchEvent(new CustomEvent('close'));
@@ -78,19 +78,19 @@ export class AgentParticipantDialog extends MobxLitElement {
7878
${this.renderAgentModel()} ${this.renderPromptContext()}
7979
<div class="buttons-wrapper">
8080
<pr-button
81-
?disabled=${this.model === ''}
81+
?disabled=${this.selectedModel === null}
8282
?loading=${this.isLoading}
8383
@click=${() => {
8484
this.isLoading = true;
8585
this.analyticsService.trackButtonClick(
8686
ButtonClick.AGENT_PARTICIPANT_ADD,
8787
);
88-
if (this.cohort && this.model) {
88+
if (this.cohort && this.selectedModel) {
8989
this.experimentEditor.addAgentParticipant();
9090
this.agentId = DEFAULT_AGENT_PARTICIPANT_ID;
9191
const modelSettings = createAgentModelSettings({
92-
apiType: ApiKeyType.GEMINI_API_KEY,
93-
modelName: this.model,
92+
apiType: this.selectedModel.apiType,
93+
modelName: this.selectedModel.id,
9494
});
9595
9696
this.experimentManager.createAgentParticipant(this.cohort.id, {
@@ -130,38 +130,25 @@ export class AgentParticipantDialog extends MobxLitElement {
130130
<div class="selections">
131131
<div>Model to use for this specific agent participant:</div>
132132
<div class="model-selector">
133-
${this.renderModelButton(
134-
'gemini-2.5-flash',
135-
'Gemini 2.5 Flash',
136-
ApiKeyType.GEMINI_API_KEY,
137-
)}
138-
${this.renderModelButton(
139-
'gemini-2.5-pro',
140-
'Gemini 2.5 Pro',
141-
ApiKeyType.GEMINI_API_KEY,
142-
)}
133+
${GEMINI_MODELS.map((model) => this.renderModelButton(model))}
143134
</div>
144135
</div>
145136
`;
146137
}
147138

148-
private renderModelButton(
149-
modelId: string,
150-
modelName: string,
151-
apiType: ApiKeyType,
152-
) {
153-
const updateModel = () => {
154-
this.model = modelId;
139+
private renderModelButton(model: ModelOption) {
140+
const selectModel = () => {
141+
this.selectedModel = model;
155142
};
156143

157-
const isActive = modelId == this.model;
144+
const isActive = this.selectedModel?.id === model.id;
158145
return html`
159146
<pr-button
160147
color="${isActive ? 'primary' : 'neutral'}"
161148
variant=${isActive ? 'tonal' : 'default'}
162-
@click=${updateModel}
149+
@click=${selectModel}
163150
>
164-
${modelName}
151+
${model.displayName}
165152
</pr-button>
166153
`;
167154
}

functions/src/api/claude.api.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import {
77
ModelGenerationConfig,
88
ModelResponse,
99
ModelResponseStatus,
10+
CLAUDE_DEFAULT_MODEL,
1011
} from '@deliberation-lab/utils';
1112
import {getClaudeAPIChatCompletionResponse} from './claude.api';
1213

13-
const MODEL_NAME = 'claude-haiku-4-5';
14+
const MODEL_NAME = CLAUDE_DEFAULT_MODEL;
1415
const CLAUDE_API_HOST = 'https://api.anthropic.com';
1516
const CLAUDE_API_PATH = '/v1/messages';
1617

functions/src/api/gemini.api.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import {
77
ModelResponseStatus,
88
StructuredOutputType,
99
StructuredOutputDataType,
10+
GEMINI_DEFAULT_MODEL,
1011
} from '@deliberation-lab/utils';
1112
import {getGeminiAPIResponse} from './gemini.api';
1213

13-
const MODEL_NAME = 'gemini-2.5-flash';
14+
const MODEL_NAME = GEMINI_DEFAULT_MODEL;
1415

1516
describe('Gemini API', () => {
1617
beforeEach(() => {

functions/src/api/gemini.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import {
1616
ModelResponseStatus,
1717
ModelResponse,
1818
addParsedModelResponse,
19+
GEMINI_DEFAULT_MODEL,
1920
} from '@deliberation-lab/utils';
2021

21-
const GEMINI_DEFAULT_MODEL = 'gemini-2.5-flash';
2222
const MAX_TOKENS_FINISH_REASON = 'MAX_TOKENS';
2323
const AUTHENTICATION_FAILURE_ERROR_CODE = 403;
2424
const QUOTA_ERROR_CODE = 429;

functions/src/api/ollama.api.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// eslint-disable-next-line @typescript-eslint/no-require-imports
22
import nock = require('nock');
33

4-
import {ModelGenerationConfig} from '@deliberation-lab/utils';
4+
import {
5+
ModelGenerationConfig,
6+
OLLAMA_DEFAULT_MODEL,
7+
} from '@deliberation-lab/utils';
58
import {ollamaChat} from './ollama.api';
69

7-
const MODEL_NAME = 'llama3.2';
10+
const MODEL_NAME = OLLAMA_DEFAULT_MODEL;
811
const LLM_SERVER_ENDPOINT = 'http://localhost:11434/api/chat';
912
const LLM_SERVER_HOST = 'http://localhost:11434';
1013
const LLM_SERVER_PATH = '/api/chat';

functions/src/log.utils.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import {
1818
StructuredOutputConfig,
1919
StructuredOutputType,
2020
createModelLogEntry,
21+
GEMINI_DEFAULT_MODEL,
2122
} from '@deliberation-lab/utils';
2223
import {writeModelLogEntry} from './log.utils';
2324
import {getGeminiAPIResponse} from './api/gemini.api';
2425

25-
const MODEL_NAME = 'gemini-2.5-flash';
26+
const MODEL_NAME = GEMINI_DEFAULT_MODEL;
2627

2728
const RULES = `
2829
rules_version = '2';

utils/src/agent.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
MediatorPromptConfig,
1313
ParticipantPromptConfig,
1414
} from './structured_prompt';
15+
import {GEMINI_DEFAULT_MODEL} from './model_config';
1516

1617
/** Agent types and functions. */
1718

@@ -172,7 +173,7 @@ export interface AgentParticipantTemplate {
172173
// ************************************************************************* //
173174
export const DEFAULT_AGENT_API_TYPE = ApiKeyType.GEMINI_API_KEY;
174175

175-
export const DEFAULT_AGENT_API_MODEL = 'gemini-2.5-flash';
176+
export const DEFAULT_AGENT_API_MODEL = GEMINI_DEFAULT_MODEL;
176177

177178
export const DEFAULT_AGENT_MODEL_SETTINGS: AgentModelSettings = {
178179
apiType: DEFAULT_AGENT_API_TYPE,

utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export * from './profile_sets';
5454
// TODO: Organize these files into 'agent' subdirectory
5555
export * from './agent';
5656
export * from './agent.validation';
57+
export * from './model_config';
5758
export * from './model_response';
5859
export * from './structured_output';
5960
export * from './structured_prompt';

utils/src/model_config.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* Centralized model configuration for all AI providers.
3+
* Update these defaults when new models are released.
4+
*/
5+
6+
import {ApiKeyType} from './agent';
7+
8+
// Default model names for each provider
9+
export const GEMINI_DEFAULT_MODEL = 'gemini-2.5-flash';
10+
export const OPENAI_DEFAULT_MODEL = 'gpt-5-mini-2025-08-07';
11+
export const CLAUDE_DEFAULT_MODEL = 'claude-haiku-4-5-20251001';
12+
export const OLLAMA_DEFAULT_MODEL = 'ministral-3';
13+
14+
/**
15+
* Model option for UI dropdowns and selection.
16+
*/
17+
export interface ModelOption {
18+
id: string;
19+
displayName: string;
20+
apiType: ApiKeyType;
21+
}
22+
23+
/**
24+
* Suggested Gemini models.
25+
*/
26+
export const GEMINI_MODELS: ModelOption[] = [
27+
{
28+
id: 'gemini-2.5-flash',
29+
displayName: 'Gemini 2.5 Flash',
30+
apiType: ApiKeyType.GEMINI_API_KEY,
31+
},
32+
{
33+
id: 'gemini-2.5-pro',
34+
displayName: 'Gemini 2.5 Pro',
35+
apiType: ApiKeyType.GEMINI_API_KEY,
36+
},
37+
];
38+
39+
/**
40+
* Suggested OpenAI models.
41+
*/
42+
export const OPENAI_MODELS: ModelOption[] = [
43+
{
44+
id: 'gpt-5-mini',
45+
displayName: 'GPT-5 mini',
46+
apiType: ApiKeyType.OPENAI_API_KEY,
47+
},
48+
];
49+
50+
/**
51+
* Suggested Claude models.
52+
*/
53+
export const CLAUDE_MODELS: ModelOption[] = [
54+
{
55+
id: 'claude-haiku-4-5-20251001',
56+
displayName: 'Claude Haiku 4.5',
57+
apiType: ApiKeyType.CLAUDE_API_KEY,
58+
},
59+
];
60+
61+
/**
62+
* Suggested models grouped by provider.
63+
*/
64+
export const MODEL_OPTIONS: Record<ApiKeyType, ModelOption[]> = {
65+
[ApiKeyType.GEMINI_API_KEY]: GEMINI_MODELS,
66+
[ApiKeyType.OPENAI_API_KEY]: OPENAI_MODELS,
67+
[ApiKeyType.CLAUDE_API_KEY]: CLAUDE_MODELS,
68+
[ApiKeyType.OLLAMA_CUSTOM_URL]: [], // Ollama models are user-configured
69+
};
70+
71+
/**
72+
* Get the default model name for a given API type.
73+
*/
74+
export function getDefaultModelForApiType(apiType: ApiKeyType): string {
75+
switch (apiType) {
76+
case ApiKeyType.GEMINI_API_KEY:
77+
return GEMINI_DEFAULT_MODEL;
78+
case ApiKeyType.OPENAI_API_KEY:
79+
return OPENAI_DEFAULT_MODEL;
80+
case ApiKeyType.CLAUDE_API_KEY:
81+
return CLAUDE_DEFAULT_MODEL;
82+
case ApiKeyType.OLLAMA_CUSTOM_URL:
83+
return OLLAMA_DEFAULT_MODEL;
84+
default:
85+
return GEMINI_DEFAULT_MODEL;
86+
}
87+
}
88+
89+
/**
90+
* All default models by provider, for reference.
91+
*/
92+
export const DEFAULT_MODELS = {
93+
[ApiKeyType.GEMINI_API_KEY]: GEMINI_DEFAULT_MODEL,
94+
[ApiKeyType.OPENAI_API_KEY]: OPENAI_DEFAULT_MODEL,
95+
[ApiKeyType.CLAUDE_API_KEY]: CLAUDE_DEFAULT_MODEL,
96+
[ApiKeyType.OLLAMA_CUSTOM_URL]: OLLAMA_DEFAULT_MODEL,
97+
} as const;

0 commit comments

Comments
 (0)