Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add test and fix final node #14

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test

on:
pull_request:


env:
POETRY_VERSION: "1.8.4"

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
steps:
- uses: actions/checkout@v4
- name: Cache Poetry
uses: actions/cache@v4
with:
path: ~/.poetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install poetry
run: |
pipx install poetry==$POETRY_VERSION
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: poetry
- name: Install dependencies
run: |
poetry install --all-extras
- name: Pytest All
run: |
poetry run pytest -vv -n 20 tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: ./coverage.xml
fail_ci_if_error: false
9 changes: 5 additions & 4 deletions graphai/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ async def execute(self, input):
else:
output = await current_node.invoke(input=state)
self._validate_output(output=output, node_name=current_node.name)
# add output to state
state = {**state, **output}
if current_node.is_end:
# finish loop if this was an end node
break
if current_node.is_router:
# if we have a router node we let the router decide the next node
next_node_name = str(output["choice"])
Expand All @@ -91,10 +96,6 @@ async def execute(self, input):
else:
# otherwise, we have linear path
current_node = self._get_next_node(current_node=current_node)
# add output to state
state = {**state, **output}
if current_node.is_end:
break
steps += 1
if steps >= self.max_steps:
raise Exception(
Expand Down
Loading
Loading