Skip to content

Commit

Permalink
Merge pull request #295 from d-o-it/main
Browse files Browse the repository at this point in the history
fix: added Azure OpenAI support
  • Loading branch information
blinko-space authored Dec 13, 2024
2 parents 92671b7 + a2f43fc commit 3c58fe7
Show file tree
Hide file tree
Showing 17 changed files with 214 additions and 21 deletions.
10 changes: 9 additions & 1 deletion public/locales/ar/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"api-endpoint": "نقطة نهاية API",
"must-start-with-http-s-or-use-api-openai-as-default": "يجب أن يبدأ بـ ://http(s) أو استخدام /api/openai كإعداد افتراضي",
"user-custom-openai-api-key": "مفتاح واجهة برمجة التطبيقات المخصص للمستخدم من OpenAI",
"user-custom-azureopenai-api-instance": "اسم مثيل Azure OpenAI",
"user-custom-azureopenai-api-deployment": "اسم نشر Azure OpenAI",
"user-custom-azureopenai-api-version": "نسخة API",
"ai-model": "نموذج الذكاء الاصطناعي",
"logout": "تسجيل الخروج",
"user-or-password-error": "خطأ في اسم المستخدم أو كلمة المرور",
Expand Down Expand Up @@ -247,5 +250,10 @@
"end-date": "تاريخ الانتهاء",
"reset": "إعادة تعيين",
"no-condition": "لا توجد حالة",
"public": "عام"
"public": "عام",
"ai-model-tooltip": "أدخل اسم الطراز المراد استخدامه، مثل gpt-3.5-turbo، gpt-4، gpt-4o، gpt-4o، gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": " أدخل اسم النشر المراد استخدامه، مثل gpt-4o",
"ollama-ai-model-tooltip": "أدخل اسم الطراز المراد استخدامه، مثل llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "نقطة نهاية أولاما الافتراضية هي http://localhost:11434",
"your-azure-openai-instance-name": "اسم مثيل Azure OpenAI الخاص بك"
}
10 changes: 9 additions & 1 deletion public/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
"upload-file": "Datei hochladen",
"use-ai": "Ai verwenden",
"user-custom-openai-api-key": "Benutzerdefinierter OpenAI Api-Schlüssel",
"user-custom-azureopenai-api-instance": "Azure OpenAI Instanzname",
"user-custom-azureopenai-api-deployment": "Azure OpenAI Bereitstellungsname",
"user-custom-azureopenai-api-version": "API version",
"user-or-password-error": "Benutzer- oder Passwortfehler",
"username": "Nutzername",
"your-changes-have-been-saved": "Ihre Änderungen wurden gespeichert!",
Expand Down Expand Up @@ -243,5 +246,10 @@
"end-date": "Enddatum",
"reset": "Zurücksetzen",
"no-condition": "Keine Bedingung",
"public": "Öffentlich"
"public": "Öffentlich",
"ai-model-tooltip": "Geben Sie den zu verwendenden Modellnamen ein, z. B. gpt-3.5-turbo, gpt-4, gpt-4o, gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": " Geben Sie den zu verwendenden Einsatznamen ein, z. B. gpt-4o",
"ollama-ai-model-tooltip": "Geben Sie den zu verwendenden Modellnamen ein, z. B. llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "Der Standard-Endpunkt von Ollama ist http://localhost:11434.",
"your-azure-openai-instance-name": "Der Name Ihrer Azure OpenAI-Instanz"
}
10 changes: 9 additions & 1 deletion public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"api-endpoint": "API Endpoint",
"must-start-with-http-s-or-use-api-openai-as-default": "Must start with http(s):// or use /api/openai as default",
"user-custom-openai-api-key": "User custom OpenAI Api Key",
"user-custom-azureopenai-api-instance": "Azure OpenAI instance name",
"user-custom-azureopenai-api-deployment": "Azure OpenAI deployment name",
"user-custom-azureopenai-api-version": "API version",
"ai-model": "AI Model",
"logout": "Logout",
"user-or-password-error": "User or password error",
Expand Down Expand Up @@ -257,5 +260,10 @@
"public": "Public",
"exclude-tag-from-embedding": "Exclude Tagged Content",
"exclude-tag-from-embedding-tip": "Notes with this tag will be excluded from AI embedding processing",
"exclude-tag-from-embedding-desc": "Select a tag to exclude its associated notes from AI embedding vector generation"
"exclude-tag-from-embedding-desc": "Select a tag to exclude its associated notes from AI embedding vector generation",
"ai-model-tooltip": "Enter the model name to use, such as gpt-3.5-turbo, gpt-4, gpt-4o, gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": " Enter the deployment name to use, such as gpt-4o",
"ollama-ai-model-tooltip": "Enter the model name to use, such as llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "Ollama default endpoint is http://localhost:11434",
"your-azure-openai-instance-name": "Your Azure OpenAI instance name"
}
10 changes: 9 additions & 1 deletion public/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@
"upload-file": "Cargar archivo",
"use-ai": "Utilizar ai",
"user-custom-openai-api-key": "Clave Api OpenAI personalizada por el usuario",
"user-custom-azureopenai-api-instance": "Nombre de la instancia de Azure OpenAI",
"user-custom-azureopenai-api-deployment": "Nombre de implementación de Azure OpenAI",
"user-custom-azureopenai-api-version": "Versión API",
"username": "nombre de usuario",
"your-changes-have-been-saved": "Tus cambios se han guardado.",
"all-notes-have-been-loaded": "Todas las notas {{items}} han sido cargadas",
Expand Down Expand Up @@ -243,5 +246,10 @@
"end-date": "Fecha final",
"reset": "Restablecer",
"no-condition": "Ninguna condición",
"public": "Público"
"public": "Público",
"ai-model-tooltip": "Introduzca el nombre del modelo a utilizar, como gpt-3.5-turbo, gpt-4, gpt-4o, gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": " Introduzca el nombre de despliegue que desea utilizar, por ejemplo gpt-4o",
"ollama-ai-model-tooltip": "Introduce el nombre del modelo a utilizar, por ejemplo llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "El punto final por defecto de Ollama es http://localhost:11434",
"your-azure-openai-instance-name": "Nombre de su instancia de Azure OpenAI"
}
10 changes: 9 additions & 1 deletion public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
"upload-file": "Télécharger le fichier",
"use-ai": "Utiliser l'ai",
"user-custom-openai-api-key": "Clé Api OpenAI personnalisée par l'utilisateur",
"user-custom-azureopenai-api-instance": "Nom de l'instance Azure OpenAI",
"user-custom-azureopenai-api-deployment": "Nom du déploiement Azure OpenAI",
"user-custom-azureopenai-api-version": "Version API",
"user-or-password-error": "Erreur d'utilisateur ou de mot de passe",
"username": "Nom d'utilisateur",
"backup-file": "FICHIER DE SAUVEGARDE",
Expand Down Expand Up @@ -245,5 +248,10 @@
"end-date": "Date de fin",
"reset": "Remise à zéro",
"no-condition": "Pas de condition",
"public": "Public"
"public": "Public",
"ai-model-tooltip": "Entrez le nom du modèle à utiliser, par exemple gpt-3.5-turbo, gpt-4, gpt-4o, gpt-4o-mini.",
"user-custom-azureopenai-api-deployment-tooltip": " Saisissez le nom de déploiement à utiliser, par exemple gpt-4o",
"ollama-ai-model-tooltip": "Saisissez le nom du modèle à utiliser, par exemple llama3.2.",
"ollama-default-endpoint-is-http-localhost-11434": "Le point de terminaison par défaut d'Ollama est http://localhost:11434",
"your-azure-openai-instance-name": "Nom de votre instance Azure OpenAI"
}
10 changes: 9 additions & 1 deletion public/locales/ja/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
"upload-file": "ファイルのアップロード",
"use-ai": "aiを使う",
"user-custom-openai-api-key": "ユーザー独自のOpenAI APIキー",
"user-custom-azureopenai-api-instance": "Azure OpenAI インスタンス名",
"user-custom-azureopenai-api-deployment": "Azure OpenAI デプロイ名",
"user-custom-azureopenai-api-version": "APIバージョン",
"edit": "編集",
"enter-your-password": "パスワードを入力してください",
"import-from-bko": ".bkoからのインポート",
Expand Down Expand Up @@ -242,5 +245,10 @@
"end-date": "終了日",
"reset": "リセット",
"no-condition": "コンディションなし",
"public": "パブリック"
"public": "パブリック",
"ai-model-tooltip": "gpt-3.5-turbo、gpt-4、gpt-4o、gpt-4o-miniなど、使用するモデル名を入力してください。",
"user-custom-azureopenai-api-deployment-tooltip": "使用するデプロイメント名(gpt-4o など)を入力します。",
"ollama-ai-model-tooltip": "llama3.2のように、使用するモデル名を入力してください。",
"ollama-default-endpoint-is-http-localhost-11434": "Ollama デフォルトのエンドポイントは http://localhost:11434",
"your-azure-openai-instance-name": "Azure OpenAIインスタンス名"
}
10 changes: 9 additions & 1 deletion public/locales/ko/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
"update-successfully": "업데이트 성공",
"use-ai": "AI 사용",
"user-custom-openai-api-key": "사용자 지정 OpenAI API 키",
"user-custom-azureopenai-api-instance": "Azure OpenAI 인스턴스 이름",
"user-custom-azureopenai-api-deployment": "Azure OpenAI 배포 이름",
"user-custom-azureopenai-api-version": "API 버전",
"user-or-password-error": "사용자 또는 비밀번호 오류",
"username": "사용자 이름",
"api-endpoint": "API 엔드포인트",
Expand Down Expand Up @@ -244,5 +247,10 @@
"end-date": "종료 날짜",
"reset": "초기화",
"no-condition": "조건 없음",
"public": "공개"
"public": "공개",
"ai-model-tooltip": "사용할 모델명(예: gpt-3.5-turbo, gpt-4, gpt-4o, gpt-4o-mini)을 입력합니다.",
"user-custom-azureopenai-api-deployment-tooltip": " 사용할 배포 이름(예: gpt-4o)을 입력합니다.",
"ollama-ai-model-tooltip": "사용할 모델 이름(예: llama3.2)을 입력합니다.",
"ollama-default-endpoint-is-http-localhost-11434": "Ollama 기본 엔드포인트는 http://localhost:11434",
"your-azure-openai-instance-name": "Azure OpenAI 인스턴스 이름"
}
10 changes: 9 additions & 1 deletion public/locales/pt/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
"upload-file": "Carregar ficheiro",
"use-ai": "Utilizar ai",
"user-custom-openai-api-key": "Chave de Api OpenAI personalizada pelo utilizador",
"user-custom-azureopenai-api-instance": "Nome da instância do Azure OpenAI",
"user-custom-azureopenai-api-deployment": "Nome da implantação do Azure OpenAI",
"user-custom-azureopenai-api-version": "Versão da API",
"user-or-password-error": "Erro de utilizador ou de palavra-passe",
"username": "nome de utilizador",
"your-changes-have-been-saved": "As suas alterações foram guardadas!",
Expand Down Expand Up @@ -241,5 +244,10 @@
"end-date": "Data final",
"reset": "Reiniciar",
"no-condition": "Sem condição",
"public": "Público"
"public": "Público",
"ai-model-tooltip": "Introduza o nome do modelo a utilizar, por exemplo, gpt-3.5-turbo, gpt-4, gpt-4o, gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": " Introduza o nome da implantação a utilizar, por exemplo, gpt-4o",
"ollama-ai-model-tooltip": "Introduza o nome do modelo a utilizar, por exemplo, llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "O ponto de extremidade predefinido da Ollama é http://localhost:11434",
"your-azure-openai-instance-name": "O nome da sua instância do Azure OpenAI"
}
10 changes: 9 additions & 1 deletion public/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
"upload-file": "Загрузить файл",
"use-ai": "Включить AI",
"user-custom-openai-api-key": "Пользовательский ключ OpenAI Api Key",
"user-custom-azureopenai-api-instance": "Имя экземпляра Azure OpenAI",
"user-custom-azureopenai-api-deployment": "Имя развертывания Azure OpenAI",
"user-custom-azureopenai-api-version": "Версия API",
"user-or-password-error": "Ошибка пользователя или пароля",
"username": "имя пользователя",
"your-changes-have-been-saved": "Ваши данные сохранены!",
Expand Down Expand Up @@ -246,5 +249,10 @@
"end-date": "Дата окончания",
"reset": "Сброс",
"no-condition": "Нет условий",
"public": "Общественность"
"public": "Общественность",
"ai-model-tooltip": "Введите название модели, которое необходимо использовать, например gpt-3.5-turbo, gpt-4, gpt-4o, gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": " Введите имя развертывания, которое необходимо использовать, например gpt-4o",
"ollama-ai-model-tooltip": "Введите имя модели, которое необходимо использовать, например llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "Конечная точка Ollama по умолчанию - http://localhost:11434.",
"your-azure-openai-instance-name": "Имя вашего экземпляра Azure OpenAI"
}
15 changes: 11 additions & 4 deletions public/locales/tr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@
"keep-sign-in": "Oturum açmaya devam et",
"language": "Dil",
"last-run": "SON KOŞU",
"logout": "Oturumu Kapat"
}
"delete-success": "Başarıyla silindi",
"logout": "Oturumu Kapat",
"delete-success": "Başarıyla silindi",
"enter-your-username": "Kullanıcı adınızı girin",
"every-day": "Her gün"
"every-day": "Her gün",
"user-custom-azureopenai-api-instance": "Azure OpenAI örnek adı",
"user-custom-azureopenai-api-deployment": "Azure OpenAI dağıtım adı",
"user-custom-azureopenai-api-version": "API sürümü",
"ai-model-tooltip": "Kullanılacak model adını girin, örneğin gpt-3.5-turbo, gpt-4, gpt-4o, gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": " Kullanılacak dağıtım adını girin, örneğin gpt-4o",
"ollama-ai-model-tooltip": "Kullanılacak model adını girin, örneğin llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "Ollama varsayılan uç noktası http://localhost:11434",
"your-azure-openai-instance-name": "Azure OpenAI örnek adınız"
}
10 changes: 9 additions & 1 deletion public/locales/zh-TW/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"api-endpoint": "接口地址",
"must-start-with-http-s-or-use-api-openai-as-default": "必須以 http(s):// 開頭,或默認使用 /api/openai",
"user-custom-openai-api-key": "用戶自定義 OpenAI Api 密鑰",
"user-custom-azureopenai-api-instance": "Azure OpenAI 虛擬實例名稱",
"user-custom-azureopenai-api-deployment": "Azure OpenAI 部署名稱",
"user-custom-azureopenai-api-version": "API 版本",
"ai-model": "人工智能模型",
"logout": "註銷",
"user-or-password-error": "用戶或密碼錯誤",
Expand Down Expand Up @@ -246,5 +249,10 @@
"end-date": "结束日期",
"reset": "重置",
"no-condition": "无条件",
"public": "公开的"
"public": "公开的",
"ai-model-tooltip": "输入要使用的型号名称,例如 gpt-3.5-turbo、gpt-4、gpt-4o、gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": "输入要使用的部署名称,如 gpt-4o",
"ollama-ai-model-tooltip": "输入要使用的模型名称,如 llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "Ollama 默认端点为 http://localhost:11434",
"your-azure-openai-instance-name": "您的 Azure OpenAI 实例名称"
}
12 changes: 10 additions & 2 deletions public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
"api-endpoint": "接口地址",
"must-start-with-http-s-or-use-api-openai-as-default": "必须以 http(s):// 开头,或默认使用 /api/openai",
"user-custom-openai-api-key": "用户自定义 OpenAI Api 密钥",
"user-custom-azureopenai-api-instance": "Azure OpenAI 虚拟实例名称",
"user-custom-azureopenai-api-deployment": "Azure OpenAI 部署名称",
"user-custom-azureopenai-api-version": "API 版本",
"ai-model": "人工智能模型",
"logout": "注销",
"user-or-password-error": "用户或密码错误",
Expand Down Expand Up @@ -165,7 +168,7 @@
"if-you-have-a-lot-of-notes-you-may-consume-a-certain-number-of-tokens": "如果您有大量笔记,您可能会消耗一定数量的代币",
"force-rebuild": "强制重建",
"force-rebuild-embedding-index": "强制重建将完全重建已索引的所有数据",
"embedding-model-description": "切��入式模型后必须重建索引",
"embedding-model-description": "切换嵌入式模型后必须重建索引",
"top-k-description": "最终返回文件的最大数量",
"embedding-score-description": "查询的相似性阈值通常是欧氏总和距离",
"embedding-lambda-description": "查询结果多样性加权参数",
Expand Down Expand Up @@ -254,5 +257,10 @@
"public": "公开的",
"exclude-tag-from-embedding": "排除标签内容",
"exclude-tag-from-embedding-tip": "带有此标签的笔记内容将不会被用于AI嵌入式处理",
"exclude-tag-from-embedding-desc": "选择一个标签来排除其关联笔记的内容,这些内容将不会被用于生成AI嵌入向量"
"exclude-tag-from-embedding-desc": "选择一个标签来排除其关联笔记的内容,这些内容将不会被用于生成AI嵌入向量",
"ai-model-tooltip": "输入要使用的型号名称,例如 gpt-3.5-turbo、gpt-4、gpt-4o、gpt-4o-mini",
"user-custom-azureopenai-api-deployment-tooltip": "输入要使用的部署名称,如 gpt-4o",
"ollama-ai-model-tooltip": "输入要使用的模型名称,如 llama3.2",
"ollama-default-endpoint-is-http-localhost-11434": "Ollama 默认端点为 http://localhost:11434",
"your-azure-openai-instance-name": "您的 Azure OpenAI 实例名称"
}
41 changes: 37 additions & 4 deletions src/components/BlinkoSettings/AiSetting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ export const AiSetting = observer(() => {
const ai = RootStore.Get(AiStore)
const { t } = useTranslation()
const isPc = useMediaQuery('(min-width: 768px)')

const store = RootStore.Local(() => ({
isVisible: false,
apiKey: '',
apiVersion: '',
apiEndPoint: '',
aiModel: '',
embeddingModel: '',
Expand All @@ -31,8 +33,10 @@ export const AiSetting = observer(() => {
showEmeddingAdvancedSetting: false,
excludeEmbeddingTagId: null as number | null
}))

useEffect(() => {
store.apiEndPoint = blinko.config.value?.aiApiEndpoint!
store.apiVersion = blinko.config.value?.aiApiVersion!
store.apiKey = blinko.config.value?.aiApiKey!
store.aiModel = blinko.config.value?.aiModel!
store.embeddingModel = blinko.config.value?.embeddingModel!
Expand All @@ -41,6 +45,7 @@ export const AiSetting = observer(() => {
store.embeddingLambda = blinko.config.value?.embeddingLambda!
store.excludeEmbeddingTagId = blinko.config.value?.excludeEmbeddingTagId!
}, [blinko.config.value])

return <Card shadow="none" className="flex flex-col p-4 bg-background pb-6">
<div className='text-desc text-sm'>AI</div>
<Item
Expand Down Expand Up @@ -89,7 +94,9 @@ export const AiSetting = observer(() => {

{
ai.modelSelect[blinko.config.value?.aiModelProvider!] && <Item
leftContent={<>{t('ai-model')}</>}
leftContent={<ItemWithTooltip
content={ai.modelSelectUILabel[blinko.config.value?.aiModelProvider!]?.modelTitle}
toolTipContent={ai.modelSelectUILabel[blinko.config.value?.aiModelProvider!]?.modelTooltip} />}
rightContent={
<Autocomplete
radius="lg"
Expand Down Expand Up @@ -323,11 +330,36 @@ export const AiSetting = observer(() => {
} />
}

< Item
{
blinko.config.value?.aiModelProvider == 'AzureOpenAI' &&
<Item
type={isPc ? 'row' : 'col'}
leftContent={<div className="flex flex-col ga-1">
<>{t('user-custom-azureopenai-api-version')}</>
</div>}
rightContent={
<Input
variant="bordered"
className="w-full md:w-[300px]"
placeholder="Enter API version"
value={store.apiVersion}
onChange={e => { store.apiVersion = e.target.value }}
onBlur={e => {
PromiseCall(api.config.update.mutate({
key: 'aiApiVersion',
value: store.apiVersion
}))
}}
type="text"
/>
} />
}

<Item
type={isPc ? 'row' : 'col'}
leftContent={< div className="flex flex-col gap-1" >
<>{t('api-endpoint')}</>
<div className="text-desc text-xs">{t('must-start-with-http-s-or-use-api-openai-as-default')}</div>
<>{ai.modelSelectUILabel[blinko.config.value?.aiModelProvider!]?.endpointTitle}</>
<div className="text-desc text-xs">{ai.modelSelectUILabel[blinko.config.value?.aiModelProvider!]?.endpointTooltip}</div>
</div >}
rightContent={< Input
size='sm'
Expand All @@ -345,6 +377,7 @@ export const AiSetting = observer(() => {
}}
/>} />


<Item
type={isPc ? 'row' : 'col'}
leftContent={<div className="flex flex-col gap-2">
Expand Down
Loading

0 comments on commit 3c58fe7

Please sign in to comment.