Skip to content

Commit

Permalink
Fixes ChatBedrock for llama3 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
3coins authored Jul 18, 2024
1 parent 19822bc commit 8a17693
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions libs/aws/langchain_aws/llms/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,24 +847,23 @@ async def _aprepare_input_and_invoke_stream(
_model_kwargs["stream"] = True

params = {**_model_kwargs, **kwargs}
if "claude-3" in self._get_model():
if _tools_in_params(params):
input_body = LLMInputOutputAdapter.prepare_input(
provider=provider,
model_kwargs=params,
prompt=prompt,
system=system,
messages=messages,
tools=params["tools"],
)
else:
input_body = LLMInputOutputAdapter.prepare_input(
provider=provider,
prompt=prompt,
system=system,
messages=messages,
model_kwargs=params,
)
if "claude-3" in self._get_model() and _tools_in_params(params):
input_body = LLMInputOutputAdapter.prepare_input(
provider=provider,
model_kwargs=params,
prompt=prompt,
system=system,
messages=messages,
tools=params["tools"],
)
else:
input_body = LLMInputOutputAdapter.prepare_input(
provider=provider,
prompt=prompt,
system=system,
messages=messages,
model_kwargs=params,
)
body = json.dumps(input_body)

response = await asyncio.get_running_loop().run_in_executor(
Expand Down

0 comments on commit 8a17693

Please sign in to comment.