We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0a9897e commit 1d20ec7Copy full SHA for 1d20ec7
src/lemonade/tools/chat.py
@@ -26,6 +26,10 @@
26
END_OF_STREAM = "</s>"
27
28
29
+def sanitize_string(input_string):
30
+ return input_string.encode("utf-8", "ignore").decode("utf-8")
31
+
32
33
class LLMPrompt(Tool):
34
"""
35
Send a prompt to an LLM instance and print the response to the screen.
@@ -105,7 +109,7 @@ def run(
105
109
state.save_stat(Keys.PROMPT_TOKENS, len_tokens_in)
106
110
state.save_stat(Keys.PROMPT, prompt)
107
111
state.save_stat(Keys.RESPONSE_TOKENS, len_tokens_out)
108
- state.save_stat(Keys.RESPONSE, response_text)
112
+ state.save_stat(Keys.RESPONSE, sanitize_string(response_text))
113
114
return state
115
0 commit comments