mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-21 12:49:06 +00:00
server/rtc: fix topic output
This commit is contained in:
@@ -55,9 +55,13 @@ class LLM:
|
||||
|
||||
regex = r"```(json|javascript|)?(.*)```"
|
||||
matches = re.findall(regex, result.strip(), re.MULTILINE | re.DOTALL)
|
||||
if not matches:
|
||||
return result
|
||||
if matches:
|
||||
result = matches[0][1]
|
||||
|
||||
else:
|
||||
# maybe the prompt has been started with ```json
|
||||
# so if text ends with ```, just remove it and use it as json
|
||||
if result.endswith("```"):
|
||||
result = result[:-3]
|
||||
|
||||
# we have a match, try to parse it
|
||||
result = matches[0][1]
|
||||
return json.loads(result.strip())
|
||||
|
||||
Reference in New Issue
Block a user