- Notifications
You must be signed in to change notification settings - Fork0
License
HassanFad/chat-copilot
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
NOTE: This is asample application to help you understand how Semantic Kernel and AI can work in Web Applications. This sample isNOT FOR PRODUCTION deployments.
This sample allows you to build your own integrated large language model (LLM) chat copilot. The sample is built on MicrosoftSemantic Kernel and has three components:
- A frontend applicationReact web app
- A backend REST API.NET web API service
- A.NET worker service for processing semantic memory.
These quick-start instructions run the sample locally. They can also be found on the official Chat Copilot Microsoft Learn documentation page forgetting started.
To deploy the sample to Azure, please viewDeploying Chat Copilot after meeting therequirements described below.
IMPORTANT: This sample is for educational purposes only and is not recommended for production deployments.
IMPORTANT: Each chat interaction will call Azure OpenAI/OpenAI which will use tokens that you may be billed for.
You will need the following items to run the sample:
- .NET 7.0 SDK(via Setup install.* script)
- Node.js(via Setup install.* script)
- Yarn(via Setup install.* script)
- Git
- AI Service (one of the following is required)
| AI Service | Requirement |
|---|---|
| Azure OpenAI | -Access -Resource -Deployed models ( gpt-35-turbo andtext-embedding-ada-002)-Endpoint -API key |
| OpenAI | -Account -API key |
Open PowerShell as an administrator.
NOTE: Ensure that you havePowerShell Core 6+ installed. This is different from the default PowerShell installed on Windows.
Clone this repository
git clone https://github.com/microsoft/chat-copilot
Setup your environment.
The following is a script to help you install the dependencies required. Feel free to install
dotnet,nodejs, andyarnwith your method of choice or use this script.cd<path to chat-copilot>\scripts\.\Install.ps1
NOTE: This script will install
Chocolatey,dotnet-7.0-sdk,nodejs, andyarn.NOTE: If you receive an error that the script is not digitally signed or cannot execute on the system, you may need tochange the execution policy (see list ofpolicies andscopes) orunblock the script.
Configure Chat Copilot.
.\Configure.ps1-AIService {AI_SERVICE}-APIKey {API_KEY}-Endpoint {AZURE_OPENAI_ENDPOINT}
AI_SERVICE:AzureOpenAIorOpenAI.API_KEY: TheAPI keyfor Azure OpenAI or for OpenAI.AZURE_OPENAI_ENDPOINT: The Azure OpenAI resourceEndpointaddress. This is only required when using Azure OpenAI, omit-Endpointif using OpenAI.IMPORTANT: For
AzureOpenAI, if you deployed modelsgpt-35-turboandtext-embedding-ada-002with custom names (instead of the default names), also use the parameters:-CompletionModel {DEPLOYMENT_NAME}-EmbeddingModel {DEPLOYMENT_NAME}-PlannerModel {DEPLOYMENT_NAME}
-PlannerModel name will be the same as -CompletionModel
Open the
.\Configure.ps1script to see all of the available parameters.
Run Chat Copilot locally. This step starts both the backend API and frontend application.
.\Start.ps1
It may take a few minutes for Yarn packages to install on the first run.
NOTE: Confirm pop-ups are not blocked and you are logged in with the same account used to register the application.
(Optional) To start ONLY the backend:
.\Start-Backend.ps1
Open Bash as an Administrator.
Clone this repository
git clone https://github.com/microsoft/chat-copilot
Configure environment.
The following is a script to help you install the dependencies required. Feel free to install
dotnet,nodejs, andyarnwith your method of choice or use this script.cd<path to chat-copilot>/scripts/
Ubuntu/Debian Linux
./install-apt.sh
NOTE: This script uses
aptto installdotnet-sdk-7.0,nodejs, andyarn.macOS
./install-brew.sh
NOTE: This script uses
homebrewto installdotnet-sdk,nodejs, andyarn.Configure Chat Copilot.
For OpenAI
./configure.sh --aiservice OpenAI --apikey {API_KEY}API_KEY: TheAPI keyfor OpenAI.
For Azure OpenAI
./configure.sh --aiservice AzureOpenAI \ --endpoint {AZURE_OPENAI_ENDPOINT} \ --apikey {API_KEY}AZURE_OPENAI_ENDPOINT: The Azure OpenAI resourceEndpointaddress.API_KEY: TheAPI keyfor Azure OpenAI.
IMPORTANT: If you deployed models
gpt-35-turboandtext-embedding-ada-002with custom names (instead of the default names), you need to specifythe deployment names with three additional parameters:./configure.sh --aiservice AzureOpenAI \ --endpoint {AZURE_OPENAI_ENDPOINT} \ --apikey {API_KEY} \ --completionmodel {DEPLOYMENT_NAME} \ --plannermodel {DEPLOYMENT_NAME} \ --embeddingmodel {DEPLOYMENT_NAME}--plannermodelwill be the same name as--completionmodel
Run Chat Copilot locally. This step starts both the backend API and frontend application.
./start.sh
It may take a few minutes for Yarn packages to install on the first run.
NOTE: Confirm pop-ups are not blocked and you are logged in with the same account used to register the application.
(Optional) To start ONLY the backend:
./start-backend.sh
(Optional) Run thememory pipeline
By default, the webapi is configured to work without the memory pipeline for synchronous processing documents. To enable asynchronous document processing, you need to configure the webapi and the memory pipeline. Please refer to thewebapi README and thememory pipeline README for more information.
By default, Chat Copilot runs locally without authentication, using a guest user profile. If you want to enable authentication with Azure Active Directory, follow the steps below.
Create anapplication registration for the frontend web app, using the values below
Supported account types: "Accounts in this organizational directory only ({YOUR TENANT} only - Single tenant)"Redirect URI (optional):Single-page application (SPA) and usehttp://localhost:3000.
Create a secondapplication registration for the backend web api, using the values below:
Supported account types: "Accounts in this organizational directory only ({YOUR TENANT} only - Single tenant)"- Donot configure a
Redirect URI (optional)
NOTE: Other account types can be used to allow multitenant and personal Microsoft accounts to use your application if you desire. Doing so may result in more users and therefore higher costs.
Take note of the
Application (client) IDfor both app registrations as you will need them in future steps.
Expose an API within the second app registration
SelectExpose an API from the menu
Add anApplication ID URI
This will generate an
api://URIClickSave to store the generated URI
Add a scope for
access_as_userClickAdd scope
SetScope name to
access_as_userSetWho can consent toAdmins and users
SetAdmin consent display name andUser consent display name to
Access copilot chat as a userSetAdmin consent description andUser consent description to
Allows the accesses to the Copilot chat web API as a user
Add the web app frontend as an authorized client application
ClickAdd a client application
ForClient ID, enter the frontend's application (client) ID
Check the checkbox underAuthorized scopes
ClickAdd application
Add permissions to web app frontend to access web api as user
Open app registration for web app frontend
Go toAPI Permissions
ClickAdd a permission
Select the tabAPIs my organization uses
Choose the app registration representing the web api backend
Select permissions
access_as_userClickAdd permissions
Run the Configure script with additional parameters to set up authentication.
Powershell
.\Configure.ps1-AiService {AI_SERVICE}-APIKey {API_KEY}-Endpoint {AZURE_OPENAI_ENDPOINT}-FrontendClientId {FRONTEND_APPLICATION_ID}-BackendClientId {BACKEND_APPLICATION_ID}-TenantId {TENANT_ID}-Instance {AZURE_AD_INSTANCE}
Bash
./configure.sh --aiservice {AI_SERVICE} --apikey {API_KEY} --endpoint {AZURE_OPENAI_ENDPOINT} --frontend-clientid {FRONTEND_APPLICATION_ID} --backend-clientid {BACKEND_APPLICATION_ID} --tenantid {TENANT_ID} --instance {AZURE_AD_INSTANCE}AI_SERVICE:AzureOpenAIorOpenAI.API_KEY: TheAPI keyfor Azure OpenAI or for OpenAI.AZURE_OPENAI_ENDPOINT: The Azure OpenAI resourceEndpointaddress. This is only required when using Azure OpenAI, omit-Endpointif using OpenAI.FRONTEND_APPLICATION_ID: TheApplication (client) IDassociated with the application registration for the frontend.BACKEND_APPLICATION_ID: TheApplication (client) IDassociated with the application registration for the backend.TENANT_ID: Your Azure AD tenant IDAZURE_AD_INSTANCE(optional): The Azure AD cloud instance for the authenticating users. Defaults tohttps://login.microsoftonline.com.
Run Chat Copilot locally. This step starts both the backend API and frontend application.
Powershell
.\Start.ps1
Bash
./start.sh
Issue: Unable to load chats.
Details: interactionin_progress: Interaction is currently in progress.
Explanation: The WebApp can display this error when the application is configured for a different AAD tenant from the browser, (e.g., personal/MSA account vs work/school account).
Solution: Either use a private/incognito browser tab or clear your browser credentials/cookies. Confirm you are logged in with the same account used to register the application.
Issue:: Challenges using text completion models, such as
text-davinci-003Solution: For OpenAI, seemodel endpoint compatibility forthe complete list of current models supporting chat completions. For Azure OpenAI, seemodel summary table and region availability.
Issue: Localhost SSL certificate errors / CORS errors
Explanation: Your browser may be blocking the frontend access to the backend while waiting for your permission to connect.
Solution:
- Confirm the backend service is running. Open a web browser and navigate to
https://localhost:40443/healthz- You should see a confirmation message:
Healthy - If your browser asks you to acknowledge the risks of visiting an insecure website, you must acknowledge this before the frontend can connect to the backend server.
- You should see a confirmation message:
- Navigate to
http://localhost:3000or refresh the page to use the Chat Copilot application.
- Confirm the backend service is running. Open a web browser and navigate to
Issue: Yarn is not working.
Explanation: You may have the wrong Yarn version installed such as v2.x+.
Solution: Use the classic version.
npm install -g yarnyarnset version classicIssue: Missing
/usr/share/dotnet/host/fxrfolder.Details: "A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist" when running dotnet commands on Linux.
Explanation: When .NET (Core) was first released for Linux, it was not yet available in the official Ubuntu repo. So instead, many of us added the Microsoft APT repo in order to install it. Now, the packages are part of the Ubuntu repo, and they are conflicting with the Microsoft packages. This error is a result of mixed packages. (Source: StackOverflow)
Solution:
# Remove all existing packages to get to a clean state:sudo apt remove --assume-yes dotnet*;sudo apt remove --assume-yes aspnetcore*;sudo apt remove --assume-yes netstandard*;# Set the Microsoft package provider priorityecho -e"Package: *\nPin: origin\"packages.microsoft.com\"\nPin-Priority: 1001"| sudo tee /etc/apt/preferences.d/99microsoft-dotnet.pref;# Update and install dotnetsudo apt update;sudo apt install --assume-yes dotnet-sdk-7.0;
Every release is associated with a release branch. For instance, releasev0.9 is on a branch called0.9.Once a release is out, its branch will no longer be updated. The exception to this is the latest release branch, which will only receive bug fixes.This is to provide some stability to those for whom breaking changes and being on the bleeding edge (with the bugs it can entail) is not a desirable option.
If you would like to learn more about Semantic Kernel and AI, you may also be interested in other repos the Semantic Kernel team supports:
| Repo | Description |
|---|---|
| Semantic Kernel | A lightweight SDK that integrates cutting-edge LLM technology quickly and easily into your apps. |
| Semantic Kernel Docs | The home for Semantic Kernel documentation that appears on the Microsoft learn site. |
| Semantic Kernel Starters | Starter projects for Semantic Kernel to make it easier to get started. |
| Semantic Memory | A service that allows you to create pipelines for ingesting, storing, and querying knowledge. |
We welcome your contributions and suggestions to the Chat Copilot Sample App! One of the easiestways to participate is to engage in discussions in the GitHub repository.Bug reports and fixes are welcome!
To learn more and get started:
- Read thedocumentation
- Join theDiscord community
- Contribute to the project
- Follow the team on ourblog
This project has adopted theMicrosoft Open Source Code of Conduct.For more information see theCode of Conduct FAQor contactopencode@microsoft.comwith any additional questions or comments.
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under theMIT license.
About
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Languages
- C#44.3%
- TypeScript43.8%
- Shell4.4%
- PowerShell3.6%
- Bicep3.3%
- Dockerfile0.4%
- Other0.2%

