Git Product home page Git Product logo

js-popular-repos / azure-openai-chat-frontend Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure-samples/azure-openai-chat-frontend

0.0 0.0 0.0 137 KB

The Chat App Protocol compliant user-interface building block, for your chat-gpt like RAG pattern applications built with Azure OpenAI and Azure AI Search.

License: MIT License

Shell 0.18% JavaScript 3.78% TypeScript 88.55% HTML 2.55% Bicep 4.94%

azure-openai-chat-frontend's Introduction

Azure OpenAI Chat Frontend

This folder contains a Lit implementation, consisting of multiple LitElements that can be used to interact with the Azure OpenAI API.

It is a classic chat UI that can be used to send messages to the API and receive responses.

Technical stack

The following technologies are part of the frontend application:

User interface demo

The following video shows the user interface. Styles are fully configurable!

chatfrontendAI.mp4

Configuration

The frontend application is configured using a global configuration file. You can enable or disable the default prompts, and configure the default prompt texts, the API endpoint and other settings.

All texts and labels are configurable to match your use case. To customize the texts, please edit the global config file.

Running the application

To run the application locally, you must install Node.js LTS and make sure you can run npm commands from your terminal.

Then you can proceed by following these steps:

  • To install all npm dependencies, please run npm install. This is a npm workspace, so all dependencies will be installed in the root folder.
  • To start the local development server, open a new terminal and run npm run start. This will start the local development server on port 8000.
  • To build the application, open a new terminal and run npm run build. This will generate a production build in the dist folder.

[IMPORTANT] For the application to be functional, you will need to connect it to a locally running or remotely deployed backend service, and make sure that the data attribute data-api-url is pointing to the correct endpoint.

Connecting to a deployed backend

The Search API service implements the HTTP protocol for AI chat apps. It can be used with any backend service that implements the same protocol.

Recommended backend repos Development environment
Property rental domain with Node.js Open in GitHub Codespaces
Example question: What is the refund policy
Employee benefits with Python Open in GitHub Codespaces
Example question: What is included in my Northwind Health Plus plan that is not in standard?
Employee benefits with .NET and C# Open in GitHub Codespaces
Example question: What is included in my Northwind Health Plus plan that is not in standard?

To connect to a backend, follow these steps:

  1. Deploy the backend services as explained in their respective repository readme files, for example following these steps to deploy the backend.
  2. Once the backend service is fully deployed, get the backend URL with azd env get-values | grep BACKEND_URI.
  3. Deploy the frontend application to Azure as explained here or start it locally or in Codespaces.
  4. Set the backend URL in this repo, running azd env set BACKEND_URI <your_backend_url> that you got in step 2.
  5. Depending on whether you want to use the deployed frontend app or the local frontend app:
  • If you want to use the deployed frontend app, run azd up to redeploy.

  • If you want to use the local frontend app on your machine or in Codespaces, run:

    # Export the environment variable.
    # The syntax may be different depending on your shell or if you're using Windows.
    export BACKEND_URI=<your_backend_url>
    
    # Start the app
    npm start

[NOTE] You may need to enable CORS in your backend service, by running azd env set ALLOWED_ORIGIN <your_frontend_url> then deploy again with azd up.

Get the frontend URL, following this table:

Environment URL
Local http://localhost:8000
Production azd env get-values | grep FRONTEND_URI
Codespace https://<your_codespace_base_url>-8000.app.github.dev

Using this module as a library

If you want to use the module as a library as it is used in the JavaScript sample, set the environment variable IS_LIB to true, running azd env set IS_LIB true.

Deploying the app to Azure Static Web Apps

To deploy this application code to Azure Static Web Apps you can use Azure Static Web Apps CLI or using the Azure Developer CLI, by running azd up and following the instruction in the terminal.

Security considerations

If you're deploying this sample to Azure Static Web Apps, using the Azure Developer CLI template, please consider enabling user authentication, following this guide.

Authenticating requests to the backend service, will need to be implemented in the backend service solution.

azure-openai-chat-frontend's People

Contributors

anfibiacreativa avatar microsoftopensource avatar manekinekko avatar diberry avatar jmatthiesen avatar microsoft-github-operations[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.