mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 13:18:18 +00:00
Improve load of complex json objects. Use it to pick tool, run code
Gemini doesn't work well when trying to output json objects. Using it to output raw json strings with complex, multi-line structures requires more intense clean-up of raw json string for parsing
This commit is contained in:
@@ -104,6 +104,18 @@ class TestTruncateMessage:
|
||||
assert truncated_chat_history[0] != copy_big_chat_message
|
||||
|
||||
|
||||
def test_load_complex_raw_json_string():
|
||||
# Arrange
|
||||
raw_json = r"""{"key": "value with unescaped " and unescaped \' and escaped \" and escaped \\'"}"""
|
||||
expeced_json = {"key": "value with unescaped \" and unescaped \\' and escaped \" and escaped \\'"}
|
||||
|
||||
# Act
|
||||
parsed_json = utils.load_complex_json(raw_json)
|
||||
|
||||
# Assert
|
||||
assert parsed_json == expeced_json
|
||||
|
||||
|
||||
def generate_content(count):
|
||||
return " ".join([f"{index}" for index, _ in enumerate(range(count))])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user