Skip to content

Commit

Permalink
Coercing prompt outputs to strings
Browse files Browse the repository at this point in the history
This is due to the addition of SampleResult in the latest version of
dynamic prompts
  • Loading branch information
adieyal committed Nov 11, 2023
1 parent fe16603 commit c4832fe
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
3 changes: 1 addition & 2 deletions nodes/feeling_lucky.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ def get_prompt(self, text: str, seed: int, autorefresh: str) -> tuple[str]:

try:
prompt = self._prompt_generator.generate(text, 1)[0]
print(prompt)

return (prompt,)
return (str(prompt),)
except Exception as e:
logger.exception(e)
return ("",)
Expand Down
2 changes: 1 addition & 1 deletion nodes/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def generate_prompt(self, text):
prompt_generator = JinjaGenerator()

all_prompts = prompt_generator.generate(text, 1) or [""]
return all_prompts[0]
return str(all_prompts[0])
3 changes: 1 addition & 2 deletions nodes/magicprompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ def get_prompt(self, text: str, seed: int, autorefresh: str) -> tuple[str]:

try:
prompt = self._prompt_generator.generate(text, 1)[0]
print(prompt)

return (prompt,)
return (str(prompt),)
except Exception as e:
logger.exception(e)
return ("",)
Expand Down
2 changes: 1 addition & 1 deletion nodes/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_prompt(self, text: str, seed: int, autorefresh: str) -> tuple[str]:
new_prompt = self._get_next_prompt(self._prompts, self._current_prompt)
print(f"New prompt: {new_prompt}")

return (new_prompt,)
return (str(new_prompt),)

@abstractproperty
def context(self) -> SamplingContext:
Expand Down

0 comments on commit c4832fe

Please sign in to comment.