Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: multi-round conversion with Bedrock Claude #1111

Merged
merged 4 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions pandasai/llm/bedrock_claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class BedrockClaude(LLM):
stop_sequences: (Optional) Custom text sequences that cause the model to stop generating. Anthropic Claude models normally stop when they have naturally completed their turn, in this case the value of the stop_reason response field is end_turn. If you want the model to stop generating when it encounters custom strings of text, you can use the stop_sequences parameter. If the model encounters one of the custom text strings, the value of the stop_reason response field is stop_sequence and the value of stop_sequence contains the matched stop sequence.
"""

_supported__models = ["anthropic.claude-3-sonnet-20240229-v1:0"]
_supported__models = [
"anthropic.claude-3-sonnet-20240229-v1:0",
"anthropic.claude-3-haiku-20240307-v1:0",
]
_valid_params = [
"max_tokens",
"model",
Expand Down Expand Up @@ -85,12 +88,19 @@ def call(self, instruction: BasePrompt, context: PipelineContext = None) -> str:

for message in memory.all():
if message["is_user"]:
messages.append(
{
"role": "user",
"content": [{"type": "text", "text": message["message"]}],
}
)
if messages and messages[-1]["role"] == "user":
messages[-1]["content"].append(
{"type": "text", "text": message["message"]}
)
else:
messages.append(
{
"role": "user",
"content": [
{"type": "text", "text": message["message"]}
],
}
)
else:
messages.append(
{
Expand Down
31 changes: 30 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading