Spaces:
Runtime error
Runtime error
Commit
·
8c3f4a5
1
Parent(s):
585f92d
correct structured
Browse files
app.py
CHANGED
@@ -92,6 +92,8 @@ import html2text
|
|
92 |
from interpreter.code_interpreter import CodeInterpreter
|
93 |
from interpreter.code_block import CodeBlock
|
94 |
|
|
|
|
|
95 |
class CodeBlock:
|
96 |
def __init__(self, code):
|
97 |
self.code = code
|
@@ -276,6 +278,18 @@ class GPTRemote(LLM):
|
|
276 |
if 'Action:' in output and 'Observation:' in output:
|
277 |
output = output.split('Observation:')[0]
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
print("-" * 20)
|
280 |
print("Treated output: \n", output)
|
281 |
return output
|
|
|
92 |
from interpreter.code_interpreter import CodeInterpreter
|
93 |
from interpreter.code_block import CodeBlock
|
94 |
|
95 |
+
import regex
|
96 |
+
|
97 |
class CodeBlock:
|
98 |
def __init__(self, code):
|
99 |
self.code = code
|
|
|
278 |
if 'Action:' in output and 'Observation:' in output:
|
279 |
output = output.split('Observation:')[0]
|
280 |
|
281 |
+
global Choice
|
282 |
+
if Choice == "Structured Zero Short Agent":
|
283 |
+
try:
|
284 |
+
# temp = output.split('{')[1].split('}')[0:-2]
|
285 |
+
pattern = r'\{((?:[^{}]|(?R))*)\}'
|
286 |
+
temp = regex.search(pattern, output)
|
287 |
+
rrr = temp.group()
|
288 |
+
output = output.replace(rrr, '```'+ '\n' + rrr + '\n'+'```')
|
289 |
+
|
290 |
+
print(output)
|
291 |
+
except Exception as e:
|
292 |
+
print("model internal error:", e)
|
293 |
print("-" * 20)
|
294 |
print("Treated output: \n", output)
|
295 |
return output
|