33 lines
903 B
TypeScript
33 lines
903 B
TypeScript
import { buildHermesRequest, normalizeProviderResponse } from "./shared.js";
|
|
import type { ProviderAdapter } from "./types.js";
|
|
|
|
export const llamaProvider: ProviderAdapter = {
|
|
name: "llama",
|
|
capabilities: {
|
|
jsonMode: false,
|
|
promptCache: false,
|
|
toolCalls: "hermes",
|
|
},
|
|
createHealthUrl(endpoint: string): string {
|
|
try {
|
|
const url = new URL(endpoint);
|
|
url.pathname = "/health";
|
|
url.search = "";
|
|
url.hash = "";
|
|
return url.toString();
|
|
} catch {
|
|
if (endpoint.includes("/v1/chat/completions")) {
|
|
return `${endpoint.split("/v1/chat/completions")[0]}/health`;
|
|
}
|
|
return `${endpoint.replace(/\/+$/u, "")}/health`;
|
|
}
|
|
},
|
|
prepareRequest(input) {
|
|
return buildHermesRequest(input);
|
|
},
|
|
supportsHealthCheck: true,
|
|
toResult(payload, endpoint) {
|
|
return normalizeProviderResponse(payload, endpoint, "llama");
|
|
},
|
|
};
|