Giter Site home page Giter Site logo

nzthiago / azurefunctionsopenai-rag-assistant Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eamonoreilly/azurefunctionsopenai-rag-assistant

1.0 0.0 0.0 502 KB

A sample app using Azure Functions with Azure AI Search for RAG and Azure OpenAI models with assistants to power chat and Q&A experiences.

License: MIT License

Shell 1.94% C# 14.53% PowerShell 1.33% TypeScript 42.71% CSS 8.75% HTML 0.31% Bicep 30.44%

azurefunctionsopenai-rag-assistant's Introduction

Chat + Enterprise data with Azure OpenAI and Azure Functions

This demo is based on azure-search-openai-demo and uses a static web app for the frontend and Azure functions for the backend API's.

This solution uses the Azure Functions OpenAI triggers and binding extension for the backend capabilities. It includes:

  • Ability to upload text files from UI - Delivered by the embeddings and semantic search output bindings
  • Ask questions of the uploaded files - Enabled by the semantic search input binding
  • Create a chat session and interact with the OpenAI deployed model - Uses the Assistant bindings to interact wiht the OpenAI model and stores chat history in Azure storage tables automatically
  • In the chat session, ask the LLM to store reminders and then later retrieve them. This capability is delivered by the AssistantSkills trigger in the OpenAI extension for Azure Functions
  • Create Azure functions in different programming language e.g. (C#, Node, Python, Java, PowerShell) and easily replace using config file
  • Static web page is configured with AAD auth by default

High Level Overview of components

Getting Started

IMPORTANT: In order to deploy and run this example, you'll need an Azure subscription with access enabled for the Azure OpenAI service. You can request access here. You can also visit here to get some free Azure credits to get you started.

AZURE RESOURCE COSTS by default this sample will create Azure App Service and Azure AI Search resources that have a monthly cost. You can switch them to free versions of each of them if you want to avoid this cost by changing the parameters file under the infra folder (though there are some limits to consider; for example, you can have up to 1 free AI Search resource per subscription.)

Prerequisites

To Run Locally

NOTE: Your Azure Account must have Microsoft.Authorization/roleAssignments/write permissions, such as User Access Administrator or Owner.

Installation

Project Initialization

  1. Create a new folder and switch to it in the terminal
  2. Run azd login
  3. Run az account set --subscription "<your target subscription>"
  4. Run azd init
    • For the target location, the regions that currently support the models used in this sample are East US or South Central US. For an up-to-date list of regions and models, check here. Make sure that all the intended services for this deployment have availability in your targeted regions.

Starting from scratch

Execute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.

  1. Run azd up - This will provision Azure resources and deploy this sample to those resources
  2. After the application has been successfully deployed you will see a URL printed to the console. Click that URL to interact with the application in your browser.

NOTE: It may take a minute for the application to be fully deployed.

Use existing resources

  1. Run azd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}
  2. Run azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}
  3. Run azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT {Name of existing ChatGPT deployment}. Only needed if your ChatGPT deployment is not the default 'chat'.
  4. Run azd env set AZURE_OPENAI_GPT_DEPLOYMENT {Name of existing GPT deployment}. Only needed if your ChatGPT deployment is not the default 'davinci'.
  5. Run azd up

NOTE: You can also use existing Search and Storage Accounts. See ./infra/main.parameters.json for list of environment variables to pass to azd env set to configure those existing resources.

Deploying or re-deploying a local clone of the repo

  • Simply run azd up

Quickstart

  • In Azure: navigate to the Azure WebApp deployed by azd. The URL is printed out when azd completes (as "Endpoint"), or you can find it in the Azure portal.
  • Running locally: navigate to 127.0.0.1:5000

Once in the web app:

  • Try different topics in chat or Q&A context. For chat, try follow up questions, clarifications, ask to simplify or elaborate on answer, etc.
  • Explore citations and sources
  • Click on "settings" to try different options, tweak prompts, etc.

Resources

How to purge aad auth

To remove your data from Azure Static Web Apps, go to https://identity.azurestaticapps.net/.auth/purge/aad

Upload files failures

Currently only text files are supported.

Azure Functions troubleshooting

Go to Application Insights and go to the Live metrics view to see real time telemtry information. Optionally, go to Application Insights and select Logs and view the traces table

azurefunctionsopenai-rag-assistant's People

Contributors

lordlinus avatar eamonoreilly avatar paulyuk avatar nzthiago avatar fjmeneses avatar

Stargazers

 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.