Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Chat app is a reference application that demonstrates how to use the Azure OpenAI service. Each programming language reference architecture provides slightly different functionality. This article describes how to use the JavaScript frontend with the Python backend.
By mixing and matching the frontend and backend, you can create a multi-language application that uses the best of both worlds.
- Demo - Configure JavaScript frontend with Python backend video
This article is part of a collection of articles that show you how to build a chat app using Azure OpenAI Service and Azure AI Search. Other articles in the collection include:
Note
This article uses one or more AI app templates as the basis for the examples and guidance in the article. AI app templates provide you with well-maintained, easy to deploy reference implementations that help to ensure a high-quality starting point for your AI apps.
Prerequisites
Deploy the two reference architectures using the following articles. Make sure to use the same subscription and region for both deployments. The deployment might take up to 20 minutes. Leave the deployments up; don't complete the Clean-up resources section until you're done with this article.
Get the URLs for the frontend and backend
After you deploy the two reference architectures, you have two full-stack apps. To connect the JavaScript frontend with the Python backend, get the URLs for both apps and configure them.
You should have each repo in a separate development environment, either locally or in Codespaces.
Set JavaScript front-end URL in Python backend
In the JavaScript development environment, get the URL for the JavaScript frontend by running the following command:
azd env get-values | grep WEBAPP_URIThis command gets all the cloud environment variables and filters for the
WEBAPP_URIvariable. Make sure the URL doesn't end with a slash,/.Copy the URL.
In the Python development environment, set the URL for the JavaScript frontend by running the following command:
azd env set ALLOWED_ORIGIN <FRONTEND-URL>In the Python development environment, redeploy the Python backend by running the following command:
azd up
Set Python backend URL in JavaScript frontend
In the Python development environment, get the URL for the Python backend by running the following command:
azd env get-values | grep BACKEND_URIThis command gets all the cloud environment variables and filters for the
BACKEND_URIvariable. Make sure the URL doesn't end with a slash,/.Copy the URL.
In the JavaScript development environment, set the URL for the Python backend by running the following command:
azd env set BACKEND_URI <BACKEND_URI>In the Python development environment, redeploy the Python backend by running the following command in the Python development environment:
azd up
Use the JavaScript frontend with the Python backend
The Python app uses an HR benefits subject area while the JavaScript app uses a real estate subject area. Now that the apps are connected, you can use the front-end to ask about HR benefits. Suggested questions include:
- What is included in my Northwind Health Plus plan that isn't standard?
- What happens in a performance review?
- What does a Product Manager do?
Clean-up resources
When you're done with the apps, you can delete the resources to avoid incurring more charges.
- Delete the JavaScript app with these instructions
- Delete the Python app with these instructions
Troubleshooting
- If you get an error, make sure the URLs you entered in the environment don't end with a slash,
/.
Next steps
- Build a chat app with Azure OpenAI best practice solution architecture
- Access control in Generative AI Apps with Azure AI Search
- Build an Enterprise ready OpenAI solution with Azure API Management
- Outperforming vector search with hybrid retrieval and ranking capabilities
- Learn more about how the Azure Developer CLI (AZD) is used in this template: