feat: added basic heartbeat override heuristics (#621)
* added basic heartbeat override * tested and working on lmstudio (patched typo + patched new bug emerging in latest lmstudio build * added lmstudio patch to chatml wrapper * update the system messages to be informative about the source * updated string constants after some tuning
This commit is contained in:
50
tests/test_function_parser.py
Normal file
50
tests/test_function_parser.py
Normal file
@@ -0,0 +1,50 @@
|
||||
import json
|
||||
|
||||
from memgpt.local_llm.function_parser import patch_function
|
||||
import memgpt.system as system
|
||||
|
||||
|
||||
EXAMPLE_FUNCTION_CALL_SEND_MESSAGE = {
|
||||
"message_history": [
|
||||
{"role": "user", "content": system.package_user_message("hello")},
|
||||
],
|
||||
# "new_message": {
|
||||
# "role": "function",
|
||||
# "name": "send_message",
|
||||
# "content": system.package_function_response(was_success=True, response_string="None"),
|
||||
# },
|
||||
"new_message": {
|
||||
"role": "assistant",
|
||||
"content": "I'll send a message.",
|
||||
"function_call": {
|
||||
"name": "send_message",
|
||||
"arguments": "null",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
EXAMPLE_FUNCTION_CALL_CORE_MEMORY_APPEND_MISSING = {
|
||||
"message_history": [
|
||||
{"role": "user", "content": system.package_user_message("hello")},
|
||||
],
|
||||
"new_message": {
|
||||
"role": "assistant",
|
||||
"content": "I'll append to memory.",
|
||||
"function_call": {
|
||||
"name": "core_memory_append",
|
||||
"arguments": json.dumps({"content": "new_stuff"}),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def test_function_parsers():
|
||||
"""Try various broken JSON and check that the parsers can fix it"""
|
||||
|
||||
og_message = EXAMPLE_FUNCTION_CALL_SEND_MESSAGE["new_message"]
|
||||
corrected_message = patch_function(**EXAMPLE_FUNCTION_CALL_SEND_MESSAGE)
|
||||
assert corrected_message == og_message, f"Uncorrected:\n{og_message}\nCorrected:\n{corrected_message}"
|
||||
|
||||
og_message = EXAMPLE_FUNCTION_CALL_CORE_MEMORY_APPEND_MISSING["new_message"].copy()
|
||||
corrected_message = patch_function(**EXAMPLE_FUNCTION_CALL_CORE_MEMORY_APPEND_MISSING)
|
||||
assert corrected_message != og_message, f"Uncorrected:\n{og_message}\nCorrected:\n{corrected_message}"
|
||||
Reference in New Issue
Block a user