Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ahejlsberg committed Dec 12, 2023
1 parent ef74a9b commit 9ebcc27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function createOpenAILanguageModel(apiKey: string, model: string, endPoin
* @param apiKey The Azure OpenAI API key.
* @returns An instance of `TypeChatLanguageModel`.
*/
export function createAzureOpenAILanguageModel(apiKey: string, endPoint: string,): TypeChatLanguageModel {
export function createAzureOpenAILanguageModel(apiKey: string, endPoint: string): TypeChatLanguageModel {
const headers = {
// Needed when using managed identity
"Authorization": `Bearer ${apiKey}`,
Expand All @@ -107,7 +107,7 @@ export function createAzureOpenAILanguageModel(apiKey: string, endPoint: string,
/**
* Common OpenAI REST API endpoint encapsulation using the fetch API.
*/
function createFetchLanguageModel(url: string, headers: object, defaultParams: Record<string, string>) {
function createFetchLanguageModel(url: string, headers: object, defaultParams: object) {
const model: TypeChatLanguageModel = {
complete
};
Expand All @@ -134,8 +134,8 @@ function createFetchLanguageModel(url: string, headers: object, defaultParams: R
}
const response = await fetch(url, options);
if (response.ok) {
const json = await response.json() as any;
return success(json.choices[0].message?.content ?? "");
const json = await response.json() as { choices: { message: PromptSection }[] };
return success(json.choices[0].message.content ?? "");
}
if (!isTransientHttpError(response.status) || retryCount >= retryMaxAttempts) {
return error(`REST API error ${response.status}: ${response.statusText}`);
Expand Down

0 comments on commit 9ebcc27

Please sign in to comment.