Skip to content

Commit

Permalink
fix(anthropic): multi-function calling format
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed May 8, 2024
1 parent 01c62ad commit 05da040
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kani/engines/anthropic/engine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
import itertools
import json
import logging
import os
import warnings
from typing import AsyncIterable
Expand All @@ -25,6 +26,8 @@
("", 100000),
]

log = logging.getLogger(__name__)


# ==== pipe ====
def content_transform(msg: ChatMessage):
Expand Down Expand Up @@ -237,7 +240,7 @@ def _prepare_request(messages, functions):
if isinstance(msg["content"], str):
prompt_msg_content.append({"type": "text", "text": msg["content"]})
else:
prompt_msg_content.append(msg["content"])
prompt_msg_content.extend(msg["content"])
# and output the final msg
prompt_msgs.append({"role": "user", "content": prompt_msg_content})
# else send to output
Expand All @@ -250,6 +253,8 @@ def _prepare_request(messages, functions):
{"name": f.name, "description": f.desc, "input_schema": f.json_schema} for f in functions
]

log.debug(f"Claude message format: {prompt_msgs}")

return kwargs, prompt_msgs

def _translate_anthropic_message(self, message):
Expand Down

0 comments on commit 05da040

Please sign in to comment.