Skip to content

Commit

Permalink
✨ feat: add Github Models provider (lobehub#3869)
Browse files Browse the repository at this point in the history
* ✨ feat: add Github Models as provider

* :bug fix: sort order of ProviderList

* 💄 style: add more info for Github Models provider

* ✨ feat: Add GitHub provider configuration

Adds support for configuring the GitHub provider in the LLM settings. It includes:

- A new `useGithubProvider` hook to define the GitHub provider configuration
- Integration of the GitHub provider in the provider list
- Localization strings for the GitHub personal access token input

The changes allow users to enter their GitHub personal access token to use GitHub-related LLM features.

* 🐛 fix: use Github Personal access tokens (classic) instead

* 💄 style: Add Invalid Github Token error type and message

Adds support for handling invalid Github Personal Access Tokens:

- Adds a new `InvalidGithubToken` error type in the `AgentRuntimeErrorType` enum
- Adds an error message for `InvalidGithubToken` in the localization files
- Configures the Github AI provider to use the new error type

This allows properly handling and displaying errors when an invalid Github token is provided.

* ✅ test: fix test for new error type

* 🐛 fix: sort order of ProviderCards

* 💄 style: use abbreviation for Github PAT

* 💄 style: add the hyperlink for creating Github PAT

* 🌐 chore: improve desc

* ✅ test: update test

---------

Co-authored-by: arvinxx <arvinx@foxmail.com>
  • Loading branch information
CloudPassenger and arvinxx authored Sep 18, 2024
1 parent 5ccc41d commit 8eac1bd
Show file tree
Hide file tree
Showing 52 changed files with 727 additions and 4 deletions.
1 change: 1 addition & 0 deletions locales/ar/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "كلمة المرور غير صحيحة أو فارغة، يرجى إدخال كلمة مرور الوصول الصحيحة أو إضافة مفتاح API مخصص",
"InvalidBedrockCredentials": "فشلت مصادقة Bedrock، يرجى التحقق من AccessKeyId/SecretAccessKey وإعادة المحاولة",
"InvalidClerkUser": "عذرًا، لم تقم بتسجيل الدخول بعد، يرجى تسجيل الدخول أو التسجيل للمتابعة",
"InvalidGithubToken": "رمز وصول شخصية GitHub غير صحيح أو فارغ، يرجى التحقق من رمز وصول GitHub الشخصي والمحاولة مرة أخرى",
"InvalidOllamaArgs": "تكوين Ollama غير صحيح، يرجى التحقق من تكوين Ollama وإعادة المحاولة",
"InvalidProviderAPIKey": "{{provider}} مفتاح API غير صحيح أو فارغ، يرجى التحقق من مفتاح API {{provider}} الخاص بك وحاول مرة أخرى",
"LocationNotSupportError": "عذرًا، لا يدعم موقعك الحالي خدمة هذا النموذج، قد يكون ذلك بسبب قيود المنطقة أو عدم توفر الخدمة. يرجى التحقق مما إذا كان الموقع الحالي يدعم استخدام هذه الخدمة، أو محاولة استخدام معلومات الموقع الأخرى.",
Expand Down
7 changes: 7 additions & 0 deletions locales/ar/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "استخدام معلومات المصادقة الخاصة بـ Bedrock المخصصة"
}
},
"github": {
"personalAccessToken": {
"desc": "أدخل رمز الوصول الشخصي الخاص بك على Github، انقر [هنا](https://github.com/settings/tokens) لإنشاء واحد",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "اختبر ما إذا تم إدخال عنوان الوكيل بشكل صحيح",
Expand Down
1 change: 1 addition & 0 deletions locales/bg-BG/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "Невалиден или празен код за достъп. Моля, въведете правилния код за достъп или добавете персонализиран API ключ.",
"InvalidBedrockCredentials": "Удостоверяването на Bedrock е неуспешно. Моля, проверете AccessKeyId/SecretAccessKey и опитайте отново.",
"InvalidClerkUser": "很抱歉,你当前尚未登录,请先登录或注册账号后继续操作",
"InvalidGithubToken": "GitHub Личният Достъпен Токен е неправилен или е празен. Моля, проверете Личния Достъпен Токен на GitHub и опитайте отново.",
"InvalidOllamaArgs": "Невалидна конфигурация на Ollama, моля, проверете конфигурацията на Ollama и опитайте отново",
"InvalidProviderAPIKey": "{{provider}} API ключ е невалиден или липсва, моля проверете {{provider}} API ключа и опитайте отново",
"LocationNotSupportError": "Съжаляваме, вашето текущо местоположение не поддържа тази услуга на модела. Това може да се дължи на регионални ограничения или на недостъпност на услугата. Моля, потвърдете дали текущото местоположение поддържа използването на тази услуга или опитайте да използвате друго местоположение.",
Expand Down
7 changes: 7 additions & 0 deletions locales/bg-BG/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "Използване на персонализирана информация за удостоверяване на Bedrock"
}
},
"github": {
"personalAccessToken": {
"desc": "Въведете вашия GitHub PAT, кликнете [тук](https://github.com/settings/tokens), за да създадете",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "Тестване дали адресът на прокси е попълнен правилно",
Expand Down
1 change: 1 addition & 0 deletions locales/de-DE/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "Das Passwort ist ungültig oder leer. Bitte geben Sie das richtige Zugangspasswort ein oder fügen Sie einen benutzerdefinierten API-Schlüssel hinzu.",
"InvalidBedrockCredentials": "Die Bedrock-Authentifizierung ist fehlgeschlagen. Bitte überprüfen Sie AccessKeyId/SecretAccessKey und versuchen Sie es erneut.",
"InvalidClerkUser": "Entschuldigung, du bist derzeit nicht angemeldet. Bitte melde dich an oder registriere ein Konto, um fortzufahren.",
"InvalidGithubToken": "Der persönliche Zugriffstoken für Github ist ungültig oder leer. Bitte überprüfen Sie den persönlichen Zugriffstoken für Github und versuchen Sie es erneut.",
"InvalidOllamaArgs": "Ollama-Konfiguration ist ungültig. Bitte überprüfen Sie die Ollama-Konfiguration und versuchen Sie es erneut.",
"InvalidProviderAPIKey": "{{provider}} API-Schlüssel ist ungültig oder leer. Bitte überprüfen Sie den {{provider}} API-Schlüssel und versuchen Sie es erneut.",
"LocationNotSupportError": "Entschuldigung, Ihr Standort unterstützt diesen Modellservice möglicherweise aufgrund von regionalen Einschränkungen oder nicht aktivierten Diensten nicht. Bitte überprüfen Sie, ob der aktuelle Standort die Verwendung dieses Dienstes unterstützt, oder versuchen Sie, andere Standortinformationen zu verwenden.",
Expand Down
7 changes: 7 additions & 0 deletions locales/de-DE/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "Verwenden Sie benutzerdefinierte Bedrock-Authentifizierungsinformationen"
}
},
"github": {
"personalAccessToken": {
"desc": "Geben Sie Ihr GitHub-PAT ein und klicken Sie [hier](https://github.com/settings/tokens), um eines zu erstellen.",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "Testen Sie, ob die Proxy-Adresse korrekt eingetragen wurde",
Expand Down
1 change: 1 addition & 0 deletions locales/en-US/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "Invalid access code or empty. Please enter the correct access code or add a custom API Key.",
"InvalidBedrockCredentials": "Bedrock authentication failed. Please check the AccessKeyId/SecretAccessKey and retry.",
"InvalidClerkUser": "Sorry, you are not currently logged in. Please log in or register an account to continue.",
"InvalidGithubToken": "The GitHub Personal Access Token is incorrect or empty. Please check your GitHub Personal Access Token and try again.",
"InvalidOllamaArgs": "Invalid Ollama configuration, please check Ollama configuration and try again",
"InvalidProviderAPIKey": "{{provider}} API Key is incorrect or empty, please check your {{provider}} API Key and try again",
"LocationNotSupportError": "We're sorry, your current location does not support this model service. This may be due to regional restrictions or the service not being available. Please confirm if the current location supports using this service, or try using a different location.",
Expand Down
7 changes: 7 additions & 0 deletions locales/en-US/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "Use Custom Bedrock Authentication Information"
}
},
"github": {
"personalAccessToken": {
"desc": "Enter your GitHub PAT. Click [here](https://github.com/settings/tokens) to create one.",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "Test if the proxy address is correctly filled in",
Expand Down
1 change: 1 addition & 0 deletions locales/es-ES/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "La contraseña no es válida o está vacía. Por favor, introduce una contraseña de acceso válida o añade una clave API personalizada",
"InvalidBedrockCredentials": "La autenticación de Bedrock no se ha completado con éxito, por favor, verifica AccessKeyId/SecretAccessKey e inténtalo de nuevo",
"InvalidClerkUser": "Lo siento mucho, actualmente no has iniciado sesión. Por favor, inicia sesión o regístrate antes de continuar.",
"InvalidGithubToken": "El token de acceso personal de Github es incorrecto o está vacío. Por favor, verifica el token de acceso personal de Github y vuelve a intentarlo.",
"InvalidOllamaArgs": "La configuración de Ollama no es válida, por favor revisa la configuración de Ollama e inténtalo de nuevo",
"InvalidProviderAPIKey": "{{provider}} API Key incorrecta o vacía, por favor revisa tu {{provider}} API Key e intenta de nuevo",
"LocationNotSupportError": "Lo sentimos, tu ubicación actual no es compatible con este servicio de modelo, puede ser debido a restricciones geográficas o a que el servicio no está disponible. Por favor, verifica si tu ubicación actual es compatible con este servicio o intenta usar otra información de ubicación.",
Expand Down
7 changes: 7 additions & 0 deletions locales/es-ES/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "Usar información de autenticación de Bedrock personalizada"
}
},
"github": {
"personalAccessToken": {
"desc": "Introduce tu PAT de Github, haz clic [aquí](https://github.com/settings/tokens) para crear uno",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "Prueba si la dirección del proxy de la interfaz se ha introducido correctamente",
Expand Down
1 change: 1 addition & 0 deletions locales/fr-FR/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "Le mot de passe est incorrect ou vide. Veuillez saisir le mot de passe d'accès correct ou ajouter une clé API personnalisée.",
"InvalidBedrockCredentials": "L'authentification Bedrock a échoué, veuillez vérifier AccessKeyId/SecretAccessKey et réessayer",
"InvalidClerkUser": "Désolé, vous n'êtes pas actuellement connecté. Veuillez vous connecter ou vous inscrire avant de continuer.",
"InvalidGithubToken": "Le jeton d'accès personnel GitHub est incorrect ou vide. Veuillez vérifier le jeton d'accès personnel GitHub et réessayer.",
"InvalidOllamaArgs": "La configuration d'Ollama n'est pas valide, veuillez vérifier la configuration d'Ollama et réessayer",
"InvalidProviderAPIKey": "{{provider}} API Key incorrect or missing, please check {{provider}} API Key and try again",
"LocationNotSupportError": "Désolé, votre emplacement actuel ne prend pas en charge ce service de modèle, peut-être en raison de restrictions géographiques ou de services non disponibles. Veuillez vérifier si votre emplacement actuel prend en charge ce service ou essayer avec une autre localisation.",
Expand Down
7 changes: 7 additions & 0 deletions locales/fr-FR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "Utiliser des informations d'authentification Bedrock personnalisées"
}
},
"github": {
"personalAccessToken": {
"desc": "Entrez votre PAT GitHub, cliquez [ici](https://github.com/settings/tokens) pour en créer un.",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "Vérifiez si l'adresse du proxy est correctement saisie",
Expand Down
1 change: 1 addition & 0 deletions locales/it-IT/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "Password incorrect or empty, please enter the correct access password, or add a custom API Key",
"InvalidBedrockCredentials": "Autenticazione Bedrock non riuscita, controlla AccessKeyId/SecretAccessKey e riprova",
"InvalidClerkUser": "Spiacenti, al momento non hai effettuato l'accesso. Per favore, effettua l'accesso o registrati prima di continuare.",
"InvalidGithubToken": "Il token di accesso personale di Github non è corretto o è vuoto. Controlla il token di accesso personale di Github e riprova.",
"InvalidOllamaArgs": "Configurazione Ollama non valida, controllare la configurazione di Ollama e riprovare",
"InvalidProviderAPIKey": "{{provider}} Chiave API non valida o vuota, controlla la Chiave API di {{provider}} e riprova",
"LocationNotSupportError": "Spiacenti, la tua posizione attuale non supporta questo servizio modello, potrebbe essere a causa di restrizioni geografiche o servizi non attivati. Verifica se la posizione attuale supporta l'uso di questo servizio o prova a utilizzare un'altra posizione.",
Expand Down
7 changes: 7 additions & 0 deletions locales/it-IT/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "Usa le informazioni di autenticazione Bedrock personalizzate"
}
},
"github": {
"personalAccessToken": {
"desc": "Inserisci il tuo PAT di Github, clicca [qui](https://github.com/settings/tokens) per crearne uno",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "Verifica se l'indirizzo del proxy è stato compilato correttamente",
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "パスワードが正しくないか空です。正しいアクセスパスワードを入力するか、カスタムAPIキーを追加してください",
"InvalidBedrockCredentials": "Bedrockの認証に失敗しました。AccessKeyId/SecretAccessKeyを確認してから再試行してください。",
"InvalidClerkUser": "申し訳ありませんが、現在ログインしていません。続行するにはログインまたはアカウント登録を行ってください",
"InvalidGithubToken": "Githubのパーソナルアクセストークンが無効または空です。Githubのパーソナルアクセストークンを確認してから、再試行してください。",
"InvalidOllamaArgs": "Ollamaの設定が正しくありません。Ollamaの設定を確認してからもう一度お試しください",
"InvalidProviderAPIKey": "{{provider}} APIキーが正しくないか空です。{{provider}} APIキーを確認して再試行してください。",
"LocationNotSupportError": "申し訳ありませんが、お住まいの地域ではこのモデルサービスをサポートしていません。地域制限またはサービスが利用できない可能性があります。現在の位置がこのサービスをサポートしているかどうかを確認するか、他の位置情報を使用してみてください。",
Expand Down
7 changes: 7 additions & 0 deletions locales/ja-JP/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "使用カスタム Bedrock 認証情報"
}
},
"github": {
"personalAccessToken": {
"desc": "あなたのGithub PATを入力してください。[こちら](https://github.com/settings/tokens)をクリックして作成します",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "プロキシアドレスが正しく入力されているかをテストします",
Expand Down
1 change: 1 addition & 0 deletions locales/ko-KR/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "액세스 코드가 잘못되었거나 비어 있습니다. 올바른 액세스 코드를 입력하거나 사용자 지정 API 키를 추가하십시오.",
"InvalidBedrockCredentials": "Bedrock 인증에 실패했습니다. AccessKeyId/SecretAccessKey를 확인한 후 다시 시도하십시오.",
"InvalidClerkUser": "죄송합니다. 현재 로그인되어 있지 않습니다. 계속하려면 먼저 로그인하거나 계정을 등록해주세요.",
"InvalidGithubToken": "Github 개인 액세스 토큰이 올바르지 않거나 비어 있습니다. Github 개인 액세스 토큰을 확인한 후 다시 시도해 주십시오.",
"InvalidOllamaArgs": "Ollama 구성이 잘못되었습니다. Ollama 구성을 확인한 후 다시 시도하십시오.",
"InvalidProviderAPIKey": "{{provider}} API 키가 잘못되었거나 비어 있습니다. {{provider}} API 키를 확인하고 다시 시도하십시오.",
"LocationNotSupportError": "죄송합니다. 귀하의 현재 위치는 해당 모델 서비스를 지원하지 않습니다. 지역 제한 또는 서비스 미개통으로 인한 것일 수 있습니다. 현재 위치가 해당 서비스를 지원하는지 확인하거나 다른 위치 정보를 사용해 보십시오.",
Expand Down
7 changes: 7 additions & 0 deletions locales/ko-KR/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "사용자 정의 Bedrock 인증 정보 사용"
}
},
"github": {
"personalAccessToken": {
"desc": "당신의 Github PAT를 입력하세요. [여기](https://github.com/settings/tokens)를 클릭하여 생성하세요.",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "프록시 주소가 올바르게 입력되었는지 테스트합니다",
Expand Down
1 change: 1 addition & 0 deletions locales/nl-NL/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "Ongeldige toegangscode: het wachtwoord is onjuist of leeg. Voer de juiste toegangscode in of voeg een aangepaste API-sleutel toe.",
"InvalidBedrockCredentials": "Bedrock authentication failed, please check AccessKeyId/SecretAccessKey and retry",
"InvalidClerkUser": "Sorry, you are not currently logged in. Please log in or register an account to continue.",
"InvalidGithubToken": "Github Persoonlijke Toegangstoken is ongeldig of leeg, controleer de Github Persoonlijke Toegangstoken en probeer het opnieuw.",
"InvalidOllamaArgs": "Ollama-configuratie is onjuist, controleer de Ollama-configuratie en probeer het opnieuw",
"InvalidProviderAPIKey": "{{provider}} API-sleutel is onjuist of leeg. Controleer de {{provider}} API-sleutel en probeer het opnieuw.",
"LocationNotSupportError": "Sorry, your current location does not support this model service, possibly due to regional restrictions or service not being available. Please confirm if the current location supports using this service, or try using other location information.",
Expand Down
7 changes: 7 additions & 0 deletions locales/nl-NL/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "Gebruik aangepaste Bedrock-verificatiegegevens"
}
},
"github": {
"personalAccessToken": {
"desc": "Vul je Github PAT in, klik [hier](https://github.com/settings/tokens) om er een te maken",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "Test of het proxyadres correct is ingevuld",
Expand Down
1 change: 1 addition & 0 deletions locales/pl-PL/error.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"InvalidAccessCode": "Nieprawidłowy kod dostępu: Hasło jest nieprawidłowe lub puste. Proszę wprowadzić poprawne hasło dostępu lub dodać niestandardowy klucz API.",
"InvalidBedrockCredentials": "Uwierzytelnienie Bedrock nie powiodło się, prosimy sprawdzić AccessKeyId/SecretAccessKey i spróbować ponownie.",
"InvalidClerkUser": "Przepraszamy, nie jesteś obecnie zalogowany. Proszę najpierw zalogować się lub zarejestrować, aby kontynuować.",
"InvalidGithubToken": "Token dostępu osobistego do GitHub jest niewłaściwy lub pusty. Proszę sprawdzić Token dostępu osobistego do GitHub i spróbować ponownie.",
"InvalidOllamaArgs": "Nieprawidłowa konfiguracja Ollama, sprawdź konfigurację Ollama i spróbuj ponownie",
"InvalidProviderAPIKey": "{{provider}} Klucz API jest nieprawidłowy lub pusty. Sprawdź Klucz API {{provider}} i spróbuj ponownie.",
"LocationNotSupportError": "Przepraszamy, Twoja lokalizacja nie obsługuje tego usługi modelu, być może ze względu na ograniczenia regionalne lub brak dostępności usługi. Proszę sprawdź, czy bieżąca lokalizacja obsługuje tę usługę, lub spróbuj użyć innych informacji o lokalizacji.",
Expand Down
7 changes: 7 additions & 0 deletions locales/pl-PL/modelProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
"title": "Użyj niestandardowych informacji uwierzytelniających Bedrock"
}
},
"github": {
"personalAccessToken": {
"desc": "Wprowadź swój osobisty token dostępu GitHub (PAT), kliknij [tutaj](https://github.com/settings/tokens), aby go utworzyć",
"placeholder": "ghp_xxxxxx",
"title": "GitHub PAT"
}
},
"ollama": {
"checker": {
"desc": "Test czy adres proxy jest poprawnie wypełniony",
Expand Down
Loading

0 comments on commit 8eac1bd

Please sign in to comment.