feat(models): add GLM-5.2 and harden reported-model fallback
Perplexity's model fields are inconsistent per model: Claude Sonnet 5 reports the real slug in user_selected_model with display_model "turbo", while GLM-5.2 reports the inverse. Pick whichever field is present and not "turbo", and fall back to the requested model when both are missing or "turbo". Also add glm_5_2 to KNOWN_MODELS. Refs #7 (follow-up comment)
This commit is contained in:
@@ -309,6 +309,21 @@ describe("searchPerplexity", () => {
|
||||
|
||||
const fallback = await searchPerplexity({ query: "q", model: "pplx_pro_upgraded" }, "jwt");
|
||||
expect(fallback.displayModel).toBe("pplx_pro_upgraded");
|
||||
|
||||
globalThis.fetch = (async () =>
|
||||
createSseResponse([
|
||||
{
|
||||
status: "COMPLETED",
|
||||
final: true,
|
||||
text: "answer",
|
||||
display_model: "turbo",
|
||||
user_selected_model: "turbo",
|
||||
sources_list: [{ title: "S", url: "https://example.com" }],
|
||||
},
|
||||
])) as unknown as typeof fetch;
|
||||
|
||||
const requested = await searchPerplexity({ query: "q", model: "glm_5_2" }, "jwt");
|
||||
expect(requested.displayModel).toBe("glm_5_2");
|
||||
});
|
||||
|
||||
test("returns EMPTY error when response has no answer and no sources", async () => {
|
||||
|
||||
Reference in New Issue
Block a user