Skip to content

Commit 74bcba8

Browse files
committed
allow custom claude api url (#644)
1 parent e2ec8ac commit 74bcba8

File tree

16 files changed

+40
-14
lines changed

16 files changed

+40
-14
lines changed

src/_locales/de/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Seitenleiste öffnen",
133133
"Generating...": "Generieren...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "Moonshot-Token erforderlich, bitte zuerst bei https://kimi.moonshot.cn anmelden",
135-
"Hide context menu of this extension": "Kontextmenü dieser Erweiterung ausblenden"
135+
"Hide context menu of this extension": "Kontextmenü dieser Erweiterung ausblenden",
136+
"Custom Claude API Url": "Benutzerdefinierte Claude-API-URL"
136137
}

src/_locales/en/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Open Side Panel",
133133
"Generating...": "Generating...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "moonshot token required, please login at https://kimi.moonshot.cn first",
135-
"Hide context menu of this extension": "Hide context menu of this extension"
135+
"Hide context menu of this extension": "Hide context menu of this extension",
136+
"Custom Claude API Url": "Custom Claude API Url"
136137
}

src/_locales/es/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Abrir panel lateral",
133133
"Generating...": "Generando...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "se requiere un token de moonshot, por favor inicie sesión en https://kimi.moonshot.cn primero",
135-
"Hide context menu of this extension": "Ocultar menú contextual de esta extensión"
135+
"Hide context menu of this extension": "Ocultar menú contextual de esta extensión",
136+
"Custom Claude API Url": "URL personalizada de la API de Claude"
136137
}

src/_locales/fr/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Ouvrir le panneau latéral",
133133
"Generating...": "Génération...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "jeton moonshot requis, veuillez vous connecter d'abord sur https://kimi.moonshot.cn",
135-
"Hide context menu of this extension": "Masquer le menu contextuel de cette extension"
135+
"Hide context menu of this extension": "Masquer le menu contextuel de cette extension",
136+
"Custom Claude API Url": "URL API Claude personnalisée"
136137
}

src/_locales/in/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Buka Panel Samping",
133133
"Generating...": "Menghasilkan...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "diperlukan token moonshot, silakan masuk di https://kimi.moonshot.cn terlebih dahulu",
135-
"Hide context menu of this extension": "Sembunyikan menu konteks ekstensi ini"
135+
"Hide context menu of this extension": "Sembunyikan menu konteks ekstensi ini",
136+
"Custom Claude API Url": "URL API Claude Kustom"
136137
}

src/_locales/it/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Apri il pannello laterale",
133133
"Generating...": "Generazione...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "richiesto token moonshot, effettua il login su https://kimi.moonshot.cn prima",
135-
"Hide context menu of this extension": "Nascondi il menu contestuale di questa estensione"
135+
"Hide context menu of this extension": "Nascondi il menu contestuale di questa estensione",
136+
"Custom Claude API Url": "URL API Claude personalizzato"
136137
}

src/_locales/ja/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "サイドパネルを開く",
133133
"Generating...": "生成中...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "moonshotトークンが必要です。最初にhttps://kimi.moonshot.cnにログインしてください",
135-
"Hide context menu of this extension": "この拡張機能のコンテキストメニューを非表示"
135+
"Hide context menu of this extension": "この拡張機能のコンテキストメニューを非表示",
136+
"Custom Claude API Url": "カスタムClaude APIのURL"
136137
}

src/_locales/ko/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "사이드 패널 열기",
133133
"Generating...": "생성 중...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "moonshot 토큰이 필요합니다. https://kimi.moonshot.cn 에서 로그인하세요.",
135-
"Hide context menu of this extension": "이 확장 프로그램의 컨텍스트 메뉴 숨기기"
135+
"Hide context menu of this extension": "이 확장 프로그램의 컨텍스트 메뉴 숨기기",
136+
"Custom Claude API Url": "사용자 정의 Claude API URL"
136137
}

src/_locales/pt/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Abrir Painel Lateral",
133133
"Generating...": "Gerando...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "token moonshot necessário, por favor faça login em https://kimi.moonshot.cn primeiro",
135-
"Hide context menu of this extension": "Ocultar menu de contexto desta extensão"
135+
"Hide context menu of this extension": "Ocultar menu de contexto desta extensão",
136+
"Custom Claude API Url": "URL da API Personalizada do Claude"
136137
}

src/_locales/ru/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Открыть боковую панель",
133133
"Generating...": "Генерация...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "требуется токен moonshot, пожалуйста, сначала войдите на https://kimi.moonshot.cn",
135-
"Hide context menu of this extension": "Скрыть контекстное меню этого расширения"
135+
"Hide context menu of this extension": "Скрыть контекстное меню этого расширения",
136+
"Custom Claude API Url": "Пользовательский URL API Claude"
136137
}

src/_locales/tr/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "Yan Paneli Aç",
133133
"Generating...": "Üretiliyor...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "moonshot jetonu gerekiyor, lütfen önce https://kimi.moonshot.cn adresinde oturum açın",
135-
"Hide context menu of this extension": "Bu uzantının bağlam menüsünü gizle"
135+
"Hide context menu of this extension": "Bu uzantının bağlam menüsünü gizle",
136+
"Custom Claude API Url": "Özel Claude API Url'si"
136137
}

src/_locales/zh-hans/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "打开侧边栏",
133133
"Generating...": "正在生成...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "需要moonshot token, 请先登录 https://kimi.moonshot.cn",
135-
"Hide context menu of this extension": "隐藏此扩展的右键菜单"
135+
"Hide context menu of this extension": "隐藏此扩展的右键菜单",
136+
"Custom Claude API Url": "自定义的Claude API地址"
136137
}

src/_locales/zh-hant/main.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,6 @@
132132
"Open Side Panel": "開啟側邊面板",
133133
"Generating...": "產生中...",
134134
"moonshot token required, please login at https://kimi.moonshot.cn first": "需要 moonshot token,請先在 https://kimi.moonshot.cn 登入",
135-
"Hide context menu of this extension": "隱藏此擴充功能的右鍵選單"
135+
"Hide context menu of this extension": "隱藏此擴充功能的右鍵選單",
136+
"Custom Claude API Url": "自訂 Claude API 網址"
136137
}

src/config/index.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ export const defaultConfig = {
231231
customChatGptWebApiUrl: 'https://chat.openai.com',
232232
customChatGptWebApiPath: '/backend-api/conversation',
233233
customOpenAiApiUrl: 'https://api.openai.com',
234+
customClaudeApiUrl: 'https://api.anthropic.com',
234235
disableWebModeHistory: true,
235236
hideContextMenu: false,
236237
siteRegex: 'match nothing',

src/popup/sections/AdvancedPart.jsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@ function ApiUrl({ config, updateConfig }) {
103103
}}
104104
/>
105105
</label>
106+
<label>
107+
{t('Custom Claude API Url')}
108+
<input
109+
type="text"
110+
value={config.customClaudeApiUrl}
111+
onChange={(e) => {
112+
const value = e.target.value
113+
updateConfig({ customClaudeApiUrl: value })
114+
}}
115+
/>
116+
</label>
106117
</>
107118
)
108119
}

src/services/apis/claude-api.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { getConversationPairs } from '../../utils/get-conversation-pairs.mjs'
1212
export async function generateAnswersWithClaudeApi(port, question, session) {
1313
const { controller, messageListener, disconnectListener } = setAbortController(port)
1414
const config = await getUserConfig()
15+
const apiUrl = config.customClaudeApiUrl
1516
const modelName = session.modelName
1617

1718
const prompt = getConversationPairs(
@@ -21,7 +22,7 @@ export async function generateAnswersWithClaudeApi(port, question, session) {
2122
prompt.push({ role: 'user', content: question })
2223

2324
let answer = ''
24-
await fetchSSE(`https://api.anthropic.com/v1/messages`, {
25+
await fetchSSE(`${apiUrl}/v1/messages`, {
2526
method: 'POST',
2627
signal: controller.signal,
2728
headers: {

0 commit comments

Comments
 (0)