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 max_tokens to BaseGenerator params #4168

Merged
merged 11 commits into from
May 18, 2023
Merged

feat: Add max_tokens to BaseGenerator params #4168

merged 11 commits into from
May 18, 2023

Conversation

vblagoje
Copy link
Member

Related Issues

Proposed Changes:

Allow per pipeline run invocation max_tokens parameter to be set. Currently, we only allow per-component max_tokens setting. Add max_tokens implementation for OpenAIAnswerGenerator, RagGenerator, and Seq2SeqGenerator.

How did you test it?

Unit tests added for the bare component and the pipeline usage

Notes for the reviewer

Ready for review

Checklist

  • I have read the contributors guidelines and the code of conduct
  • I have updated the related issue with new insights and changes
  • I added tests that demonstrate the correct behavior of the change
  • I've used one of the conventional commit types for my PR title: fix:, feat:, build:, chore:, ci:, docs:, style:, refactor:, perf:, test:.
  • I documented my code
  • I ran pre-commit hooks and fixed any issue

test/nodes/test_generator.py Outdated Show resolved Hide resolved
@agnieszka-m
Copy link
Contributor

FYI, committed some minor lg changes

@vblagoje
Copy link
Member Author

@masci this PR should be gtg now; the impact is minimal though as we'll deprecate all these generators soon anyway.

@@ -197,3 +197,22 @@ def test_build_prompt_within_max_length():

assert len(prompt_docs) == 1
assert prompt_docs[0] == documents[0]


@pytest.mark.integration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be unit at this point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I wanted it, but when I tagged the test with the unit, it fails with
FAILED test/nodes/test_generator.py::test_openai_answer_generator_pipeline_max_tokens - AttributeError: module 'requests.sessions' has no attribute 'Session'
because I believe it disables any HTTP requests. I'll reverted it to the integration marker.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means the mocking was wrong, when this happens you should fix it instead of just marking it integration. I have fixed it for you, please have a look at my commit.

@coveralls
Copy link
Collaborator

coveralls commented May 17, 2023

Coverage Status

Coverage: 38.611% (+0.4%) from 38.239% when pulling c0f7eca on max_tokens into 9d52998 on main.

@@ -197,3 +197,22 @@ def test_build_prompt_within_max_length():

assert len(prompt_docs) == 1
assert prompt_docs[0] == documents[0]


@pytest.mark.integration
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means the mocking was wrong, when this happens you should fix it instead of just marking it integration. I have fixed it for you, please have a look at my commit.

@masci masci merged commit 5d7ee2e into main May 18, 2023
60 checks passed
@masci masci deleted the max_tokens branch May 18, 2023 13:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic:tests type:documentation Improvements on the docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include max_tokens in the answer_generator run method
4 participants