Skip to content

Commit

Permalink
Trajectory nodes (#30)
Browse files Browse the repository at this point in the history
* Set parent and children on transition

* Don't convert to X | Y for type annotations

* Rollback to use Optional as X | Y breaks compability to external libs

* Support save and read trajectories in a tree structure

* Verify save/load trajectories

* Refactor
  • Loading branch information
aorwall authored Aug 5, 2024
1 parent 83d56b1 commit 8ec5d51
Show file tree
Hide file tree
Showing 51 changed files with 2,613 additions and 1,754 deletions.
11 changes: 8 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
INDEX_STORE_DIR=/tmp/moatless/index-store
MOATLESS_DIR=/tmp/moatless

REPO_DIR=/tmp/repos
TRAJECTORY_DIR=/tmp/moatless/trajectories
PRONPT_LOG_DIR=/tmp/moatless/prompt_logs

DEFAULT_MODEL=gpt-4o-2024-05-13
CHEAP_MODEL=gpt-4o-mini-2024-07-18

INDEX_STORE_DIR=/tmp/moatless/index-store
INDEX_STORE_URL="https://stmoatless.blob.core.windows.net/indexstore/20240522-voyage-code-2"
27 changes: 24 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,35 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Poetry
uses: snok/install-poetry@v1
- name: Install dependencies
run: poetry install

- name: Cache REPO_DIR
uses: actions/cache@v4
with:
path: /tmp/cache
key: ${{ runner.os }}-moatless-${{ github.sha }}

- name: Run tests
run: poetry run pytest
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
INDEX_STORE_URL: ${{ vars.INDEX_STORE_URL }}
INDEX_STORE_DIR: /tmp/cache/index-store
REPO_DIR: /tmp/cache/repos
MOATLESS_DIR: /tmp/moatless
run: poetry run pytest

- name: Upload MOATLESS_DIR contents
uses: actions/upload-artifact@v4
if: ${{ success() && hashFiles('/tmp/moatless/**') != '' }}
with:
name: moatless-artifacts
path: /tmp/moatless
3 changes: 2 additions & 1 deletion moatless/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from moatless.loop import AgenticLoop, Transitions
from moatless.repository import FileRepository
from moatless.workspace import Workspace
from moatless.transition_rules import TransitionRules
from moatless.loop import AgenticLoop
24 changes: 12 additions & 12 deletions moatless/benchmark/claude_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
from moatless.edit.plan import PlanToCode
from moatless.find.decide import DecideRelevance
from moatless.find.identify import IdentifyCode
from moatless.find.search_v2 import SearchCode
from moatless.loop import Transition
from moatless.find.search import SearchCode
from moatless.transition_rules import TransitionRule
from moatless.state import Finished, Rejected
from moatless.transitions import (
search_and_code_transitions,
Expand Down Expand Up @@ -177,8 +177,8 @@ def evaluate_search():
},
initial_state=SearchCode,
transitions=[
Transition(source=SearchCode, dest=Finished, trigger="did_search"),
Transition(source=SearchCode, dest=Finished, trigger="finish"),
TransitionRule(source=SearchCode, dest=Finished, trigger="did_search"),
TransitionRule(source=SearchCode, dest=Finished, trigger="finish"),
],
)

Expand Down Expand Up @@ -298,19 +298,19 @@ def evaluate_plan(previous_trajectory_dir: Optional[str] = None):
},
initial_state=SearchCode,
transitions=[
Transition(source=SearchCode, dest=IdentifyCode, trigger="did_search"),
Transition(source=IdentifyCode, dest=SearchCode, trigger="search"),
Transition(source=IdentifyCode, dest=DecideRelevance, trigger="finish"),
Transition(source=DecideRelevance, dest=SearchCode, trigger="search"),
Transition(
TransitionRule(source=SearchCode, dest=IdentifyCode, trigger="did_search"),
TransitionRule(source=IdentifyCode, dest=SearchCode, trigger="search"),
TransitionRule(source=IdentifyCode, dest=DecideRelevance, trigger="finish"),
TransitionRule(source=DecideRelevance, dest=SearchCode, trigger="search"),
TransitionRule(
source=DecideRelevance,
dest=PlanToCode,
trigger="finish",
exclude_fields={"message"},
),
Transition(source=PlanToCode, dest=Finished, trigger="edit_code"),
Transition(source=PlanToCode, dest=Rejected, trigger="finish"),
Transition(source=PlanToCode, dest=Rejected, trigger="reject"),
TransitionRule(source=PlanToCode, dest=Finished, trigger="edit_code"),
TransitionRule(source=PlanToCode, dest=Rejected, trigger="finish"),
TransitionRule(source=PlanToCode, dest=Rejected, trigger="reject"),
],
)

Expand Down
Loading

0 comments on commit 8ec5d51

Please sign in to comment.