Skip to content

Commit bcfa5f6

Browse files
authored
fix(prompt/base.py): Proper parsing of dict to json string (#728)
Co-authored-by: GlockPL <[email protected]>
1 parent d76bb22 commit bcfa5f6

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

packages/ragbits-core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Fix issue with improper convertion to json of tool call arguments (#737)
56
- Added Google Drive support (#686)
67
- Add LLM Usage to LLMResponseWithMetadata (#700)
78
- Split usage per model type (#715)

packages/ragbits-core/src/ragbits/core/prompt/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
from abc import ABCMeta, abstractmethod
23
from typing import Any, Generic
34

@@ -99,7 +100,7 @@ def add_tool_use_message(
99100
"type": "function",
100101
"function": {
101102
"name": name,
102-
"arguments": str(arguments),
103+
"arguments": json.dumps(arguments),
103104
},
104105
}
105106
],

packages/ragbits-core/tests/unit/prompts/test_prompt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def test_base_prompt_with_parser_add_tool_use_message_no_history():
675675
assert prompt.chat[0]["tool_calls"][0]["id"] == "tool_123"
676676
assert prompt.chat[0]["tool_calls"][0]["type"] == "function"
677677
assert prompt.chat[0]["tool_calls"][0]["function"]["name"] == "test_function"
678-
assert prompt.chat[0]["tool_calls"][0]["function"]["arguments"] == "{'param': 'value'}"
678+
assert prompt.chat[0]["tool_calls"][0]["function"]["arguments"] == '{"param": "value"}'
679679

680680
assert prompt.chat[1]["role"] == "tool"
681681
assert prompt.chat[1]["tool_call_id"] == "tool_123"

0 commit comments

Comments
 (0)