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: prompt_template_resolved.output_variable is NoneType issue #4976

Merged
merged 12 commits into from
May 29, 2023

Conversation

faaany
Copy link
Contributor

@faaany faaany commented May 22, 2023

Related Issues

Proposed Changes:

  • use try and except instead of using or

How did you test it?

  • locally running the following code snippet, it won't crash.
from haystack.nodes.prompt import PromptNode, PromptModel
the_question = "What is the capital of Germany?"
node = PromptNode()
results, _ = node.run(query=the_question)

Notes for the reviewer

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

@faaany faaany requested a review from a team as a code owner May 22, 2023 10:26
@faaany faaany requested review from silvanocerza and removed request for a team May 22, 2023 10:26
@coveralls
Copy link
Collaborator

coveralls commented May 22, 2023

Pull Request Test Coverage Report for Build 5086338918

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 27 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.0008%) to 39.621%

Files with Coverage Reduction New Missed Lines %
nodes/prompt/prompt_node.py 27 58.92%
Totals Coverage Status
Change from base Build 5081399763: -0.0008%
Covered Lines: 8877
Relevant Lines: 22405

💛 - Coveralls

@github-actions github-actions bot added the type:documentation Improvements on the docs label May 22, 2023
@faaany
Copy link
Contributor Author

faaany commented May 23, 2023

is there any concern with this fix? @silvanocerza

@silvanocerza
Copy link
Contributor

@faaany I can't seem to reproduce the issue as specified in the linked issue, can you provide one please?

@faaany
Copy link
Contributor Author

faaany commented May 24, 2023

@faaany I can't seem to reproduce the issue as specified in the linked issue, can you provide one please?

the code snippet for reproduction is as follows:

from haystack.nodes.prompt import PromptNode, PromptModel

the_question = "What is the capital of Germany?"

node = PromptNode()
results, _ = node.run(query=the_question)

print(results)

And the error log is as follows:

Traceback (most recent call last):
  File "/localdisk/fanli/project/haystack/my_test.py", line 6, in <module>
    results, _ = node.run(query=the_question)
  File "/localdisk/fanli/project/haystack/haystack/nodes/prompt/prompt_node.py", line 375, in run
    output_variable = self.output_variable or prompt_template_resolved.output_variable or "results"
AttributeError: 'NoneType' object has no attribute 'output_variable'

prompt_template is an optional variable and is None by default. The problem is that we try to access output_variable from a None object. In our case what we really want with this line

output_variable = self.output_variable or prompt_template_resolved.output_variable or "results"

is that the output_variable has the value of results. try-except can get rid of this problem.

@faaany
Copy link
Contributor Author

faaany commented May 26, 2023

@silvanocerza any update? it has been a while...

@silvanocerza silvanocerza removed the type:documentation Improvements on the docs label May 29, 2023
@silvanocerza silvanocerza merged commit 7001aee into deepset-ai:main May 29, 2023
45 checks passed
@silvanocerza
Copy link
Contributor

@faaany merged! Sorry but I was at a conference and didn't have time to handle some stuff. :)

@silvanocerza
Copy link
Contributor

@652994331 please don't ask for support in unrelated PRs.

If you're unsure of what you're doing I suggest you read the official Haystack documentation and follow the tutorials.

If you want to report a bug open an issue here.

If instead you want to ask for some guidance or help I suggest you ask in GitHub discussions or in our community Discord.

Thanks. 🙏

@faaany
Copy link
Contributor Author

faaany commented May 30, 2023

@faaany merged! Sorry but I was at a conference and didn't have time to handle some stuff. :)

no problem! thanks so much for the approval!

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

Successfully merging this pull request may close these issues.

bug: PromptNode.run() requires the optional argument prompt_template or output_variable
3 participants