Spaces:
Runtime error
Runtime error
Valian
commited on
Commit
·
a31142b
1
Parent(s):
e97538a
make verbosity configurable through session constructor
Browse files
codeinterpreterapi/session.py
CHANGED
|
@@ -20,14 +20,14 @@ from codeinterpreterapi.chains.remove_download_link import remove_download_link
|
|
| 20 |
|
| 21 |
|
| 22 |
class CodeInterpreterSession:
|
| 23 |
-
def __init__(self, model=None, openai_api_key=
|
| 24 |
self.codebox = CodeBox()
|
|
|
|
| 25 |
self.tools: list[StructuredTool] = self._tools()
|
| 26 |
self.llm: BaseChatModel = self._llm(model, openai_api_key)
|
| 27 |
self.agent_executor: AgentExecutor = self._agent_executor()
|
| 28 |
self.input_files: list[File] = []
|
| 29 |
self.output_files: list[File] = []
|
| 30 |
-
self.verbose = verbose if verbose is not None else settings.VERBOSE
|
| 31 |
|
| 32 |
async def astart(self) -> None:
|
| 33 |
await self.codebox.astart()
|
|
@@ -52,10 +52,9 @@ class CodeInterpreterSession:
|
|
| 52 |
model = "gpt-4"
|
| 53 |
|
| 54 |
if openai_api_key is None:
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
openai_api_key = settings.OPENAI_API_KEY
|
| 59 |
|
| 60 |
return ChatOpenAI(
|
| 61 |
temperature=0.03,
|
|
|
|
| 20 |
|
| 21 |
|
| 22 |
class CodeInterpreterSession:
|
| 23 |
+
def __init__(self, model=None, openai_api_key=settings.OPENAI_API_KEY, verbose=settings.VERBOSE) -> None:
|
| 24 |
self.codebox = CodeBox()
|
| 25 |
+
self.verbose = verbose
|
| 26 |
self.tools: list[StructuredTool] = self._tools()
|
| 27 |
self.llm: BaseChatModel = self._llm(model, openai_api_key)
|
| 28 |
self.agent_executor: AgentExecutor = self._agent_executor()
|
| 29 |
self.input_files: list[File] = []
|
| 30 |
self.output_files: list[File] = []
|
|
|
|
| 31 |
|
| 32 |
async def astart(self) -> None:
|
| 33 |
await self.codebox.astart()
|
|
|
|
| 52 |
model = "gpt-4"
|
| 53 |
|
| 54 |
if openai_api_key is None:
|
| 55 |
+
raise ValueError(
|
| 56 |
+
"OpenAI API key missing. Set OPENAI_API_KEY env variable or pass `openai_api_key` to session."
|
| 57 |
+
)
|
|
|
|
| 58 |
|
| 59 |
return ChatOpenAI(
|
| 60 |
temperature=0.03,
|