Spaces:
Runtime error
Runtime error
Commit
·
5759e22
1
Parent(s):
7f421ce
Update chat_completion.py
Browse files- chat_completion.py +2 -2
chat_completion.py
CHANGED
@@ -6,7 +6,7 @@ import openai
|
|
6 |
|
7 |
|
8 |
class ChatCompletion:
|
9 |
-
def __init__(self, model: str = 'gpt-3.5-turbo
|
10 |
api_key: Optional[str] = None, api_key_path: str = './openai_api_key'):
|
11 |
if api_key is None:
|
12 |
openai.api_key = api_key
|
@@ -20,7 +20,7 @@ class ChatCompletion:
|
|
20 |
self.user_messages = []
|
21 |
|
22 |
def chat(self, msg: str, setting: Optional[str] = None, model: Optional[str] = None) -> str:
|
23 |
-
if self._context_length() >
|
24 |
self.reset()
|
25 |
if setting is not None:
|
26 |
if setting not in self.system_messages:
|
|
|
6 |
|
7 |
|
8 |
class ChatCompletion:
|
9 |
+
def __init__(self, model: str = 'gpt-3.5-turbo',
|
10 |
api_key: Optional[str] = None, api_key_path: str = './openai_api_key'):
|
11 |
if api_key is None:
|
12 |
openai.api_key = api_key
|
|
|
20 |
self.user_messages = []
|
21 |
|
22 |
def chat(self, msg: str, setting: Optional[str] = None, model: Optional[str] = None) -> str:
|
23 |
+
if self._context_length() > 4096:
|
24 |
self.reset()
|
25 |
if setting is not None:
|
26 |
if setting not in self.system_messages:
|