Skip to content

Commit

Permalink
added function for bedrock tools
Browse files Browse the repository at this point in the history
  • Loading branch information
imZain448 committed Jan 26, 2025
1 parent 45b9586 commit 93e0c4b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
3 changes: 0 additions & 3 deletions instructor/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ def patch( # type: ignore

logger.debug(f"Patching `client.chat.completions.create` with {mode=}")

# TODO: remove this
print(f"instructor.patch: patching {create.__name__}")

if create is not None:
func = create
elif client is not None:
Expand Down
20 changes: 9 additions & 11 deletions instructor/process_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,6 @@ def process_response(
f"Instructor Raw Response: {response}",
)

# TODO: remove this
print(f"instructor.process_response.py: response_model {response_model}")

# TODO: remove this
print(f"instructor.process_response.py: response {response}")

if response_model is None:
logger.debug("No response model, returning response as is")
return response
Expand Down Expand Up @@ -195,9 +189,6 @@ def process_response(

model._raw_response = response

# TODO: remove this
print(f"instructor.process_response.py: model {model}")

return model


Expand Down Expand Up @@ -570,8 +561,6 @@ def handle_vertexai_json(
def handle_bedrock_json(
response_model: type[T], new_kwargs: dict[str, Any]
) -> tuple[type[T], dict[str, Any]]:
print(f"handle_bedrock_json: response_model {response_model}")
print(f"handle_bedrock_json: new_kwargs {new_kwargs}")
json_message = dedent(
f"""
As a genius expert, your task is to understand the content and provide
Expand All @@ -594,6 +583,14 @@ def handle_bedrock_json(
"""
)
system_message.append({"text": json_message})
new_kwargs["system"] = system_message

return response_model, new_kwargs


def handle_bedrock_tools(
response_model: type[T], new_kwargs: dict[str, Any]
) -> tuple[type[T], dict[str, Any]]:
return response_model, new_kwargs


Expand Down Expand Up @@ -806,6 +803,7 @@ def handle_response_model(
Mode.FIREWORKS_TOOLS: handle_fireworks_tools,
Mode.WRITER_TOOLS: handle_writer_tools,
Mode.BEDROCK_JSON: handle_bedrock_json,
Mode.BEDROCK_TOOLS: handle_bedrock_tools,
}

if mode in mode_handlers:
Expand Down
3 changes: 0 additions & 3 deletions instructor/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,6 @@ def retry_sync(
response=response, total_usage=total_usage
)

# TODO: remove this
print(f"instructor.retry.py: {response}")

return process_response( # type: ignore
response=response,
response_model=response_model,
Expand Down

0 comments on commit 93e0c4b

Please sign in to comment.