Fix Qwen OAuth and Ollama models listing
- Add generateUXDesignerPrompt method to QwenOAuthService - Fix Ollama Cloud listModels to handle multiple response formats - Improve Ollama models parsing with array/different response structures - All providers now support UX Designer Prompt feature
This commit is contained in:
38
app/api/qwen/user/route.ts
Normal file
38
app/api/qwen/user/route.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { QWEN_OAUTH_BASE_URL } from "../constants";
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
const authorization = request.headers.get("authorization");
|
||||
if (!authorization || !authorization.startsWith("Bearer ")) {
|
||||
return NextResponse.json(
|
||||
{ error: "Authorization required" },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
const token = authorization.slice(7);
|
||||
|
||||
const userResponse = await fetch(`${QWEN_OAUTH_BASE_URL}/api/v1/user`, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!userResponse.ok) {
|
||||
const errorText = await userResponse.text();
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to fetch user info", details: errorText },
|
||||
{ status: userResponse.status }
|
||||
);
|
||||
}
|
||||
|
||||
const userData = await userResponse.json();
|
||||
return NextResponse.json({ user: userData });
|
||||
} catch (error) {
|
||||
console.error("Qwen user info failed", error);
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to fetch user info" },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user