Skip to content

Commit 64e351a

Browse files
committed
Support custom Anthropic API
1 parent b30125d commit 64e351a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/api/Providers/special/custom_openai.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const getOpenAIModels = async (url, apiKey) => {
2020
return res;
2121
};
2222

23-
export const getChatCompletionsURL = async (url, type) => {
23+
export const getChatCompletionsURL = (url, type) => {
2424
const suffix = (() => {
2525
switch (type) {
2626
case "OpenAI":
@@ -36,6 +36,9 @@ export const getChatCompletionsURL = async (url, type) => {
3636
export const CustomOpenAIProvider = {
3737
name: "CustomOpenAI",
3838
isCustom: true,
39+
info: {
40+
type: "OpenAI",
41+
},
3942
generate: async function* (chat, options) {
4043
// eslint-disable-next-line @typescript-eslint/no-unused-vars
4144
let { url, model, apiKey, config: reqConfig, ...reqBody } = options;
@@ -50,7 +53,7 @@ export const CustomOpenAIProvider = {
5053
} catch {}
5154

5255
// Initialize
53-
const api_url = getChatCompletionsURL(url, apiData.type);
56+
const api_url = getChatCompletionsURL(url, this.info.type ?? apiData.type);
5457

5558
apiKey = apiKey || apiData.apiKey;
5659
// The order for applying configs: reqBody -> apiData.config -> reqConfig

src/components/preferences/manageCustomAPIs.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,10 @@ const EditAPIConfig = ({ customAPIData, setCustomAPIData, url }) => {
7373
id="type"
7474
title="Type"
7575
defaultValue={APIData.type}
76-
options={[
77-
{ label: "OpenAI", value: "OpenAI" },
78-
{ label: "Anthropic", value: "Anthropic" },
79-
]}
80-
/>
76+
>
77+
<Form.Dropdown.Item title="OpenAI" value="OpenAI" />
78+
<Form.Dropdown.Item title="Anthropic" value="Anthropic" />
79+
</Form.Dropdown>
8180

8281
{/* Options */}
8382
<Form.Checkbox

0 commit comments

Comments
 (0)