Skip to content

Commit

Permalink
feat(structured outputs): support accessing raw responses (#1058)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertCraigie authored Sep 11, 2024
1 parent f9b7eac commit af17697
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/resources/beta/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ export interface ParsedChatCompletion<ParsedT> extends ChatCompletion {
export type ChatCompletionParseParams = ChatCompletionCreateParamsNonStreaming;

export class Completions extends APIResource {
async parse<Params extends ChatCompletionParseParams, ParsedT = ExtractParsedContentFromParams<Params>>(
parse<Params extends ChatCompletionParseParams, ParsedT = ExtractParsedContentFromParams<Params>>(
body: Params,
options?: Core.RequestOptions,
): Promise<ParsedChatCompletion<ParsedT>> {
): Core.APIPromise<ParsedChatCompletion<ParsedT>> {
validateInputTools(body.tools);

const completion = await this._client.chat.completions.create(body, {
...options,
headers: {
...options?.headers,
'X-Stainless-Helper-Method': 'beta.chat.completions.parse',
},
});

return parseChatCompletion(completion, body);
return this._client.chat.completions
.create(body, {
...options,
headers: {
...options?.headers,
'X-Stainless-Helper-Method': 'beta.chat.completions.parse',
},
})
._thenUnwrap((completion) => parseChatCompletion(completion, body));
}

/**
Expand Down

0 comments on commit af17697

Please sign in to comment.