File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,24 @@ def respond(interpreter):
179
179
except :
180
180
pass
181
181
182
+ if code .replace ("\n " , "" ).replace (" " , "" ).startswith ("{language:" ):
183
+ try :
184
+ code = code .replace ("language: " , "'language': " ).replace (
185
+ "code: " , "'code': "
186
+ )
187
+ code_dict = json .loads (code )
188
+ if set (code_dict .keys ()) == {"language" , "code" }:
189
+ language = code_dict ["language" ]
190
+ code = code_dict ["code" ]
191
+ interpreter .messages [- 1 ][
192
+ "content"
193
+ ] = code # So the LLM can see it.
194
+ interpreter .messages [- 1 ][
195
+ "format"
196
+ ] = language # So the LLM can see it.
197
+ except :
198
+ pass
199
+
182
200
if language == "text" or language == "markdown" :
183
201
# It does this sometimes just to take notes. Let it, it's useful.
184
202
# In the future we should probably not detect this behavior as code at all.
You can’t perform that action at this time.
0 commit comments