15
15
class OpenAiChatPromptDriver (BasePromptDriver ):
16
16
"""
17
17
Attributes:
18
- base_url: API URL.
19
- api_key: API key to pass directly. Defaults to `OPENAI_API_KEY` environment variable.
20
- max_tokens: Optional maximum return tokens. If not specified, no value will be passed to the API. If set, the
21
- value will be bounded to the maximum possible as determined by the tokenizer.
22
- model: OpenAI model name.
23
- organization: OpenAI organization. Defaults to `OPENAI_ORG_ID` environment variable.
24
- client: OpenAI client. Defaults to `openai.OpenAI`.
25
- tokenizer: Custom `OpenAiTokenizer`.
26
- user: OpenAI user.
27
- response_format: Optional response format. Currently only supports `json_object` which will enable OpenAi's JSON mode.
28
- seed: Optional seed.
18
+ base_url: An optional OpenAi API URL.
19
+ api_key: An optional OpenAi API key. If not provided, the `OPENAI_API_KEY` environment variable will be used.
20
+ organization: An optional OpenAI organization. If not provided, the `OPENAI_ORG_ID` environment variable will be used.
21
+ client: An `openai.OpenAI` client.
22
+ model: An OpenAI model name.
23
+ tokenizer: An `OpenAiTokenizer`.
24
+ user: An optional user id. Can be used to track requests by user.
25
+ response_format: An optional OpenAi Chat Completion response format. Currently only supports `json_object` which will enable OpenAi's JSON mode.
26
+ seed: An optional OpenAi Chat Completion seed.
27
+ ignored_exception_types: An optional tuple of exception types to ignore. Defaults to OpenAI's known exception types.
29
28
_ratelimit_request_limit: The maximum number of requests allowed in the current rate limit window.
30
29
_ratelimit_requests_remaining: The number of requests remaining in the current rate limit window.
31
30
_ratelimit_requests_reset_at: The time at which the current rate limit window resets.
@@ -34,10 +33,9 @@ class OpenAiChatPromptDriver(BasePromptDriver):
34
33
_ratelimit_tokens_reset_at: The time at which the current rate limit window resets.
35
34
"""
36
35
37
- base_url : str = field (default = None , kw_only = True )
36
+ base_url : Optional [ str ] = field (default = None , kw_only = True )
38
37
api_key : Optional [str ] = field (default = None , kw_only = True )
39
38
organization : Optional [str ] = field (default = None , kw_only = True )
40
- seed : Optional [int ] = field (default = None , kw_only = True )
41
39
client : openai .OpenAI = field (
42
40
default = Factory (
43
41
lambda self : openai .OpenAI (api_key = self .api_key , base_url = self .base_url , organization = self .organization ),
@@ -48,8 +46,9 @@ class OpenAiChatPromptDriver(BasePromptDriver):
48
46
tokenizer : OpenAiTokenizer = field (
49
47
default = Factory (lambda self : OpenAiTokenizer (model = self .model ), takes_self = True ), kw_only = True
50
48
)
51
- user : str = field (default = "" , kw_only = True )
49
+ user : Optional [ str ] = field (default = None , kw_only = True )
52
50
response_format : Optional [Literal ["json_object" ]] = field (default = None , kw_only = True )
51
+ seed : Optional [int ] = field (default = None , kw_only = True )
53
52
ignored_exception_types : Tuple [Type [Exception ], ...] = field (
54
53
default = Factory (
55
54
lambda : (
0 commit comments