jerome-white commited on
Commit
2a70816
·
1 Parent(s): 9bcad24

Max completion tokens only valid for threads

Browse files
Files changed (1) hide show
  1. mylib/_chat.py +5 -2
mylib/_chat.py CHANGED
@@ -17,9 +17,11 @@ def parse_wait_time(err):
17
  raise TypeError(err.code)
18
 
19
  class ChatController:
20
- _gpt_defaults = {
21
  'model': 'gpt-4o',
22
  'temperature': 1e-4,
 
 
23
  'max_completion_tokens': 2 ** 12,
24
  }
25
 
@@ -28,7 +30,7 @@ class ChatController:
28
  self.database = database
29
  self.retries = retries
30
 
31
- for i in self._gpt_defaults.items():
32
  kwargs.setdefault(*i)
33
 
34
  self.assistant = self.client.beta.assistants.create(
@@ -73,6 +75,7 @@ class ChatController:
73
  run = self.client.beta.threads.runs.create_and_poll(
74
  thread_id=self.thread.id,
75
  assistant_id=self.assistant.id,
 
76
  )
77
  if run.status == 'completed':
78
  return self.client.beta.threads.messages.list(
 
17
  raise TypeError(err.code)
18
 
19
  class ChatController:
20
+ _assistant_kwargs = {
21
  'model': 'gpt-4o',
22
  'temperature': 1e-4,
23
+ }
24
+ _threads_kwargs = {
25
  'max_completion_tokens': 2 ** 12,
26
  }
27
 
 
30
  self.database = database
31
  self.retries = retries
32
 
33
+ for i in self._assistant_kwargs.items():
34
  kwargs.setdefault(*i)
35
 
36
  self.assistant = self.client.beta.assistants.create(
 
75
  run = self.client.beta.threads.runs.create_and_poll(
76
  thread_id=self.thread.id,
77
  assistant_id=self.assistant.id,
78
+ **self._threads_kwargs,
79
  )
80
  if run.status == 'completed':
81
  return self.client.beta.threads.messages.list(