fix(ai-public): hide public pool endpoint from users
This commit is contained in:
@@ -51,7 +51,6 @@ export type ListAiBindingsResponse = {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
providerName: string | null;
|
providerName: string | null;
|
||||||
model: string | null;
|
model: string | null;
|
||||||
endpoint: string | null;
|
|
||||||
hasApiKey: boolean;
|
hasApiKey: boolean;
|
||||||
} | null;
|
} | null;
|
||||||
};
|
};
|
||||||
@@ -122,7 +121,6 @@ export class AiService {
|
|||||||
enabled: publicPool.enabled,
|
enabled: publicPool.enabled,
|
||||||
providerName: publicPool.providerName,
|
providerName: publicPool.providerName,
|
||||||
model: publicPool.model,
|
model: publicPool.model,
|
||||||
endpoint: publicPool.endpoint,
|
|
||||||
hasApiKey: Boolean(publicPool.encryptedApiKey)
|
hasApiKey: Boolean(publicPool.encryptedApiKey)
|
||||||
}
|
}
|
||||||
: null
|
: null
|
||||||
|
|||||||
@@ -468,6 +468,30 @@ describe("AiController (integration)", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should hide public pool endpoint from user bindings response", async () => {
|
||||||
|
prismaService.seedPublicPool({
|
||||||
|
enabled: true,
|
||||||
|
providerName: "public-openai",
|
||||||
|
model: "gpt-4o-mini",
|
||||||
|
encryptedApiKey: "sk-public",
|
||||||
|
endpoint: "https://internal.example.com/v1",
|
||||||
|
rpmLimit: 60,
|
||||||
|
dailyTokenLimit: 100000
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await request(app.getHttpServer())
|
||||||
|
.get("/ai/bindings")
|
||||||
|
.set("x-user-id", "user_1")
|
||||||
|
.expect(200);
|
||||||
|
|
||||||
|
expect(response.body.publicPool).toEqual({
|
||||||
|
enabled: true,
|
||||||
|
providerName: "public-openai",
|
||||||
|
model: "gpt-4o-mini",
|
||||||
|
hasApiKey: true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it("should upsert one binding per user channel", async () => {
|
it("should upsert one binding per user channel", async () => {
|
||||||
await request(app.getHttpServer())
|
await request(app.getHttpServer())
|
||||||
.post("/ai/bindings")
|
.post("/ai/bindings")
|
||||||
|
|||||||
@@ -450,12 +450,6 @@ export function SettingsPage({ session }: SettingsPageProps) {
|
|||||||
{bindingsResponse?.publicPool?.model || "未设置"}
|
{bindingsResponse?.publicPool?.model || "未设置"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
接口地址:
|
|
||||||
<span className="ml-2 break-all text-foreground">
|
|
||||||
{bindingsResponse?.publicPool?.endpoint || "未设置"}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ export type WebAiBindingsResponse = {
|
|||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
providerName: string | null;
|
providerName: string | null;
|
||||||
model: string | null;
|
model: string | null;
|
||||||
endpoint: string | null;
|
|
||||||
hasApiKey: boolean;
|
hasApiKey: boolean;
|
||||||
} | null;
|
} | null;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user