mirror of
https://github.com/luckyyzh/pi-agent-integrated.git
synced 2026-10-03 02:59:35 +00:00
feat: integrate Pi backend and Pi Web
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { ModelRuntime } from "@earendil-works/pi-coding-agent";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET() {
|
||||
const modelRuntime = await ModelRuntime.create();
|
||||
const credentials = await modelRuntime.listCredentials();
|
||||
const loggedInProviders = new Set(
|
||||
credentials.filter((credential) => credential.type === "oauth").map((credential) => credential.providerId),
|
||||
);
|
||||
const providers = modelRuntime.getProviders().filter((provider) => provider.auth.oauth);
|
||||
|
||||
const EXCLUDED = new Set(["anthropic"]);
|
||||
const DISPLAY_NAMES: Record<string, string> = {
|
||||
"openai-codex": "ChatGPT Plus/Pro",
|
||||
"github-copilot": "GitHub Copilot",
|
||||
};
|
||||
|
||||
const result = await Promise.all(
|
||||
providers
|
||||
.filter((p) => !EXCLUDED.has(p.id))
|
||||
.map(async (p) => {
|
||||
return {
|
||||
id: p.id,
|
||||
name: DISPLAY_NAMES[p.id] ?? p.name,
|
||||
usesCallbackServer: false,
|
||||
loggedIn: loggedInProviders.has(p.id),
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return Response.json({ providers: result });
|
||||
}
|
||||
Reference in New Issue
Block a user