fix(discord): avoid bundling pi-ai runtime deps

This commit is contained in:
Tak Hoffman
2026-03-24 11:17:08 -05:00
parent 49ae71fa62
commit 3e9ff16645
4 changed files with 44 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
import type { Api, Model } from "@mariozechner/pi-ai";
import { complete, type Api, type Model } from "@mariozechner/pi-ai";
import type { OpenClawConfig } from "../config/config.js";
import { resolveAgentDir, resolveAgentEffectiveModelPrimary } from "./agent-scope.js";
import { DEFAULT_PROVIDER } from "./defaults.js";
@@ -231,3 +231,15 @@ export async function prepareSimpleCompletionModelForAgent(params: {
auth: prepared.auth,
};
}
export async function completeWithPreparedSimpleCompletionModel(params: {
model: Model<Api>;
auth: ResolvedProviderAuth;
context: Parameters<typeof complete>[1];
options?: Omit<Parameters<typeof complete>[2], "apiKey">;
}) {
return await complete(params.model, params.context, {
...params.options,
apiKey: params.auth.apiKey,
});
}