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

Fix: Remove unexpected argument from APIRankers #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

srisudarsan
Copy link
Contributor

With latest change (ce422c3) of moving from Pydantic to a constructor based class, unexpected parameter present in APIRankers makes the initialisation fail.
Removing the unexpected variable text from being passed

@srisudarsan
Copy link
Contributor Author

@bclavie Can you please review this ?

@bclavie
Copy link
Collaborator

bclavie commented Feb 21, 2025

Thank you for your contribution!

Could you provide the exact issue? This fix cannot be merged as-is as we do not want to remove the text from Result objects.

@srisudarsan
Copy link
Contributor Author

Sure. Prior to this commit, we had Result as a Pydantic Model and passing an non-existing field to a Pydantic Model does not raise an exception, whereas now, we have rewritten Result with a classic Python style constructor without the text as a class variable to the init method, thus when we try to initialise a Result object with text field which is not defined in the init it throws an error as follows

Traceback (most recent call last):
  File "rerankers/main.py", line 3, in <module>
    results = ranker.rank(query="I love you", docs=["I hate you", "I really like you"], doc_ids=[0, 1])
  File "rerankers/rerankers/models/api_rankers.py", line 112, in rank
    results = self._parse_response(response.json(), docs)
  File "rerankers/rerankers/models/api_rankers.py", line 92, in _parse_response
    Result(
TypeError: __init__() got an unexpected keyword argument 'text'

CMIIW, Result object has a field called document which has text in it , thus making the text field in the Result object redundant

@srisudarsan
Copy link
Contributor Author

Hello @bclavie , did you manage to check this out ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants