Skip to content

Commit c5e32c6

Browse files
committed
fix: add generate example in gen.yaml
1 parent eaf7cd4 commit c5e32c6

6 files changed

Lines changed: 34 additions & 18 deletions

File tree

.github/workflows/run_example_scripts.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ jobs:
2323
- name: Install dependencies
2424
run: npm install && npm install --prefix examples && npm install tsx
2525

26-
- name: Build the project
27-
run: npm run build
28-
2926
- name: Run the example script
30-
run: ./scripts/run_examples.sh
27+
run: |
28+
cd examples && npm run test
3129
env:
3230
MISTRAL_API_KEY: ${{ secrets.MISTRAL_API_KEY }}

.speakeasy/gen.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ typescript:
3535
envVarPrefix: MISTRAL
3636
flattenGlobalSecurity: true
3737
flatteningOrder: body-first
38+
generateExamples: true
3839
imports:
3940
option: openapi
4041
paths:

examples/package-lock.json

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"gcp": "npm run script -- ./src/gcp/async_chat_no_streaming.ts",
1111
"azure": "npm run script -- ./src/azure/async_chat_no_streaming.ts",
1212
"format": "prettier --write .",
13-
"test": "tsx ./test.ts"
13+
"test": "tsx ./test.ts",
14+
"build:examples": "echo 'skipping build examples'"
1415
},
1516
"keywords": [],
1617
"author": "",
@@ -22,9 +23,10 @@
2223
"yargs": "^17.0.0"
2324
},
2425
"devDependencies": {
25-
"glob": "^11.0.0",
2626
"@types/node": "^20.11.4",
27+
"glob": "^11.0.0",
2728
"prettier": "3.3.3",
28-
"tsx": "^4.7.0"
29+
"tsx": "^4.7.0",
30+
"typescript": "^5.9.2"
2931
}
30-
}
32+
}

examples/src/async_audio_transcription_stream.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ import { Mistral } from "@mistralai/mistralai";
22

33
const apiKey = process.env["MISTRAL_API_KEY"];
44
if (!apiKey) {
5-
throw new Error("missing MISTRAL_API_KEY environment variable");
5+
throw new Error("missing MISTRAL_API_KEY environment variable");
66
}
77

88
const mistral = new Mistral({ apiKey: apiKey });
99

1010
const stream = await mistral.audio.transcriptions.stream({
11-
model: "voxtral-mini-latest",
12-
fileUrl: "https://docs.mistral.ai/audio/bcn_weather.mp3",
11+
model: "voxtral-mini-latest",
12+
fileUrl: "https://docs.mistral.ai/audio/bcn_weather.mp3",
1313
});
1414

1515
for await (const event of stream) {
16-
process.stdout.write(JSON.stringify(event));
17-
process.stdout.write("\n");
16+
process.stdout.write(JSON.stringify(event));
17+
process.stdout.write("\n");
1818
}

examples/src/async_chat_prediction.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ const chatResponse = await client.chat.complete({
2222
model: "codestral-latest",
2323
messages: [
2424
{ role: "user", content: refactorPrompt },
25-
{ role: "user", content: code }
25+
{ role: "user", content: code },
2626
],
2727
prediction: {
2828
type: "content",
29-
content: code
30-
}
29+
content: code,
30+
},
3131
});
3232

33-
console.log(chatResponse.choices[0].message.content);
33+
console.log(chatResponse.choices[0]?.message.content);

0 commit comments

Comments
 (0)