(message: any)
| 467 | "anthropic-version": "2023-06-01", |
| 468 | "Content-Type": "application/json", |
| 469 | }, |
| 470 | timeout, |
| 471 | }, |
| 472 | ); |
| 473 | const content = response.data?.content |
| 474 | ?.filter((item: any) => item?.type === "text") |
| 475 | ?.map((item: any) => item.text) |
| 476 | ?.join("\n") |
| 477 | ?.trim(); |
| 478 | if (!content) throw new Error("Anthropic 返回内容为空"); |
| 479 | return content; |
| 480 | } |
| 481 | |
| 482 | async function callWithProtocol( |
| 483 | protocol: Exclude<ProviderProtocol, "auto">, |
| 484 | provider: CustomProvider, |
| 485 | input: string, |
| 486 | timeout: number, |
| 487 | ): Promise<string> { |
| 488 | switch (protocol) { |
| 489 | case "responses": |
| 490 | return callResponses( |
| 491 | provider.api_key, |
| 492 | provider.base_url, |
| 493 | provider.model, |
| 494 | input, |
| 495 | timeout, |
| 496 | ); |
| 497 | case "gemini": |
| 498 | return callGemini( |
| 499 | provider.api_key, |
| 500 | provider.base_url, |
| 501 | provider.model, |
| 502 | input, |
| 503 | timeout, |
| 504 | ); |
| 505 | case "anthropic": |
| 506 | return callAnthropic( |
| 507 | provider.api_key, |
| 508 | provider.base_url, |
no test coverage detected