mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
Add testPipelineCall networking function
This commit is contained in:
parent
1faa4734a9
commit
0bbf4fa58c
1 changed files with 31 additions and 0 deletions
|
|
@ -5673,6 +5673,37 @@ export const deletePolicyAttachmentCall = async (accessToken: string, attachment
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const testPipelineCall = async (
|
||||||
|
accessToken: string,
|
||||||
|
pipeline: any,
|
||||||
|
testMessages: Array<{role: string, content: string}>
|
||||||
|
) => {
|
||||||
|
try {
|
||||||
|
const url = proxyBaseUrl ? `${proxyBaseUrl}/policies/test-pipeline` : `/policies/test-pipeline`;
|
||||||
|
const response = await fetch(url, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
[globalLitellmHeaderName]: `Bearer ${accessToken}`,
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ pipeline, test_messages: testMessages }),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorData = await response.json();
|
||||||
|
const errorMessage = deriveErrorMessage(errorData);
|
||||||
|
handleError(errorMessage);
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to test pipeline:", error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const getResolvedGuardrails = async (accessToken: string, policyId: string) => {
|
export const getResolvedGuardrails = async (accessToken: string, policyId: string) => {
|
||||||
try {
|
try {
|
||||||
const url = proxyBaseUrl
|
const url = proxyBaseUrl
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue