Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion dsp/modules/gpt3.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class GPT3(LM):
api_key (Optional[str], optional): API provider Authentication token. use Defaults to None.
api_provider (Literal["openai"], optional): The API provider to use. Defaults to "openai".
model_type (Literal["chat", "text"], optional): The type of model that was specified. Mainly to decide the optimal prompting strategy. Defaults to "text".
max_tokens (int, optional): The maximum number of tokens to use. The maximum number of tokens to
return is half of this value. Defaults to 150.
**kwargs: Additional arguments to pass to the API provider.
"""

Expand All @@ -55,6 +57,7 @@ def __init__(
api_base: Optional[str] = None,
model_type: Literal["chat", "text"] = None,
system_prompt: Optional[str] = None,
max_tokens: Optional[int] = 150,
**kwargs,
):
super().__init__(model)
Expand Down Expand Up @@ -86,7 +89,7 @@ def __init__(

self.kwargs = {
"temperature": 0.0,
"max_tokens": 150,
"max_tokens": max_tokens,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
Expand Down
1 change: 1 addition & 0 deletions dsp/primitives/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def do_generate(
max_tokens_key = "max_tokens" if "max_tokens" in keys else "max_output_tokens"
new_kwargs = {
**kwargs,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How the value set by the user effects the maximum tokens passed and returned from the model is quite unclear here, would anyone be able to clarify how 101:118 relate to the eventual values passed to different models, I'll have a crack at clearing this up. Might it be possible to do the 75 checking upstream of here?

# Set the required max tokens key to the new value.
max_tokens_key: max_tokens,
"n": 1,
"temperature": 0.0,
Expand Down