Skip to content

Commit 90e7318

Browse files
committed
1 parent 365247b commit 90e7318

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

adminforth/documentation/docs/tutorial/05-ListOfAdapters.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,45 @@ new CompletionAdapterGoogleGemini({
211211
}),
212212
```
213213

214+
### Using json_schema with adapter
215+
216+
If you want use custom json schema for completion response - you can use outputSchema param for completion:
217+
218+
219+
```ts
220+
const openAi = new CompletionAdapterOpenAIChatGPT({
221+
openAiApiKey: process.env.OPENAI_API_KEY as string,
222+
model: 'gpt-5-mini',
223+
});
224+
225+
const prompt = 'What is the capital of France? return json';
226+
227+
openAi.complete(
228+
prompt,
229+
[],
230+
200,
231+
{
232+
json_schema: {
233+
name: "capital_response",
234+
schema: {
235+
type: "object",
236+
properties: {
237+
capital: { type: "string" },
238+
},
239+
required: ["capital"],
240+
},
241+
},
242+
},
243+
).then((resp) => {
244+
console.log(resp);
245+
});
246+
247+
```
248+
249+
Then output will be like:
250+
```
251+
{ content: '{"capital":"Paris"}', finishReason: 'stop' }
252+
```
214253

215254
## 🔎 Image Analysis
216255

0 commit comments

Comments
 (0)