mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(coding-agent): route managed llama.cpp classify requests after auth resolution
Auth resolution replaces the classifier baseUrl with the /v1 inference placeholder, so classify skipped the managed server and requests failed against managed.llama.invalid.
This commit is contained in:
parent
bd7e1ba0f1
commit
ea1b18c711
2 changed files with 21 additions and 1 deletions
|
|
@ -363,7 +363,10 @@ export function createLlamaProvider(managed: ManagedLlama = createManagedLlama()
|
|||
streamSimple(requestModel, context, requestOptions),
|
||||
),
|
||||
classify: async (model, context, options) => {
|
||||
if (model.baseUrl !== MANAGED_LLAMA_SERVER_URL) return classifier.classify(model, context, options);
|
||||
// Auth resolution replaces the catalog URL with the inference URL (`/v1`), so accept both placeholder forms.
|
||||
if (model.baseUrl !== MANAGED_LLAMA_SERVER_URL && model.baseUrl !== MANAGED_INFERENCE_URL) {
|
||||
return classifier.classify(model, context, options);
|
||||
}
|
||||
let server: ManagedLlamaServerInfo;
|
||||
try {
|
||||
server = await managed.acquire(options?.signal);
|
||||
|
|
|
|||
|
|
@ -345,6 +345,23 @@ describe("managed llama.cpp provider", () => {
|
|||
expect(calls).toEqual(["probe", "acquire", "acquire"]);
|
||||
expect(requests.at(-1)?.authorization).toBe("Bearer secret");
|
||||
expect(requests.at(-1)?.url.startsWith("/v1")).toBe(false);
|
||||
|
||||
// The model runtime applies the auth baseUrl (the `/v1` inference placeholder) before classifying.
|
||||
const resolvedClassification = await provider.classify!(
|
||||
{
|
||||
...(classifierModel as ClassifierModel<"llama-cpp-classify">),
|
||||
baseUrl: `${MANAGED_LLAMA_SERVER_URL}/v1`,
|
||||
},
|
||||
{
|
||||
state: {},
|
||||
questions: { ok: { type: "bool", instructions: "ok?", criteria: { true: "yes", false: "no" } } },
|
||||
},
|
||||
{ apiKey: "managed" },
|
||||
);
|
||||
expect(resolvedClassification.stopReason).toBe("error");
|
||||
expect(calls).toEqual(["probe", "acquire", "acquire", "acquire"]);
|
||||
expect(requests.at(-1)?.authorization).toBe("Bearer secret");
|
||||
expect(requests.at(-1)?.url.startsWith("/v1")).toBe(false);
|
||||
});
|
||||
|
||||
it("reports a managed server that cannot start as a classifier error", async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue