Spaces:
Runtime error
Runtime error
Shroominic
commited on
Commit
·
34d0048
1
Parent(s):
c26a364
🔧 tiny fixes
Browse files
codeinterpreterapi/session.py
CHANGED
|
@@ -9,7 +9,7 @@ from langchain.prompts.chat import MessagesPlaceholder
|
|
| 9 |
from langchain.agents import AgentExecutor, BaseSingleActionAgent
|
| 10 |
from langchain.memory import ConversationBufferMemory
|
| 11 |
|
| 12 |
-
from codeinterpreterapi.schema import CodeInterpreterResponse, CodeInput, File, UserRequest
|
| 13 |
from codeinterpreterapi.config import settings
|
| 14 |
from codeinterpreterapi.chains.functions_agent import OpenAIFunctionsAgent
|
| 15 |
from codeinterpreterapi.prompts import code_interpreter_system_message
|
|
@@ -39,7 +39,7 @@ class CodeInterpreterSession:
|
|
| 39 |
# TODO: current files as context to the agent
|
| 40 |
"Input a string of code to a python interpreter (jupyter kernel). "
|
| 41 |
"Variables are preserved between runs. ",
|
| 42 |
-
func=self.
|
| 43 |
coroutine=self.arun_handler,
|
| 44 |
args_schema=CodeInput,
|
| 45 |
),
|
|
@@ -91,7 +91,6 @@ class CodeInterpreterSession:
|
|
| 91 |
|
| 92 |
async def arun_handler(self, code: str):
|
| 93 |
"""Run code in container and send the output to the user"""
|
| 94 |
-
# TODO: upload files
|
| 95 |
output: CodeBoxOutput = await self.codebox.arun(code)
|
| 96 |
|
| 97 |
if not isinstance(output.content, str):
|
|
@@ -111,8 +110,10 @@ class CodeInterpreterSession:
|
|
| 111 |
):
|
| 112 |
await self.codebox.ainstall(package.group(1))
|
| 113 |
return f"{package.group(1)} was missing but got installed now. Please try again."
|
| 114 |
-
|
| 115 |
-
|
|
|
|
|
|
|
| 116 |
|
| 117 |
elif modifications := await get_file_modifications(code, self.llm):
|
| 118 |
for filename in modifications:
|
|
|
|
| 9 |
from langchain.agents import AgentExecutor, BaseSingleActionAgent
|
| 10 |
from langchain.memory import ConversationBufferMemory
|
| 11 |
|
| 12 |
+
from codeinterpreterapi.schema import CodeInterpreterResponse, CodeInput, File, UserRequest
|
| 13 |
from codeinterpreterapi.config import settings
|
| 14 |
from codeinterpreterapi.chains.functions_agent import OpenAIFunctionsAgent
|
| 15 |
from codeinterpreterapi.prompts import code_interpreter_system_message
|
|
|
|
| 39 |
# TODO: current files as context to the agent
|
| 40 |
"Input a string of code to a python interpreter (jupyter kernel). "
|
| 41 |
"Variables are preserved between runs. ",
|
| 42 |
+
func=self.run_handler,
|
| 43 |
coroutine=self.arun_handler,
|
| 44 |
args_schema=CodeInput,
|
| 45 |
),
|
|
|
|
| 91 |
|
| 92 |
async def arun_handler(self, code: str):
|
| 93 |
"""Run code in container and send the output to the user"""
|
|
|
|
| 94 |
output: CodeBoxOutput = await self.codebox.arun(code)
|
| 95 |
|
| 96 |
if not isinstance(output.content, str):
|
|
|
|
| 110 |
):
|
| 111 |
await self.codebox.ainstall(package.group(1))
|
| 112 |
return f"{package.group(1)} was missing but got installed now. Please try again."
|
| 113 |
+
else: pass
|
| 114 |
+
# TODO: preanalyze error to optimize next code generation
|
| 115 |
+
if settings.VERBOSE:
|
| 116 |
+
print("Error:", output.content)
|
| 117 |
|
| 118 |
elif modifications := await get_file_modifications(code, self.llm):
|
| 119 |
for filename in modifications:
|