Skip to content

Commit cf641fd

Browse files
committed
pre-commit all files
1 parent abc5993 commit cf641fd

6 files changed

Lines changed: 46 additions & 29 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ VERBOSE=False
88
# OPENAI_API_TYPE=azure
99
# OPENAI_API_VERSION=2023-07-01-preview
1010
# OPENAI_API_BASE=
11-
# DEPLOYMENT_NAME=
11+
# DEPLOYMENT_NAME=

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ To configure OpenAI and Azure OpenAI, ensure that you set the appropriate enviro
3131

3232
For OpenAI, set the OPENAI_API_KEY environment variable:
3333
```
34-
export OPENAI_API_KEY=your_openai_api_key
34+
export OPENAI_API_KEY=your_openai_api_key
3535
```
36-
36+
3737
For Azure OpenAI, set the following environment variables:
3838
```
39-
export OPENAI_API_TYPE=azure
40-
export OPENAI_API_VERSION=your_api_version
41-
export OPENAI_API_BASE=your_api_base
42-
export OPENAI_API_KEY=your_azure_openai_api_key
43-
export DEPLOYMENT_NAME=your_deployment_name
39+
export OPENAI_API_TYPE=azure
40+
export OPENAI_API_VERSION=your_api_version
41+
export OPENAI_API_BASE=your_api_base
42+
export OPENAI_API_KEY=your_azure_openai_api_key
43+
export DEPLOYMENT_NAME=your_deployment_name
4444
```
45-
45+
4646
Remember to replace the placeholders with your actual API keys and other required information.
4747

4848
```python

codeinterpreterapi/agents/functions_agent.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,22 @@
1616
from langchain.callbacks.base import BaseCallbackManager
1717
from langchain.callbacks.manager import Callbacks
1818
from langchain.chat_models.openai import ChatOpenAI
19-
from langchain.prompts.chat import (BaseMessagePromptTemplate,
20-
ChatPromptTemplate,
21-
HumanMessagePromptTemplate,
22-
MessagesPlaceholder)
23-
from langchain.schema import (AgentAction, AgentFinish, AIMessage, BaseMessage,
24-
BasePromptTemplate, FunctionMessage,
25-
OutputParserException, SystemMessage)
19+
from langchain.prompts.chat import (
20+
BaseMessagePromptTemplate,
21+
ChatPromptTemplate,
22+
HumanMessagePromptTemplate,
23+
MessagesPlaceholder,
24+
)
25+
from langchain.schema import (
26+
AgentAction,
27+
AgentFinish,
28+
AIMessage,
29+
BaseMessage,
30+
BasePromptTemplate,
31+
FunctionMessage,
32+
OutputParserException,
33+
SystemMessage,
34+
)
2635
from langchain.tools import BaseTool
2736
from langchain.tools.convert_to_openai import format_tool_to_openai_function
2837
from pydantic import root_validator

codeinterpreterapi/prompts/remove_dl_link.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from langchain.prompts.chat import (ChatPromptTemplate,
2-
HumanMessagePromptTemplate)
1+
from langchain.prompts.chat import ChatPromptTemplate, HumanMessagePromptTemplate
32
from langchain.schema import AIMessage, HumanMessage, SystemMessage
43

54
remove_dl_link_prompt = ChatPromptTemplate(

codeinterpreterapi/session.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@
2222
from langchain.tools import BaseTool, StructuredTool
2323

2424
from codeinterpreterapi.agents import OpenAIFunctionsAgent
25-
from codeinterpreterapi.chains import (get_file_modifications,
26-
remove_download_link)
25+
from codeinterpreterapi.chains import get_file_modifications, remove_download_link
2726
from codeinterpreterapi.config import settings
2827
from codeinterpreterapi.prompts import code_interpreter_system_message
29-
from codeinterpreterapi.schema import (CodeInput, CodeInterpreterResponse,
30-
File, UserRequest)
31-
from codeinterpreterapi.utils import (CodeAgentOutputParser,
32-
CodeCallbackHandler,
33-
CodeChatAgentOutputParser)
28+
from codeinterpreterapi.schema import (
29+
CodeInput,
30+
CodeInterpreterResponse,
31+
File,
32+
UserRequest,
33+
)
34+
from codeinterpreterapi.utils import (
35+
CodeAgentOutputParser,
36+
CodeCallbackHandler,
37+
CodeChatAgentOutputParser,
38+
)
3439

3540

3641
class CodeInterpreterSession:
@@ -86,15 +91,20 @@ def _choose_llm(
8691
openai_api_base = getenv("OPENAI_API_BASE")
8792
deployment_name = getenv("DEPLOYMENT_NAME")
8893
openapi_type = getenv("OPENAI_API_TYPE")
89-
if openapi_type == "azure" and openai_api_version and openai_api_base and deployment_name:
94+
if (
95+
openapi_type == "azure"
96+
and openai_api_version
97+
and openai_api_base
98+
and deployment_name
99+
):
90100
return AzureChatOpenAI(
91101
temperature=0.03,
92102
openai_api_base=openai_api_base,
93103
openai_api_version=openai_api_version,
94104
deployment_name=deployment_name,
95105
openai_api_key=openai_api_key,
96106
max_retries=3,
97-
request_timeout=60*3
107+
request_timeout=60 * 3,
98108
)
99109
else:
100110
return ChatOpenAI(

codeinterpreterapi/utils/parser.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def _type(self) -> str:
3939

4040
class CodeChatAgentOutputParser(AgentOutputParser):
4141
def get_format_instructions(self) -> str:
42-
from langchain.agents.conversational_chat.prompt import \
43-
FORMAT_INSTRUCTIONS
42+
from langchain.agents.conversational_chat.prompt import FORMAT_INSTRUCTIONS
4443

4544
return FORMAT_INSTRUCTIONS
4645

0 commit comments

Comments
 (0)