释放 Azure Open AI 的强大功能 前提条件 1. Azure OpenAI: 要部署和运行 AzureChatGPT,您需要具有 Azure 订阅…
释放 Azure Open AI 的强大功能 前提条件 1. Azure OpenAI: 要部署和运行 AzureChatGPT,您需要具有 Azure 订阅…
Azure OpenAI: To deploy and run AzureChatGPT, you'll need an Azure subscription with access to the Azure OpenAI service. Request access here. Once you have access, follow the instructions in this link to deploy the gpt-35-turbo or gpt-4 models.
Setup GitHub or Azure AD for Authentication: The Add an identity provider section below shows how to configure authentication providers.
Note: You can configure the authentication provider to your identity solution using NextAuth providers
AzureChatGPT is built with the following technologies.
Node.js 18: an open-source, cross-platform JavaScript runtime environment.
Next.js 13: enables you to create full-stack web applications by extending the latest React features
NextAuth.js: configurable authentication framework for Next.js 13
Tailwind CSS: is a utility-first CSS framework that provides a series of predefined classes that can be used to style each element by mixing and matching
shadcn/ui: re-usable components built using Radix UI and Tailwind CSS.
Azure Cosmos DB: fully managed platform-as-a-service (PaaS) NoSQL database to store chat history
Azure App Service: fully managed platform-as-a-service (PaaS) for hosting web applications, REST APIs, and mobile back ends.
Click on the Deploy to Azure button and configure your settings in the Azure Portal as described in the Environment variables section.
Please see the section below for important information about adding authentication to your app.
Clone this repository locally or fork to your Github account.
.env.local to store the environment variables add the following variables…npm installnpm run devYou should now be prompted to login with GitHub. Once you successfully login, you can start creating new conversations.
Fork this repository to your own organisation so that you can execute GitHub Actions against your own Azure Subscription.
The GitHub workflow requires a secret named AZURE_CREDENTIALS to authenticate with Azure. The secret contains the credentials for a service principal with the Contributor role on the resource group containing the container app and container registry.
Create a service principal with the Contributor role on the resource group that contains the Azure App Service.
az ad sp create-for-rbac
--name --role contributor --scopes /subscriptions//resourceGroups/ --sdk-auth --output jsonCopy the JSON output from the command.
In the GitHub repository, navigate to Settings > Secrets > Actions and select New repository secret.
Enter AZURE_CREDENTIALS as the name and paste the contents of the JSON output as the value.
Select Add secret.
Under the same repository secrets add a new variable AZURE_APP_SERVICE_NAME to deploy to your Azure Web app. The value of this secret is the name of your Azure Web app e.g. my-web-app-name from the domain https://my-web-app-name.azurewebsites.net/
Once the secrets are configured, the GitHub Actions will be triggered for every code push to the repository. Alternatively, you can manually run the workflow by clicking on the "Run Workflow" button.
Once the deployment is complete, you will need to add an identity provider to authenticate your app.
⚠️ Note: Only one of the identity provider is required below.
We'll create two GitHub apps: one for testing locally and another for production.
New OAuth App https://github.com/settings/applications/newApplication name: AzureChatGPT DEV Environment
Homepage URL:http://localhost:3000/
Authorization callback URL:http://localhost:3000/api/auth/callback/github/New OAuth App https://github.com/settings/applications/newApplication name: AzureChatGPT Production
Homepage URL:https://YOUR-WEBSITE-NAME.azurewebsites.net/
Authorization callback URL:https://YOUR-WEBSITE-NAME.azurewebsites.net/api/auth/callback/github/⚠️ Once the apps are setup, ensure to update the environment variables locally and on Azure App Service.
# github OAuth app configuration
AUTH_GITHUB_ID=
AUTH_GITHUB_SECRET=New Registration https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/CreateApplicationBlade/quickStartType~/null/isMSAApp~/falseApplication name: AzureChatGPT DEV Environment
Supported account types: Accounts in this organizational directory only
Redirect URI Platform: Web
Redirect URI:http://localhost:3000/api/auth/callback/azure-ad/New Registration https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/CreateApplicationBlade/quickStartType~/null/isMSAApp~/falseApplication name: AzureChatGPT Production
Supported account types: Accounts in this organizational directory only
Redirect URI Platform: Web
Redirect URI:https://YOUR-WEBSITE-NAME.azurewebsites.net/api/auth/callback/azure-ad/⚠️ Once the apps are setup, ensure to update the environment variables locally and on Azure App Service.
# Azure AD OAuth app configuration
AZURE_AD_CLIENT_ID=
AZURE_AD_CLIENT_SECRET=
AZURE_AD_TENANT_ID=Below are the required environment variables
| App Setting | Value | Note |
|---|---|---|
| AZURE_OPENAI_API_KEY | API keys of your Azure OpenAI resource | |
| AZURE_OPENAI_API_INSTANCE_NAME | the name of your Azure OpenAI resource | |
| AZURE_OPENAI_API_DEPLOYMENT_NAME | The name of your model deployment | |
| AZURE_OPENAI_API_VERSION | 2023-03-15-preview | API version when using gpt chat |
| AUTH_GITHUB_ID | Client ID of your GitHub OAuth application | |
| AUTH_GITHUB_SECRET | Client Secret of your GitHub OAuth application | |
| NEXTAUTH_SECRET | Used to encrypt the NextAuth.js JWT, and to hash email verification tokens. This set by default as part of the deployment template | |
| NEXTAUTH_URL | Current webs hosting domain name with HTTP or HTTPS. This set by default as part of the deployment template qweqweqwe | |
| AZURE_COSMOSEDB_URI | URL of the Azure CosmosDB | |
| AZURE_COSMOSEDB_KEY | API Key for Azure Cosmos DB | |
| AZURE_AD_CLIENT_ID | The client id specific to the application | |
| AZURE_AD_CLIENT_SECRET | The client secret specific to the application | |
| AZURE_AD_TENANT_ID | The organisation Tenant ID |
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
暂无开放 Issues,或尚未同步最近议题。