Bugfix/add regex to csv and airtable agent (#2983)
add regex to csv and airtable agent
This commit is contained in:
parent
b833fd8f7d
commit
9da05acc30
|
|
@ -166,6 +166,8 @@ json.dumps(my_dict)`
|
||||||
}
|
}
|
||||||
const res = await chain.call(inputs, [loggerHandler, ...callbacks])
|
const res = await chain.call(inputs, [loggerHandler, ...callbacks])
|
||||||
pythonCode = res?.text
|
pythonCode = res?.text
|
||||||
|
// Regex to get rid of markdown code blocks syntax
|
||||||
|
pythonCode = pythonCode.replace(/^```[a-z]+\n|\n```$/gm, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then run the code using Pyodide
|
// Then run the code using Pyodide
|
||||||
|
|
@ -173,6 +175,7 @@ json.dumps(my_dict)`
|
||||||
if (pythonCode) {
|
if (pythonCode) {
|
||||||
try {
|
try {
|
||||||
const code = `import pandas as pd\n${pythonCode}`
|
const code = `import pandas as pd\n${pythonCode}`
|
||||||
|
// TODO: get print console output
|
||||||
finalResult = await pyodide.runPythonAsync(code)
|
finalResult = await pyodide.runPythonAsync(code)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Sorry, I'm unable to find answer for question: "${input}" using follwoing code: "${pythonCode}"`)
|
throw new Error(`Sorry, I'm unable to find answer for question: "${input}" using follwoing code: "${pythonCode}"`)
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,8 @@ json.dumps(my_dict)`
|
||||||
}
|
}
|
||||||
const res = await chain.call(inputs, [loggerHandler, ...callbacks])
|
const res = await chain.call(inputs, [loggerHandler, ...callbacks])
|
||||||
pythonCode = res?.text
|
pythonCode = res?.text
|
||||||
|
// Regex to get rid of markdown code blocks syntax
|
||||||
|
pythonCode = pythonCode.replace(/^```[a-z]+\n|\n```$/gm, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then run the code using Pyodide
|
// Then run the code using Pyodide
|
||||||
|
|
@ -178,6 +180,7 @@ json.dumps(my_dict)`
|
||||||
if (pythonCode) {
|
if (pythonCode) {
|
||||||
try {
|
try {
|
||||||
const code = `import pandas as pd\n${pythonCode}`
|
const code = `import pandas as pd\n${pythonCode}`
|
||||||
|
// TODO: get print console output
|
||||||
finalResult = await pyodide.runPythonAsync(code)
|
finalResult = await pyodide.runPythonAsync(code)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Sorry, I'm unable to find answer for question: "${input}" using following code: "${pythonCode}"`)
|
throw new Error(`Sorry, I'm unable to find answer for question: "${input}" using following code: "${pythonCode}"`)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue