Skip to content

Commit

Permalink
add text splitter tutorial files and update RST links
Browse files Browse the repository at this point in the history
  • Loading branch information
fm1320 committed Nov 25, 2024
2 parents 7f700f6 + f1035f8 commit dc22573
Show file tree
Hide file tree
Showing 21 changed files with 9,373 additions and 9,238 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
Loading

0 comments on commit dc22573

Please sign in to comment.