mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
Feat : tts
This commit is contained in:
@@ -109,7 +109,7 @@ export async function GET() {
|
||||
// POST - Update 9Router settings (merge with existing config)
|
||||
export async function POST(request) {
|
||||
try {
|
||||
const { baseUrl, apiKey, model } = await request.json();
|
||||
const { baseUrl, apiKey, model, subagentModel } = await request.json();
|
||||
|
||||
if (!baseUrl || !apiKey || !model) {
|
||||
return NextResponse.json({ error: "baseUrl, apiKey and model are required" }, { status: 400 });
|
||||
@@ -141,6 +141,12 @@ export async function POST(request) {
|
||||
wire_api: "responses",
|
||||
});
|
||||
|
||||
// Add subagent configuration
|
||||
const effectiveSubagentModel = subagentModel || model;
|
||||
setNestedSection(parsed, "agents.subagent", {
|
||||
model: effectiveSubagentModel,
|
||||
});
|
||||
|
||||
// Write merged config
|
||||
const configContent = stringifyTOML(parsed);
|
||||
await fs.writeFile(configPath, configContent);
|
||||
@@ -196,6 +202,9 @@ export async function DELETE() {
|
||||
// Remove 9router provider section
|
||||
deleteNestedSection(parsed, "model_providers.9router");
|
||||
|
||||
// Remove subagent configuration
|
||||
deleteNestedSection(parsed, "agents.subagent");
|
||||
|
||||
// Write updated config
|
||||
const configContent = stringifyTOML(parsed);
|
||||
await fs.writeFile(configPath, configContent);
|
||||
|
||||
@@ -77,7 +77,7 @@ export async function GET() {
|
||||
// POST - Apply 9Router as openai-compatible provider
|
||||
export async function POST(request) {
|
||||
try {
|
||||
const { baseUrl, apiKey, model } = await request.json();
|
||||
const { baseUrl, apiKey, model, subagentModel } = await request.json();
|
||||
|
||||
if (!baseUrl || !model) {
|
||||
return NextResponse.json({ error: "baseUrl and model are required" }, { status: 400 });
|
||||
@@ -97,6 +97,7 @@ export async function POST(request) {
|
||||
|
||||
const normalizedBaseUrl = baseUrl.endsWith("/v1") ? baseUrl : `${baseUrl}/v1`;
|
||||
const keyToUse = apiKey || "sk_9router";
|
||||
const effectiveSubagentModel = subagentModel || model;
|
||||
|
||||
// Merge 9router provider
|
||||
if (!config.provider) config.provider = {};
|
||||
@@ -108,12 +109,21 @@ export async function POST(request) {
|
||||
},
|
||||
models: {
|
||||
[model]: { name: model },
|
||||
[effectiveSubagentModel]: { name: effectiveSubagentModel },
|
||||
},
|
||||
};
|
||||
|
||||
// Set as active model
|
||||
config.model = `9router/${model}`;
|
||||
|
||||
// Add subagent configuration
|
||||
if (!config.agent) config.agent = {};
|
||||
config.agent.explorer = {
|
||||
description: "Fast explorer subagent for codebase exploration",
|
||||
mode: "subagent",
|
||||
model: `9router/${effectiveSubagentModel}`,
|
||||
};
|
||||
|
||||
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
||||
|
||||
return NextResponse.json({
|
||||
@@ -149,6 +159,13 @@ export async function DELETE() {
|
||||
// Reset model if it was pointing to 9router
|
||||
if (config.model?.startsWith("9router/")) delete config.model;
|
||||
|
||||
// Remove subagent configuration
|
||||
if (config.agent?.explorer?.model?.startsWith("9router/")) {
|
||||
delete config.agent.explorer;
|
||||
// Clean up empty agent object
|
||||
if (Object.keys(config.agent).length === 0) delete config.agent;
|
||||
}
|
||||
|
||||
await fs.writeFile(configPath, JSON.stringify(config, null, 2));
|
||||
|
||||
return NextResponse.json({
|
||||
|
||||
Reference in New Issue
Block a user