Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: Mandana Vaziri <[email protected]>
  • Loading branch information
vazirim committed Oct 4, 2024
1 parent d40d5ba commit 0ceb00f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
4 changes: 3 additions & 1 deletion src/pdl/pdl_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1051,7 +1051,9 @@ def get_transformed_inputs(kwargs):
if "input" in litellm_params:
append_log(state, "Model Input", litellm_params["input"])
else:
append_log(state, "Model Input", messages_to_str(concrete_block.model, model_input))
append_log(
state, "Model Input", messages_to_str(concrete_block.model, model_input)
)
background: Messages = [msg]
result = msg["content"]
append_log(state, "Model Output", result)
Expand Down
36 changes: 15 additions & 21 deletions src/pdl/pdl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,19 @@ def messages_concat(messages1: Messages, messages2: Messages) -> Messages:


def messages_to_str(model_id: str, messages: Messages) -> str:
if "granite-3b" not in model_id and "granite-8b" not in model_id:
return "".join(
[
(
msg["content"]

)
for msg in messages
]
if "granite-3b" not in model_id and "granite-8b" not in model_id:
return "".join([(msg["content"]) for msg in messages])
return (
"".join(
[
(
msg["content"]
if msg["role"] is None
# else f"<|{msg['role']}|>{msg['content']}"
else f"<|start_of_role|>{msg['role']}<|end_of_role|>{msg['content']}<|end_of_text|>\n"
)
for msg in messages
]
)
+ "<|start_of_role|>assistant<|end_of_role|>"
)
return "".join(
[
(
msg["content"]
if msg["role"] is None
#else f"<|{msg['role']}|>{msg['content']}"
else f"<|start_of_role|>{msg['role']}<|end_of_role|>{msg['content']}<|end_of_text|>\n"
)
for msg in messages
]
) + "<|start_of_role|>assistant<|end_of_role|>"

0 comments on commit 0ceb00f

Please sign in to comment.