Skip to content

Commit 9364ebd

Browse files
committed
Switch gpt-4.1 to gpt-5, azure deployment names are now same as model name
1 parent 002fdce commit 9364ebd

File tree

8 files changed

+41
-26
lines changed

8 files changed

+41
-26
lines changed

.env.template

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
API_TOKEN=<API_TOKEN>
1+
# Toska
2+
API_TOKEN=
23

3-
AZURE_API_KEY=<AZURE_API_KEY>
4-
AZURE_RESOURCE=<AZURE_RESOURCE>
4+
# Azure
5+
AZURE_API_KEY=
6+
AZURE_RESOURCE=
57

6-
GPT_4O=<deployment-4o>
7-
GPT_4O_MINI=<deployment-4o-mini>
8-
GPT_41=<deployment-4.1>
8+
AZURE_OPENAI_EMBEDDER_MODEL=
9+
AZURE_OPENAI_EMBEDDER_DEPLOYMENT=
10+
11+
# Encryption
12+
ENCRYPTION_KEY=
13+
ENCRYPTION_IV=
14+
15+
# Laama
16+
LAAMA_API_TOKEN=
17+
LAAMA_API_URL=
18+
19+
OLLAMA_EMBEDDER_MODEL=
20+
21+
# S3
22+
S3_HOST=
23+
S3_ACCESS_KEY=
24+
S3_SECRET_ACCESS_KEY=
25+
S3_BUCKET=

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ See `compose.yaml` for local development. In short, in addition to the CC server
3131

3232
Azure is used for OpenAI LLMs.
3333

34-
Create an AI foundry resource (or something) and create deployment for the models you want to use (gpt4.1 for example).
34+
Create an AI foundry resource (or something) and create deployment for the models you want to use (gpt-5 for example). Always set the deployment name to the acual model name. So for model gpt-5, the deployment name should be gpt-5.
3535

3636
Then populate .env with the following:
3737
```
3838
AZURE_RESOURCE=<name-of-the-resource-you-created>
3939
AZURE_API_KEY=<asd>
40-
GPT_41=<name-of-the-deployment-you-created>
4140
```
4241

4342
### S3

src/client/components/ChatV2/ChatV2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ export const ChatV2 = () => {
268268
setActiveModel(defaultCourseModel ?? courseModels[0])
269269
}
270270
} else {
271-
allowedModels = validModels.map((m) => m.name) // [gpt-4.1, gpt-4o, gpt-4o-mini, mock] 23.7.2025
271+
allowedModels = validModels.map((m) => m.name) // [gpt-5, gpt-4o, gpt-4o-mini, mock] 23.7.2025
272272
}
273273

274274
// Mock model is only visible to admins in production

src/config.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,29 @@ export const DEFAULT_RESET_CRON = process.env.DEFAULT_RESET_CRON || '0 0 1 */3 *
2020

2121
export const EMBED_MODEL = process.env.EMBED_MODEL ?? 'text-embedding-small'
2222

23+
/**
24+
* name: the acual model name, which is shown to users, configures the model to be used and is also the azure deployment name.
25+
*/
2326
export const validModels = [
2427
{
2528
name: 'gpt-4o',
26-
deployment: process.env.GPT_4O || '',
2729
context: 128_000,
2830
},
2931
{
3032
name: 'gpt-4o-mini',
31-
deployment: process.env.GPT_4O_MINI || '',
3233
context: 128_000,
3334
},
3435
{
35-
name: 'gpt-4.1',
36-
deployment: process.env.GPT_41 || '',
36+
name: 'gpt-5',
3737
context: 128_000,
3838
},
3939
{
4040
name: 'mock',
41-
deployment: 'mock',
4241
context: 128_000,
4342
},
4443
]
4544

46-
export const DEFAULT_MODEL_ON_ENABLE = 'gpt-4.1'
45+
export const DEFAULT_MODEL_ON_ENABLE = 'gpt-5'
4746

4847
export const DEFAULT_ASSISTANT_INSTRUCTIONS = '' // 11th August 2025 we decided it should be empty
4948
export const DEFAULT_MODEL_TEMPERATURE = 0.5

src/server/routes/testUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ router.post('/completions-api', async (req, res) => {
120120
content: 'Hello!, please explain the concept of artificial intelligence.',
121121
},
122122
],
123-
model: 'gpt-4.1',
123+
model: 'gpt-5',
124124
options: {
125125
temperature: 0.9,
126126
},

src/server/services/langchain/chat.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ import { MockModel } from './MockModel'
1717
type ChatModel = Runnable<BaseLanguageModelInput, AIMessageChunk, BaseChatModelCallOptions>
1818

1919
const getChatModel = (model: string, tools: StructuredTool[], temperature: number): ChatModel => {
20-
const deploymentName = validModels.find((m) => m.name === model)?.deployment
21-
if (!deploymentName) {
20+
const modelConfig = validModels.find((m) => m.name === model)
21+
if (!modelConfig) {
2222
throw new Error(`Invalid model: ${model}`)
2323
}
2424

2525
const chatModel =
26-
deploymentName === 'mock'
26+
modelConfig.name === 'mock'
2727
? new MockModel({ tools, temperature })
2828
: new AzureChatOpenAI({
2929
model,
3030
azureOpenAIApiKey: AZURE_API_KEY,
3131
azureOpenAIApiVersion: '2023-05-15',
32-
azureOpenAIApiDeploymentName: deploymentName,
32+
azureOpenAIApiDeploymentName: model, // In Azure, always use the acual model name as the deployment name
3333
azureOpenAIApiInstanceName: AZURE_RESOURCE,
3434
temperature,
3535
}).bindTools(tools)

src/server/util/oldAzureClient.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ const getMockCompletionEvents: () => Promise<EventStream<ChatCompletions>> = asy
4444
}
4545

4646
export const getCompletionEvents = async ({ model, messages, options }: AzureOptions) => {
47-
const deploymentId = validModels.find((m) => m.name === model)?.deployment
47+
const modelConfig = validModels.find((m) => m.name === model)
4848

49-
if (!deploymentId) throw new Error(`Invalid model: ${model}, not one of ${validModels.map((m) => m.name).join(', ')}`)
49+
if (!modelConfig) throw new Error(`Invalid model: ${model}, not one of ${validModels.map((m) => m.name).join(', ')}`)
5050

51-
if (deploymentId === 'mock') return getMockCompletionEvents()
51+
if (modelConfig.name === 'mock') return getMockCompletionEvents()
5252

5353
try {
54-
const events = await oldClient.streamChatCompletions(deploymentId, messages, options)
54+
const events = await oldClient.streamChatCompletions(modelConfig.name, messages, options)
5555

5656
return events
5757
} catch (error: any) {

src/server/util/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ export const getAllowedModels = (model: string): string[] => {
2222

2323
// Logic: allowed models are selected by the pricing of the model
2424
// gpt-4o is the most expensive, so it is allowed for all
25-
// gpt-4.1 is cheaper, so all models cheaper than it are allowed
25+
// gpt-5 is cheaper, so all models cheaper than it are allowed
2626
// pricings: https://azure.microsoft.com/en-us/pricing/details/cognitive-services/openai-service/?cdn=disable
2727

2828
if (model === 'gpt-4o') return allModels
2929

30-
if (model === 'gpt-4.1') return ['gpt-4.1', 'gpt-4o-mini']
30+
if (model === 'gpt-5') return ['gpt-5', 'gpt-4o-mini']
3131

3232
if (model === 'mock') return ['mock']
3333

0 commit comments

Comments
 (0)