GithubHelp home page GithubHelp logo

astronomer / ask-astro Goto Github PK

View Code? Open in Web Editor NEW
161.0 9.0 37.0 75.18 MB

An end-to-end LLM reference implementation providing a Q&A interface for Airflow and Astronomer

Home Page: https://ask.astronomer.io/

License: Apache License 2.0

JavaScript 0.84% HTML 0.12% CSS 1.64% Svelte 11.60% TypeScript 3.38% Dockerfile 0.27% Python 80.26% Jinja 1.90%
airflow astronomer llm llm-ops

ask-astro's Introduction


Ask Astro is an open-source reference implementation of Andreessen Horowitz's LLM Application Architecture built by Astronomer. It provides an end-to-end example of a Q&A LLM application used to answer questions about Apache Airflow and Astronomer, including:

  • Airflow DAGs for data ingestion from various sources to a vector database
  • An API containing the business logic of taking a user's prompt and ultimately generating a response
  • A Slack bot that exposes Ask Astro in Slack workspaces
  • A UI that exposes Ask Astro to the public
  • Airflow DAGs that process user feedback and generate AI feedback on questions and answers

These are generally divided into three categories: data retrieval & embedding, prompt orchestration, and feedback loops. The rest of this README contains more in-depth detail on each of the categories in advance of a series of blog posts that will be written about the topics.

If you have any questions, feedback, or want to share similar use cases, reach out to [email protected].

Data Retrieval & Embedding

In order to make the responses as factual and accurate as possible, it's generally best practice to use Retrieval Augmented Generation (RAG). However, in order for RAG to be effective, a vector database needs to be populated with the most up-to-date and relevant information.

Ask Astro uses a set of Airflow DAGs that: ingest data from a source via an API or Python library, preprocesses and splits the data into smaller chunks, embeds those chunks, and writes the embeddings to Weaviate. As of today, Ask Astro retrieves data from the following sources:

Generally, each of these sources has a DAG that handles the ingestion flow. We use LangChain's built-in text splitters for processing Markdown, RST, and Python code into smaller chunks to ensure each document is small enough to give accurate results when doing embeddings. We then use a Weaviate provider that we've built (and plan to publish) to both embed and store each document as a vector in Weaviate using OpenAI's embedding model.

In addition to the individual DAGs per source, we have one DAG to do full-database refreshes based on a baseline of all data. The first time the ask-astro-load-bulk DAG runs it saves extracted documents in parquet files for a point-in-time baseline. This baseline allows us to experiment with new vector databases, embedding models, chunking strategies, etc. much more quickly.

See the Ingest README for details on configuring ingest with sources and connection details.

Prompt Orchestration

Ask Astro uses LangChain's ConversationalRetrievalChain to generate a response. This chain does the following:

  1. Use an LLM to generate 3 variations of the original user prompt with different wording. This is to ensure we retrieve as much helpful context as possible from our vector database
  2. Embed each of the prompts with OpenAI's embeddings model
  3. Retrieve documents from Weaviate using the embedded vectors from each prompt
  4. Combine the original user prompt with relevant sources found from the vector database, and make an LLM call to generate an answer

This generally works well. For prompt rewording, we use gpt-3.5-turbo, which runs very quickly and inexpensively. For the actual user-facing answer generation, we use gpt-4 to ensure high quality answers.

Feedback Loops

Airflow is critical in improving model performance over time. Feedback on answers come from two places:

  • End users can explicitly supply feedback by rating an answer as correct or incorrect
  • LLMs rate each question and answer according to it's "helpfulness", "publicness", and "on-topicness"

If a user provides feedback that the answer is correct, and the LLM rates the answer as helpful, public, and on-topic, Ask Astro (1) marks the answer as a good example to be displayed on the Ask Astro homepage for users to derive inspiration from, and (2) writes the question and answer back to Weaviate as a potential source to be used in future prompts. This way, there's a continuous feedback loop to constantly improve the model over time.

Future Exploration

A project like Ask Astro is never "complete", and there are always more methods and use cases to explore. Further exploration in Ask Astro (and more generally, in using Airflow for LLM operations) may come from the following areas:

  • Data Privacy & Private Context: can the model be supplemented with customer-specific data to provide more accurate, contextual answers?
  • Fine Tuning: are there any performance or accuracy improvements that come from fine tuning a model?
  • Semantic Caching: if there are two similar questions asked to Ask Astro, can we avoid expensive gpt-4 calls?
  • Feedback Loops: what else can we do with information about the accuracy of answers? For example, can we infer source usefulness based on how frequently (or infrequently) a source is used in accurate answers?
  • Experimentation: how do we effectively experiment and measure accuracy or performance improvements as a result of experiments?
  • LLM Operations and Observability: how do we ensure we have good visibility into what the model's doing, particularly given that it's making multiple API & LLM calls?

Local dev env

You can use local dev script to start UI, API server and API

python3 scripts/local_dev.py run-api-server # To run backend
python3 scripts/local_dev.py run-ui         # To run UI
python3 scripts/local_dev.py run-airflow    # To run Airflow

Backend API sever

User Interface

Apache Airflow

Deployment

The following sections describe how to deploy the various components of Ask Astro.

Backend API

User Interface

Apache Airflow

Slackbot

ask-astro's People

Contributors

carterjfulcher avatar davidgxue avatar dependabot[bot] avatar jlaneve avatar katiebrady-astro avatar kaxil avatar lee-w avatar lzdanski avatar mpgreg avatar pankajastro avatar pankajkoti avatar phanikumv avatar sunank200 avatar venkatajagannath avatar weaviate-git-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ask-astro's Issues

Modify Cloud Build Configuration for Tagged Release and Separate Production/Development Environments

  • Add deployment story for Ask-Astro.
  • Modify the Cloud Build configuration to build and deploy only when a tagged release is pushed to GitHub and to separate the setup for production and development environments.

Steps to Implement:

Create distinct Cloud Build configuration files for production and development, named cloudbuild-prod.yaml and cloudbuild-dev.yaml respectively.

Configure GitHub triggers for tagged releases in both configurations, ensuring they correspond to their respective environments.

Implement conditional logic within each configuration file to determine whether a build and deployment should proceed based on branch and tag information.

Outcome:

  • This setup ensures that builds and deployments are initiated solely when tagged releases are pushed to GitHub. The correct configuration file is automatically selected based on the activated trigger, allowing environment-specific substitutions and configurations to be applied.

Additional Context:

This change enhances deployment control and separates production and development workflows, improving overall project management.

Implement CircleCI Configuration for Testing and Pre-commit Hooks for Ask-Astro

Objective: Integrate CircleCI into the project for enhanced automation and code quality.

Tasks:

  • Set up CircleCI configuration.
  • Implement CI pipeline for running tests.
  • Configure CI to execute pre-commit hooks for linting, type-checking, ruff, and black formatting.

Benefits: Improve code reliability, maintainability, and streamline development processes.

Setup sphinx documentation

  • Initialize sphinx project structure under docs
  • Consolidate current documentation and move them into docs to reduce duplication
  • Make pyinvoke tasks for building and serving documentation

Documentation for steps when Ask-Astro is down

Currently, there is documentation around the setup and the repository but there is no documentation for steps when Ask-Astro is down:

  • Add a step-by-step guide for how to debug the issue.
  • Add a step-by-step guide around how to roll back the deployment.
  • Add a step-by-step guide to actions to be taken when the slack bot UI or backend is down.
  • Add POC for each component in the notion doc.

Migrate Firestore Database Between GCP Accounts (from CSE Dev to Ask-Astro)

Description:
Migrate Firestore database from one GCP account to another. Proposed solution: Export data from the source Firestore, transfer it to the destination GCP account's GCS bucket, and import into the destination Firestore. Steps and detailed guide in the comments.

Steps:

  1. Export data from the source Firestore.
  2. Transfer data to the destination GCP account's GCS bucket.
  3. Import data into the destination Firestore.

Acceptance Criteria:

  • Backup old firestore data
  • Firestore data successfully migrated to the destination GCP account.
  • Detailed migration steps documented in comments.
  • Migration process tested and validated.
  • No data loss during migration.
  • Documentation updated to reflect the migration process.

Migrate the ask-astro project to new GCP account

  • Migrate the Firestore.
  • Create separate dev and prod cloud build.
  • Add cloud build and cloud run for new account.
  • Integrate both deployments to cloud flare.
  • Run prod with new GCP account and dev with CSE -dev account

User testing for the existing Slack bot implementation

Currently, we have not done user testing for the current Slack bot implementation. This is critical before the release of Phase - 2.

  • User testing for Slack bot
    • Identify the issues and bugs with the workflow.
    • Create the issue with a proper description.
    • Create a test plan.
    • Coordinate with Steven and @pgagnon for this and create required issues on ask-astro GitHub repo.

Separate the weaviate and DAGS for dev to prod account

  • Separate the prod and dev for ingestion and feedback DAGs.
  • Work on running ingestion and feedback DAGs with weaviate in dev.
  • Change the credentials in prod and dev for cloud build accordingly.
  • Migrate older prod to new weaviate account. Make older dev as dev database and new account as prod database

Add CI job to deploy DAG

currently, looks like we do not have automation to sync the astro prod/dev instance dag with main branch. I feel we should add a CI job for the same

Code samples from Learn Docs are shown as sources with a non-existent link

When Ask Astro shows a Source that is from the code-samples folder (retrieved from https://github.com/astronomer/docs/blob/main/code-samples/dags) in the Astronomer Docs repo it shows a link to the docs.astronomer page like this https://docs.astronomer.io/code-samples/dags/.... These code samples are embedded in other docs on the page and not accessible through that link.

Solution proposed in #16 :
create an extra case for the URL prefix and link to the DAG code in the GitHub repo.

Improve response times

Right now the median response time is about 15s and P90 is around 40s. We should aim for a median of 10s or less, and P90 of 20s.
Priority: P1 (should have for Phase 2)

Get access for all the permission for cloud providers

Integrate Ask-astro prod and Ask-Astro dev with Langsmith

  • Integrate Ask-astro prod slackbot with Langsmith
  • Integrate Ask-Astro dev slackbot with Langsmith
  • Document the change.
  • Create a separate project for dev
  • Debug why sending through slack cannot generate correct result on Langsmith

Enhance Local Development for Ask-Astro Project

Objective: Improve the local development experience for the Ask-Astro project.

Tasks:

  • Add a comprehensive local development guide to the project documentation.
  • Update the README file to reflect the changes and provide clear instructions.
  • Configure and run the Slack app locally using ngrok with the correct settings for efficient testing and debugging.

Outcome: A streamlined local development process that contributes to project efficiency and ease of contribution.

Ask Astro || Incorrect response for query: Tell me how can I check task logs with airflow CLI

In Airflow CLI we do not have any logs command in tasks, and the response is totally incorrect

Response i have received from Ask Astro

To check task logs with the Airflow CLI, you will need to use the Airflow tasks logs command. Here is the basic syntax:
airflow tasks logs -A -t [task_id] [dag_id] [execution_date]
• Replace [task_id] with the ID of the task you want to view logs for.
• Replace [dag_id] with the ID of the DAG that the…
See more

Add/Update documentation

  • Get issues created for documentation.
  • Work on documentation to create guide for end to end deployment process.

Implement some observability/monitoring part-2

As part of our observability and monitoring effort, we want to set up the monitoring for the following components apart from this issue:

  • Explore and set up the monitoring for backend APIs. This should ping the APIs every 5 minutes and post a notification on Slack if the APIs are down with a relevant response.
  • Slack bot monitoring
  • Page on GitHub on what kind of observation metrics/actions are needed.

More details around this can be found #39 (comment)

Code clean up

  • Code clean up for Ask-Astro
  • Remove unnecessary comments.
  • Run pre-commits and fix.
  • Rewrite and fix custom logics.

consolidate to azure endpoint

Original ingest was using OpenAI and frontend app was using Azure OpenAI. Need to consolidate to azure.
-update schema
-update keys
-test

Setup and run Ask-Astro end to end

  • Setup and run Ask Astro end to end using local dev story.
  • Use ngrok to build slack locally.
  • Create a personal Slack bot and run Ask-Astro.
  • Please outline the changes required to the slack bot for the Ask Astro channel on OSS airflow and create corresponding smaller issues if needed.

Setup readthedocs

Please describe the feature you'd like to see
build docs and publish to readthedocs

Describe the solution you'd like

Are there any alternatives to this feature?

Additional context

Acceptance Criteria

  • All checks and tests in the CI should pass
  • Unit tests
  • Integration tests (if the feature relates to a new database or external service)
  • Example DAG
  • Docstrings in reStructuredText for each of methods, classes, functions and module-level attributes (including Example DAG on how it should be used)
  • Exception handling in case of errors
  • Logging (are we exposing useful information to the user? e.g. source and destination)
  • Improve the documentation (README, Sphinx, and any other relevant)
  • How to use Guide for the feature (example)

Don't ask for feedback when Ask Astro hits an error

Describe the bug
We shouldn't be asking the user for feedback if Ask Astro hits an error. It's pretty clear the answer isn't correct :)

Expected behavior
Hide the feedback mechanism if we've hit an error.

Screenshots
Screenshot 2023-11-08 at 7 35 44 AM

Add filter to block non Airflow or astro related questions

Message from Slack: Since we are talking about AskAstro I already have a Feedback. I’ve seen that you are using langchain and probably a filter step to block questions non related to Astro. For most of them it is working well (sorry for doing some QA I couldn’t avoid it), but for others it isn’t (check the picture). Make sure to a have throttling limit otherwise someone can exploit the website to use ChatGPT through your services and you can be surprised by the OpenAI bill

More at: https://astronomer.slack.com/archives/C061ZEF3NP9/p1698147033409819?thread_ts=1698146233.559039&cid=C061ZEF3NP9

Setup nightly slack ingest

Current bulk and incremental dags only ingest from slack archives. Need to get a slack token and setup nightly incremental ingest.

Use a single Slack App for internal, customer and Airflow OSS Slack workspace

Currently, we have 2 Slack apps. One that's installed in Airflow OSS Slack. And the other that is installed in Astronomer workspace that is getting used for our internal and customer channels use. Both the apps point to different backends. The one that is the currently installed Slack app in Airflow OSS points is the newer one which we would like to be used as a common backend in all places.

Evaluate how we can unify the app experience to use a single service backend for a consistent experience.

Monitor and maintain user feedback

As one way to measure response accuracy, we should monitor user feedback and aim to maintain current levels of positive feedback. (Using the existing LangSmith integration to do this is acceptable.)
Priority: P0 (must have for Phase 2)

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.