Giter VIP home page Giter VIP logo

union-rag-demo's Introduction

Union RAG

UnionAI-native RAG applications.

Note

If you're here for the LLM RAG workshop, go here.

Setup

conda create -n union-rag python=3.11 -y
pip install -r requirements.txt

Run the Union RAG Workflow

For quick iteration and development, you can run the workflow on Union with:

unionai run --copy-all --remote union_rag/langchain.py ask --question 'what is flytekit?'

Workflow Deployment

Deploy the workflow to Union with the following command:

unionai register union_rag/langchain.py

Slack App Deployment

Install sam cli.

We'll use bolt to create a slack bot and sam cli to deploy a lambda function that will serve as one of the backend layers for our question-answering slackbot.

  1. Follow the Bolt getting started guide to create a slack app.

    • Follow the instructions to create a SLACK_BOT_TOKEN and SLACK_SIGNING_SECRET.
    • Create a UNIONAI_SERVERLESS_API_KEY using unionai create app union-rag
  2. Create a secrets.txt file to store these credentials. This file is ignored by git and should look something like this:

    SLACK_BOT_TOKEN=<SLACK_BOT_TOKEN>
    SLACK_SIGNING_SECRET=<SLACK_SIGNING_SECRET>
    UNIONAI_SERVERLESS_API_KEY=<UNIONAI_SERVERLESS_API_KEY>
    
  3. Export the secrets to your environment:

    export $(cat secrets.txt | xargs)
  4. Create the deploy.yaml file:

    cat template.yaml | envsubst > deploy.yaml
    
  5. Make sure your ~/.aws/credentials file is properly configured with your aws_access_key_id and aws_secret_access_key.

  6. Login to AWS ECR. First do aws configure sso, then:

    aws sso login --profile <PROFILE>
  7. Run sam build --template deploy.yaml to build the app.

  8. Run sam deploy --guided to deploy the app to AWS. This will ask you a series of questions on specific values you want to use for the deployment. In the end you should see an output like this:

    CloudFormation outputs from deployed stack
    -----------------------------------------------------------------------------------------------------------------
    Outputs
    -----------------------------------------------------------------------------------------------------------------
    Key                 UnionRagApi
    Description         API Gateway endpoint URL for Prod stage for union rag function
    Value               https://xyz.execute-api.us-east-2.amazonaws.com/Prod/
    
    Key                 UnionRagFunctionIamRole
    Description         Implicit IAM Role created for union rag function
    Value               arn:aws:iam::xyz:role/union-rag-UnionRagFunctionRole-xyz
    
    Key                 UnionRagFunction
    Description         union rag Lambda Function ARN
    Value               arn:aws:lambda:us-east-2:xyz:function:union-rag-UnionRagFunction-xyz
    -----------------------------------------------------------------------------------------------------------------
    
    Successfully created/updated stack - union-rag in us-east-2
    
  9. Now test your slack app by installing it in your slack workspace and typing @flyte-attendant what is flytekit?. You should see an initial response from the bot, followed by the answer to your question.

union-rag-demo's People

Contributors

cosmicbboy 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.