mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-31 04:12:10 +03:00
Update Pollinations request transformation to send the selected model and stream flag so requests match the active endpoint behavior. Align the ChatGPT TLS client with shared proxy resolution so dashboard proxy context is honored before falling back to environment settings. Also refresh provider display names across dashboard pages, correct the Claude extra-usage toggle messaging and visual state, and mark Pollinations as offering a free public endpoint.
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { BaseExecutor } from "./base.ts";
|
|
import { PROVIDERS } from "../config/constants.ts";
|
|
|
|
/**
|
|
* PollinationsExecutor — OpenAI-compatible Pollinations text endpoint.
|
|
*
|
|
* Pollinations currently exposes a public endpoint and an optional key-backed tier.
|
|
* OmniRoute sends the bearer token when configured, but no auth header is required
|
|
* for the anonymous endpoint.
|
|
*
|
|
* Endpoint: https://text.pollinations.ai/openai/chat/completions
|
|
* Docs: https://pollinations.ai/docs
|
|
*/
|
|
export class PollinationsExecutor extends BaseExecutor {
|
|
constructor() {
|
|
super("pollinations", PROVIDERS["pollinations"] || { format: "openai" });
|
|
}
|
|
|
|
buildUrl(_model: string, _stream: boolean, urlIndex = 0, _credentials = null): string {
|
|
const baseUrls = this.getBaseUrls();
|
|
return (
|
|
baseUrls[urlIndex] || baseUrls[0] || "https://text.pollinations.ai/openai/chat/completions"
|
|
);
|
|
}
|
|
|
|
buildHeaders(credentials: any, stream = true): Record<string, string> {
|
|
const key = credentials?.apiKey || credentials?.accessToken;
|
|
|
|
const headers: Record<string, string> = {
|
|
"Content-Type": "application/json",
|
|
};
|
|
|
|
if (key) {
|
|
headers.Authorization = `Bearer ${key}`;
|
|
}
|
|
|
|
if (stream) {
|
|
headers["Accept"] = "text/event-stream";
|
|
}
|
|
|
|
return headers;
|
|
}
|
|
|
|
transformRequest(model: string, body: any, stream: boolean, _credentials: any): any {
|
|
if (typeof body === "object" && body !== null) {
|
|
body.model = model;
|
|
body.stream = stream;
|
|
body.jsonMode = true;
|
|
}
|
|
return body;
|
|
}
|
|
}
|
|
|
|
export default PollinationsExecutor;
|