Skip to content

Commit

Permalink
fix(pipeline): .explain manual examples
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Oct 3, 2024
1 parent 4515930 commit 4b29973
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions kani/engines/huggingface/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def build_prompt(
raise NotImplementedError(
"You must pass a prompt_pipeline to the HuggingEngine to use it as a non-abstract class."
)
log.debug(messages) # todo temp
prompt = self.pipeline(messages, functions)
log.debug(f"BUILT PROMPT: {prompt}")
return prompt
Expand Down
16 changes: 12 additions & 4 deletions kani/prompts/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,24 @@ def explain(
print(f"{idx + 1:>{listwidth}}. {step.explain()}")
print()

# example
# build examples
print("Example\n-------")
if all_cases:
example_kwargs = {k: True for k in ALL_EXAMPLE_KWARGS}
else:
example_kwargs = functools.reduce(operator.or_, (s.explain_example_kwargs() for s in self.steps), kwargs)

examples_msg_grps = build_conversation(**example_kwargs)
examples_msgs = list(itertools.chain.from_iterable(examples_msg_grps))
example_functions = build_functions(**example_kwargs)
if not example:
examples_msg_grps = build_conversation(**example_kwargs)
examples_msgs = list(itertools.chain.from_iterable(examples_msg_grps))
else:
examples_msg_grps = [example]
examples_msgs = example

if not functions:
example_functions = build_functions(**example_kwargs)
else:
example_functions = functions

# run and time example
start = time.perf_counter()
Expand Down

0 comments on commit 4b29973

Please sign in to comment.