Skip to content

Commit

Permalink
Merge pull request #3 from parea-ai/use-github-workflows
Browse files Browse the repository at this point in the history
Use GitHub workflows
  • Loading branch information
jalexanderII authored Jan 31, 2024
2 parents 0c097dc + 2d22f63 commit 3000675
Show file tree
Hide file tree
Showing 18 changed files with 6,725 additions and 288 deletions.
99 changes: 0 additions & 99 deletions .circleci/config.yml

This file was deleted.

5 changes: 1 addition & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
OPENAI_API_KEY=<insert OpenAI API key here>
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=<insert Langsmith API key here>
LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
LANGCHAIN_PROJECT="rag-demo"
PAREA_API_KEY=<insert Parea API key here>
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: build

on: [ push, pull_request ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.11" ]

steps:
- uses: actions/[email protected]
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry
run: make poetry-download

- name: Set up cache
uses: actions/[email protected]
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run style checks
run: |
make check-codestyle
# - name: Run tests
# run: |
# make test
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ cython_debug/
*.swp

.dccache
.DS_Store
.DS_Store
36 changes: 36 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
default_language_version:
python: python3.11

default_stages: [ commit, push ]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: LICENSE

- repo: local
hooks:
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py39-plus
types: [ python ]
language: system

- repo: local
hooks:
- id: isort
name: isort
entry: poetry run isort --settings-path pyproject.toml
types: [ python ]
language: system

- repo: local
hooks:
- id: black
name: black
entry: poetry run black --config pyproject.toml
types: [ python ]
language: system
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[MESSAGES CONTROL]
disable=line-too-long,no-member,too-few-public-methods,missing-function-docstring,missing-module-docstring
disable=line-too-long,no-member,too-few-public-methods,missing-function-docstring,missing-module-docstring
89 changes: 89 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#* Variables
SHELL := /usr/bin/env bash
PYTHON := python3
PYTHONPATH := `pwd`

#* Docker variables
VERSION := latest

#* Poetry
.PHONY: poetry-download
poetry-download:
curl -sSL https://install.python-poetry.org | $(PYTHON) -

.PHONY: poetry-remove
poetry-remove:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | $(PYTHON) - --uninstall

#* Installation
.PHONY: install
install:
poetry lock -n && poetry export --without-hashes > requirements.txt
poetry install -n
poetry run mypy --install-types --non-interactive ./

.PHONY: pre-commit-install
pre-commit-install:
poetry run pre-commit install

#* Formatters
.PHONY: codestyle
codestyle:
poetry run pyupgrade --exit-zero-even-if-changed --py39-plus **/*.py
poetry run isort --settings-path pyproject.toml ./
poetry run black --config pyproject.toml ./

.PHONY: formatting
formatting: codestyle

#* Linting
.PHONY: test
test:
PYTHONPATH=$(PYTHONPATH) poetry run pytest tests/test_chains.py

.PHONY: check-codestyle
check-codestyle:
poetry run isort --diff --check-only --settings-path pyproject.toml ./
poetry run black --diff --check --config pyproject.toml ./
poetry run darglint --verbosity 2 parea tests

.PHONY: mypy
mypy:
poetry run mypy --config-file pyproject.toml ./

.PHONY: lint
lint: test check-codestyle mypy

.PHONY: update-dev-deps
update-dev-deps:
poetry add -D bandit@latest darglint@latest "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest pylint@latest pytest@latest pyupgrade@latest safety@latest coverage@latest coverage-badge@latest pytest-html@latest pytest-cov@latest
poetry add -D --allow-prereleases black@latest


#* Cleaning
.PHONY: pycache-remove
pycache-remove:
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf

.PHONY: dsstore-remove
dsstore-remove:
find . | grep -E ".DS_Store" | xargs rm -rf

.PHONY: mypycache-remove
mypycache-remove:
find . | grep -E ".mypy_cache" | xargs rm -rf

.PHONY: ipynbcheckpoints-remove
ipynbcheckpoints-remove:
find . | grep -E ".ipynb_checkpoints" | xargs rm -rf

.PHONY: pytestcache-remove
pytestcache-remove:
find . | grep -E ".pytest_cache" | xargs rm -rf

.PHONY: build-remove
build-remove:
rm -rf build/

.PHONY: cleanup
cleanup: pycache-remove dsstore-remove mypycache-remove ipynbcheckpoints-remove pytestcache-remove
36 changes: 13 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,14 @@

To build your LLM and set up automated testing, you’ll need the following frameworks and tools:

- [CircleCI](https://circleci.com/signup/) – A configuration-as-code CI/CD platform that allows users to run and
orchestrate cloud-based pipelines across machines.
- [PareaAI](https://www.parea.ai/) – A tool created to more efficiently debug language model applications
by showing the trace of LLM calls, as well as inputs and outputs for certain prompts. This allows you to view the test
results and metadata for all LLM calls in a single dashboard.

- [LangChain](https://docs.langchain.com/docs/) – An open-source framework for developing language model-powered
applications. It provides prompt templates, models, document loaders, text splitters,
and [many other tools for interacting with models](https://docs.langchain.com/docs/category/components).

- [PareaAI](https://www.parea.ai/) – A tool created to more efficiently debug language model applications
by showing the trace of LLM calls, as well as inputs and outputs for certain prompts. This allows you to view the test
results and metadata for all LLM calls in a single dashboard.

- [ChromaDB](https://docs.trychroma.com/) – An open-source embedding database/vector store, which tokenizes inputs (in
our case, text) and stores them in an n-dimensional vector space. Chunks of text similar to new inputs can be returned
using a modified K-nearest-neighbor algorithm in the vector space.
Expand All @@ -23,14 +20,10 @@ To build your LLM and set up automated testing, you’ll need the following fram
scripts.
- These scripts rely on a .env file with API keys to OpenAI and Langchain, as well as other environment variables.
An example is provided, but you need to populate it with your own variables.
- .circleci/ directory contains the CircleCI config.yml that defines the CircleCI pipelines that call the
ML scripts.

# Set up environment

- Fork the example repository and clone your forked version locally.

- Install and activate your virtual environment
- Install and activate your virtual environment (we use Poetry)

- Create a .env file by running `cp .env.example .env`, then set the necessary environment variables in it. This will
include:
Expand All @@ -43,19 +36,16 @@ To build your LLM and set up automated testing, you’ll need the following fram
account, and create an API key by clicking on the API Keys button on the bottom left of the page and following the
instructions. This key should be stored in the `PAREA_API_KEY` environment variable in your .env file.

# Run the application

## Start the server

flask --app rag/app run & # spin up the Flask server

## Interact with the server
# Run tests

curl -X POST -H "Content-Type: application/json" -d '{"message": "What is LangSmith?"}' http://127.0.0.1:5000
## Pytest

Ask the application different questions by changing the `message` field in the curl command.
```bash
poetry run pytest -s
```

## Stop the server
or

fg [job no. of server]
Ctrl-C
```bash
make test
```
Loading

0 comments on commit 3000675

Please sign in to comment.