biobootloader / wolverine

MIT License
5.22k stars 516 forks source link

Add VALIDATE_JSON_RETRY environment variable, and tests #35

Closed nervousapps closed 1 year ago

nervousapps commented 1 year ago

VALIDATE_JSON_RETRY environment variable to configure the number of retry when validating a chatCompletion response. -1 means unlimited.

I'm not sure about raising an exception at the end of retry, maybe a user prompt should be useful to add retries.

Add environment variables part in README.

Test a little bit reworked, add tests for json_validated_response.

Add a new line at the end of the prompts to have only the specified json object without comments or other world. Less likely to return a wrong/malformed json object.

For testing purpose, it could be a good option to add a github action like

name: PyTest

# test whenever there are new commits on master
on:
  push:
    branches:
      - main

# security: restrict permissions for CI jobs.
permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - run: pip install -r ./requirements-dev.txt
      - run: pytest