Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
fm1320 committed Nov 25, 2024
2 parents 6955c6b + f1035f8 commit a435bb8
Show file tree
Hide file tree
Showing 21 changed files with 9,226 additions and 9,089 deletions.
13 changes: 12 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,24 @@ repos:
hooks:
- id: black
args: ['--line-length=88']
exclude: ^docs/|.*\.(json|yaml|md|txt)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.2
hooks:
# Run the linter.
- id: ruff
args: ['--fix', '--extend-ignore=E402']
args: ['--fix']
exclude: ^docs/|.*\.(json|yaml|md|txt)$

# Add local hooks to run custom commands
- repo: local
hooks:
- id: run-make-format
name: Run Make Format
entry: make format
language: system
pass_filenames: false
# - repo: https://github.com/pycqa/flake8
# rev: 4.0.1
# hooks:
Expand Down
51 changes: 51 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Define variables for common directories and commands
PYTHON = poetry run
SRC_DIR = .

# Default target: Show help
.PHONY: help
help:
@echo "Available targets:"
@echo " setup Install dependencies and set up pre-commit hooks"
@echo " format Run Black and Ruff to format the code"
@echo " lint Run Ruff to check code quality"
@echo " test Run tests with pytest"
@echo " precommit Run pre-commit hooks on all files"
@echo " clean Clean up temporary files and build artifacts"

# Install dependencies and set up pre-commit hooks
.PHONY: setup
setup:
poetry install
poetry run pre-commit install

# Format code using Black and Ruff
.PHONY: format
format:
$(PYTHON) black $(SRC_DIR)
git ls-files | xargs pre-commit run black --files

# Run lint checks using Ruff
.PHONY: lint
lint:
$(PYTHON) ruff check $(SRC_DIR)

# Run all pre-commit hooks on all files
.PHONY: precommit
precommit:
$(PYTHON) pre-commit run --all-files

# Run tests
.PHONY: test
test:
$(PYTHON) pytest

# Clean up temporary files and build artifacts
.PHONY: clean
clean:
rm -rf .pytest_cache
rm -rf .mypy_cache
rm -rf __pycache__
rm -rf build dist *.egg-info
find . -type d -name "__pycache__" -exec rm -r {} +
find . -type f -name "*.pyc" -delete
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
anthropic = safe_import(
OptionalPackages.ANTHROPIC.value[0], OptionalPackages.ANTHROPIC.value[1]
)
import anthropic

# import anthropic
from anthropic import (
RateLimitError,
APITimeoutError,
Expand Down
2 changes: 1 addition & 1 deletion adalflow/adalflow/optim/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def __init__(
dataset: Sequence[DataClass] = None,
exclude_input_fields_from_bootstrap_demos: bool = False,
*args,
**kwargs
**kwargs,
):
self._weighted = weighted
self.dataset = dataset
Expand Down
5 changes: 2 additions & 3 deletions adalflow/tests/test_random_sample.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import unittest
from typing import TypeVar
from adalflow.core.functional import random_sample


# Assuming the random_sample function is defined here or imported
T_co = TypeVar("T_co", covariant=True)


from adalflow.core.functional import random_sample


class TestRandomSample(unittest.TestCase):

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/hotpot_qa/adal_exp/train_vanilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def train(
**gpt_3_model,
teacher_model_config=gpt_4o_model,
text_optimizer_model_config=gpt_4o_model,
backward_engine_model_config=gpt_4o_model
backward_engine_model_config=gpt_4o_model,
)
print(adal_component)
trainer = adal.Trainer(
Expand Down
17 changes: 9 additions & 8 deletions docs/source/contributor/index.rst
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
Contributor Guide
=============================
Welcome to the AdalFlow community! We're building the most user-friendly, modular, and powerful library for building and auto-optimizing LLM applications, rom Chatbots and RAGs to Agents.
Welcome to the AdalFlow community! We're building the most user-friendly, modular, and powerful library for building and auto-optimizing LLM applications, from Chatbots and RAGs to Agents.
*Think of AdalFlow for LLM applications and prompt engineering as the PyTorch/TensorFlow/JAX equivalent for AI modeling.*
The goal is to provide basic and fundamental building blocks to create advanced applications with auto-optimization out of the box.

The goal of the library is to provide basic and fundamental building blocks to create advanced applications with auto-optimization out of the box.
As we mature, we anticipate that more RAG, memory-based chatbots, or agent frameworks will be built on top of AdalFlow’s building blocks, such as `retriever` and `generator`.
We highly suggest you read our :ref:`design principle<lightrag_design_philosophy>` before you start contributing.

We only accept high quality contributions.
We appreciate contributors, but we have to hold our libary responsible for our users.
Once you decide to contribute, we hope it’s not just to list your name on the repo.
More importantly, we want you to learn and improve your own skills, support your favorite projects, and contribute to the community!
We greatly appreciate all contributions, from bug fixes to new features, and value every contributor.
However, we must be selective to ensure our library remains reliable for users.
We hope your contributions go beyond listing your name on the repo—our goal is for you to learn, grow your skills, support your favorite projects, and give back to the community!

The goal of this guide is to design the best process for maintaining the quality of our library while enabling the community to make meaningful contributions.
It took us three months to set up this contributor guide, as we first tested the process with early contributors.
Our goal is to design the best process for maintaining the quality of our library while enabling the community to make meaningful contributions.
We are determined to make AdalFlow as great and legendary as PyTorch.
*We are determined to make AdalFlow as great and legendary as PyTorch.*

This guide covers the overall contributing process, along with development essentials for environment setup, coding, testing, and documentation.

Here’s to the future of LLM applications!
Expand Down
Loading

0 comments on commit a435bb8

Please sign in to comment.