zeno-ml / zeno-build

Build, evaluate, understand, and fix LLM-based apps
MIT License
482 stars 33 forks source link

add n to the acomplete and refactor error handler #170

Closed zhaochenyang20 closed 1 year ago

zhaochenyang20 commented 1 year ago

Description

  1. I create ERROR_ERRORS_TO_MESSAGES to make the error handling clearer for _throttled_openai_completion_acreate and _throttled_openai_chat_completion_acreate.
  2. There is no TimeoutError in openai.error, so I delete it.
  3. I add a new parameter n for both completion, which is the number of responses to generate for each API call.

References

Blocked by

zhaochenyang20 commented 1 year ago

I used pre-commit run --show-diff-on-failure --color=always --all-files to run pre-commit. But it changed 21 other files. Possibly due to different settings of pre-commit. 🤔

cabreraalex commented 1 year ago

Hmm yeah looks like the isort settings are different?

zhaochenyang20 commented 1 year ago

Hmmm. I checked the isort setting. But I didn't find problem. I will uninstall isort and reinstall it tonight to have a try.

zhaochenyang20 commented 1 year ago

Hey Alex, I tried loads of times and I feel that our configuration for pre-commit is merely the same. This is mine:


repos:
  - repo: https://github.com/python/black.git
    rev: 22.3.0
    hooks:
      - id: black
        files: '\.py$'
  - repo: https://github.com/PyCQA/flake8
    rev: 5.0.4
    hooks:
      - id: flake8
        name: flake8
        additional_dependencies:
          - flake8-absolute-import
          - flake8-black>=0.1.1
          - flake8-pep585>=0.1.6
        entry: flake8
        files: '\.py$'
      - id: flake8
        name: docstring
        additional_dependencies:
          - flake8-docstrings>=1.6
        args:
          - --docstring-convention=google
          - --select=D
        entry: flake8
        files: '\.py$'
      - id: flake8
        name: future-import
        additional_dependencies:
          - flake8-future-import
        args:
          - --select=FI
        entry: flake8
        files: '\.py$'
  - repo: https://github.com/pycqa/isort.git
    rev: 5.12.0
    hooks:
      - id: isort
        args: ["--profile", "black"]
        files: '\.py$'
  - repo: https://github.com/sondrelg/pep585-upgrade
    rev: v1.0.1
    hooks:
      - id: upgrade-type-hints
        files: '\.py$'
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: 'v0.981'
    hooks:
      - id: mypy
        additional_dependencies:
          - types-requests
        files: '\.py$'
  - repo: https://github.com/DavidAnson/markdownlint-cli2
    rev: v0.5.1
    hooks:
    - id: markdownlint-cli2
    - id: markdownlint-cli2-fix
···
zhaochenyang20 commented 1 year ago

Would you please clone my branch and run pre-commit on your device?

I've tried this on my laptop, on TIR, and searched Google and StackOverflow. All failed. 😭

neubig commented 1 year ago

Thanks @zhaochenyang20 ! I did it and it worked. Could you please select "allow edits from maintainers" for this pull request? https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

zhaochenyang20 commented 1 year ago

Sorry. I run all the processes again. Now it also works on my device. 😂

zhaochenyang20 commented 1 year ago

I select it!

zhaochenyang20 commented 1 year ago

Sorry that I close this PR and delete the previous fork. I created a new PR: https://github.com/zeno-ml/zeno-build/pull/171

@neubig Thanks so much!