MCPcopy Index your code
hub / github.com/OpenPipe/OpenPipe / getAzureGpt4Completion

Function getAzureGpt4Completion

app/src/server/utils/openai.ts:70–93  ·  view source on GitHub ↗
(input: ChatCompletionCreateParams)

Source from the content-addressed store, hash-verified

68
69// Fall back to our own Azure instance for long-running requests
70export async function getAzureGpt4Completion(input: ChatCompletionCreateParams) {
71 const models = ["gpt-4", "gpt-4-turbo", "gpt-4-32k"] as const;
72 let lastError;
73 for (const model of models) {
74 const client = getEndpointForModel(model).client;
75
76 try {
77 return client.chat.completions.create({
78 ...input,
79 model,
80 stream: false,
81 });
82 } catch (error) {
83 if (error instanceof APIError && error.status === 429) {
84 // store error to throw if all models fail
85 lastError = error;
86 continue;
87 }
88 console.log("ERROR:", error);
89 throw error;
90 }
91 }
92 throw lastError;
93}
94
95const azureGpt4Endpoints: readonly {
96 apiBase: string;

Callers 1

getCompletionFunction · 0.90

Calls 2

getEndpointForModelFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected