together 1.1.3__tar.gz → 1.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {together-1.1.3 → together-1.1.5}/PKG-INFO +1 -1
- {together-1.1.3 → together-1.1.5}/pyproject.toml +1 -1
- {together-1.1.3 → together-1.1.5}/src/together/cli/api/chat.py +31 -2
- {together-1.1.3 → together-1.1.5}/src/together/cli/api/completions.py +11 -1
- {together-1.1.3 → together-1.1.5}/src/together/cli/api/finetune.py +12 -2
- {together-1.1.3 → together-1.1.5}/src/together/filemanager.py +1 -6
- {together-1.1.3 → together-1.1.5}/src/together/resources/chat/completions.py +46 -0
- {together-1.1.3 → together-1.1.5}/src/together/resources/completions.py +47 -1
- {together-1.1.3 → together-1.1.5}/src/together/types/chat_completions.py +17 -1
- {together-1.1.3 → together-1.1.5}/src/together/types/completions.py +19 -1
- {together-1.1.3 → together-1.1.5}/LICENSE +0 -0
- {together-1.1.3 → together-1.1.5}/README.md +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/abstract/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/abstract/api_requestor.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/cli/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/cli/api/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/cli/api/files.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/cli/api/images.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/cli/api/models.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/cli/cli.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/client.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/constants.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/error.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/legacy/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/legacy/base.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/legacy/complete.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/legacy/embeddings.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/legacy/files.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/legacy/finetune.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/legacy/images.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/legacy/models.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/resources/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/resources/chat/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/resources/embeddings.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/resources/files.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/resources/finetune.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/resources/images.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/resources/models.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/together_response.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/abstract.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/common.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/embeddings.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/error.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/files.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/finetune.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/images.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/types/models.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/utils/__init__.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/utils/_log.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/utils/api_helpers.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/utils/files.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/utils/tools.py +0 -0
- {together-1.1.3 → together-1.1.5}/src/together/version.py +0 -0
|
@@ -28,6 +28,9 @@ class ChatShell(cmd.Cmd):
|
|
|
28
28
|
top_p: float | None = None,
|
|
29
29
|
top_k: int | None = None,
|
|
30
30
|
repetition_penalty: float | None = None,
|
|
31
|
+
presence_penalty: float | None = None,
|
|
32
|
+
frequency_penalty: float | None = None,
|
|
33
|
+
min_p: float | None = None,
|
|
31
34
|
safety_model: str | None = None,
|
|
32
35
|
system_message: str | None = None,
|
|
33
36
|
) -> None:
|
|
@@ -40,6 +43,9 @@ class ChatShell(cmd.Cmd):
|
|
|
40
43
|
self.top_p = top_p
|
|
41
44
|
self.top_k = top_k
|
|
42
45
|
self.repetition_penalty = repetition_penalty
|
|
46
|
+
self.presence_penalty = presence_penalty
|
|
47
|
+
self.frequency_penalty = frequency_penalty
|
|
48
|
+
self.min_p = min_p
|
|
43
49
|
self.safety_model = safety_model
|
|
44
50
|
self.system_message = system_message
|
|
45
51
|
|
|
@@ -69,6 +75,9 @@ class ChatShell(cmd.Cmd):
|
|
|
69
75
|
top_p=self.top_p,
|
|
70
76
|
top_k=self.top_k,
|
|
71
77
|
repetition_penalty=self.repetition_penalty,
|
|
78
|
+
presence_penalty=self.presence_penalty,
|
|
79
|
+
frequency_penalty=self.frequency_penalty,
|
|
80
|
+
min_p=self.min_p,
|
|
72
81
|
safety_model=self.safety_model,
|
|
73
82
|
stream=True,
|
|
74
83
|
):
|
|
@@ -76,13 +85,12 @@ class ChatShell(cmd.Cmd):
|
|
|
76
85
|
assert isinstance(chunk, ChatCompletionChunk)
|
|
77
86
|
assert chunk.choices
|
|
78
87
|
assert chunk.choices[0].delta
|
|
79
|
-
assert chunk.choices[0].delta.content
|
|
80
88
|
|
|
81
89
|
token = chunk.choices[0].delta.content
|
|
82
90
|
|
|
83
91
|
click.echo(token, nl=False)
|
|
84
92
|
|
|
85
|
-
output += token
|
|
93
|
+
output += token or ""
|
|
86
94
|
|
|
87
95
|
click.echo("\n")
|
|
88
96
|
|
|
@@ -109,6 +117,10 @@ class ChatShell(cmd.Cmd):
|
|
|
109
117
|
@click.option("--temperature", type=float, help="Sampling temperature")
|
|
110
118
|
@click.option("--top-p", type=int, help="Top p sampling")
|
|
111
119
|
@click.option("--top-k", type=float, help="Top k sampling")
|
|
120
|
+
@click.option("--repetition-penalty", type=float, help="Repetition penalty")
|
|
121
|
+
@click.option("--presence-penalty", type=float, help="Presence penalty")
|
|
122
|
+
@click.option("--frequency-penalty", type=float, help="Frequency penalty")
|
|
123
|
+
@click.option("--min-p", type=float, help="Minimum p")
|
|
112
124
|
@click.option("--safety-model", type=str, help="Moderation model")
|
|
113
125
|
@click.option("--system-message", type=str, help="System message to use for the chat")
|
|
114
126
|
def interactive(
|
|
@@ -120,6 +132,9 @@ def interactive(
|
|
|
120
132
|
top_p: float | None = None,
|
|
121
133
|
top_k: int | None = None,
|
|
122
134
|
repetition_penalty: float | None = None,
|
|
135
|
+
presence_penalty: float | None = None,
|
|
136
|
+
frequency_penalty: float | None = None,
|
|
137
|
+
min_p: float | None = None,
|
|
123
138
|
safety_model: str | None = None,
|
|
124
139
|
system_message: str | None = None,
|
|
125
140
|
) -> None:
|
|
@@ -135,6 +150,9 @@ def interactive(
|
|
|
135
150
|
top_p=top_p,
|
|
136
151
|
top_k=top_k,
|
|
137
152
|
repetition_penalty=repetition_penalty,
|
|
153
|
+
presence_penalty=presence_penalty,
|
|
154
|
+
frequency_penalty=frequency_penalty,
|
|
155
|
+
min_p=min_p,
|
|
138
156
|
safety_model=safety_model,
|
|
139
157
|
system_message=system_message,
|
|
140
158
|
).cmdloop()
|
|
@@ -158,6 +176,11 @@ def interactive(
|
|
|
158
176
|
@click.option("--top-p", type=int, help="Top p sampling")
|
|
159
177
|
@click.option("--top-k", type=float, help="Top k sampling")
|
|
160
178
|
@click.option("--repetition-penalty", type=float, help="Repetition penalty")
|
|
179
|
+
@click.option("--presence-penalty", type=float, help="Presence penalty sampling method")
|
|
180
|
+
@click.option(
|
|
181
|
+
"--frequency-penalty", type=float, help="Frequency penalty sampling method"
|
|
182
|
+
)
|
|
183
|
+
@click.option("--min-p", type=float, help="Min p sampling")
|
|
161
184
|
@click.option("--no-stream", is_flag=True, help="Disable streaming")
|
|
162
185
|
@click.option("--logprobs", type=int, help="Return logprobs. Only works with --raw.")
|
|
163
186
|
@click.option("--echo", is_flag=True, help="Echo prompt. Only works with --raw.")
|
|
@@ -174,6 +197,9 @@ def chat(
|
|
|
174
197
|
top_p: float | None = None,
|
|
175
198
|
top_k: int | None = None,
|
|
176
199
|
repetition_penalty: float | None = None,
|
|
200
|
+
presence_penalty: float | None = None,
|
|
201
|
+
frequency_penalty: float | None = None,
|
|
202
|
+
min_p: float | None = None,
|
|
177
203
|
no_stream: bool = False,
|
|
178
204
|
logprobs: int | None = None,
|
|
179
205
|
echo: bool | None = None,
|
|
@@ -195,6 +221,9 @@ def chat(
|
|
|
195
221
|
max_tokens=max_tokens,
|
|
196
222
|
stop=stop,
|
|
197
223
|
repetition_penalty=repetition_penalty,
|
|
224
|
+
presence_penalty=presence_penalty,
|
|
225
|
+
frequency_penalty=frequency_penalty,
|
|
226
|
+
min_p=min_p,
|
|
198
227
|
stream=not no_stream,
|
|
199
228
|
logprobs=logprobs,
|
|
200
229
|
echo=echo,
|
|
@@ -14,7 +14,6 @@ from together.types.completions import CompletionChoicesChunk, CompletionRespons
|
|
|
14
14
|
@click.pass_context
|
|
15
15
|
@click.argument("prompt", type=str, required=True)
|
|
16
16
|
@click.option("--model", type=str, required=True, help="Model name")
|
|
17
|
-
@click.option("--no-stream", is_flag=True, help="Disable streaming")
|
|
18
17
|
@click.option("--max-tokens", type=int, help="Max tokens to generate")
|
|
19
18
|
@click.option(
|
|
20
19
|
"--stop", type=str, multiple=True, help="List of strings to stop generation"
|
|
@@ -22,6 +21,11 @@ from together.types.completions import CompletionChoicesChunk, CompletionRespons
|
|
|
22
21
|
@click.option("--temperature", type=float, help="Sampling temperature")
|
|
23
22
|
@click.option("--top-p", type=int, help="Top p sampling")
|
|
24
23
|
@click.option("--top-k", type=float, help="Top k sampling")
|
|
24
|
+
@click.option("--repetition-penalty", type=float, help="Repetition penalty")
|
|
25
|
+
@click.option("--presence-penalty", type=float, help="Presence penalty")
|
|
26
|
+
@click.option("--frequency-penalty", type=float, help="Frequency penalty")
|
|
27
|
+
@click.option("--min-p", type=float, help="Minimum p")
|
|
28
|
+
@click.option("--no-stream", is_flag=True, help="Disable streaming")
|
|
25
29
|
@click.option("--logprobs", type=int, help="Return logprobs. Only works with --raw.")
|
|
26
30
|
@click.option("--echo", is_flag=True, help="Echo prompt. Only works with --raw.")
|
|
27
31
|
@click.option("--n", type=int, help="Number of output generations")
|
|
@@ -37,6 +41,9 @@ def completions(
|
|
|
37
41
|
top_p: float | None = None,
|
|
38
42
|
top_k: int | None = None,
|
|
39
43
|
repetition_penalty: float | None = None,
|
|
44
|
+
presence_penalty: float | None = None,
|
|
45
|
+
frequency_penalty: float | None = None,
|
|
46
|
+
min_p: float | None = None,
|
|
40
47
|
no_stream: bool = False,
|
|
41
48
|
logprobs: int | None = None,
|
|
42
49
|
echo: bool | None = None,
|
|
@@ -56,6 +63,9 @@ def completions(
|
|
|
56
63
|
max_tokens=max_tokens,
|
|
57
64
|
stop=stop,
|
|
58
65
|
repetition_penalty=repetition_penalty,
|
|
66
|
+
presence_penalty=presence_penalty,
|
|
67
|
+
frequency_penalty=frequency_penalty,
|
|
68
|
+
min_p=min_p,
|
|
59
69
|
stream=not no_stream,
|
|
60
70
|
logprobs=logprobs,
|
|
61
71
|
echo=echo,
|
|
@@ -107,10 +107,20 @@ def retrieve(ctx: click.Context, fine_tune_id: str) -> None:
|
|
|
107
107
|
@fine_tuning.command()
|
|
108
108
|
@click.pass_context
|
|
109
109
|
@click.argument("fine_tune_id", type=str, required=True)
|
|
110
|
-
|
|
110
|
+
@click.option(
|
|
111
|
+
"--quiet", is_flag=True, help="Do not prompt for confirmation before cancelling job"
|
|
112
|
+
)
|
|
113
|
+
def cancel(ctx: click.Context, fine_tune_id: str, quiet: bool = False) -> None:
|
|
111
114
|
"""Cancel fine-tuning job"""
|
|
112
115
|
client: Together = ctx.obj
|
|
113
|
-
|
|
116
|
+
if not quiet:
|
|
117
|
+
confirm_response = input(
|
|
118
|
+
"You will be billed for any completed training steps upon cancellation. "
|
|
119
|
+
f"Do you want to cancel job {fine_tune_id}? [y/N]"
|
|
120
|
+
)
|
|
121
|
+
if "y" not in confirm_response.lower():
|
|
122
|
+
click.echo({"status": "Cancel not submitted"})
|
|
123
|
+
return
|
|
114
124
|
response = client.fine_tuning.cancel(fine_tune_id)
|
|
115
125
|
|
|
116
126
|
click.echo(json.dumps(response.model_dump(), indent=4))
|
|
@@ -103,13 +103,8 @@ def _prepare_output(
|
|
|
103
103
|
if "x-tar" in content_type.lower():
|
|
104
104
|
remote_name += ".tar.gz"
|
|
105
105
|
|
|
106
|
-
elif "zstd" in content_type.lower() or step != -1:
|
|
107
|
-
remote_name += ".tar.zst"
|
|
108
|
-
|
|
109
106
|
else:
|
|
110
|
-
|
|
111
|
-
f"Unknown file type {content_type} found. Aborting download."
|
|
112
|
-
)
|
|
107
|
+
remote_name += ".tar.zst"
|
|
113
108
|
|
|
114
109
|
return Path(remote_name)
|
|
115
110
|
|
|
@@ -28,6 +28,10 @@ class ChatCompletions:
|
|
|
28
28
|
top_p: float | None = None,
|
|
29
29
|
top_k: int | None = None,
|
|
30
30
|
repetition_penalty: float | None = None,
|
|
31
|
+
presence_penalty: float | None = None,
|
|
32
|
+
frequency_penalty: float | None = None,
|
|
33
|
+
min_p: float | None = None,
|
|
34
|
+
logit_bias: Dict[str, float] | None = None,
|
|
31
35
|
stream: bool = False,
|
|
32
36
|
logprobs: int | None = None,
|
|
33
37
|
echo: bool | None = None,
|
|
@@ -59,6 +63,21 @@ class ChatCompletions:
|
|
|
59
63
|
repetition_penalty (float, optional): A number that controls the diversity of generated text
|
|
60
64
|
by reducing the likelihood of repeated sequences. Higher values decrease repetition.
|
|
61
65
|
Defaults to None.
|
|
66
|
+
presence_penalty (float, optional): A number that controls the likelihood of tokens based on if they have
|
|
67
|
+
appeared in the text. Positive values decrease the likelihood of repeated tokens or phrases.
|
|
68
|
+
Must be in the range [-2, 2].
|
|
69
|
+
Defaults to None.
|
|
70
|
+
frequency_penalty (float, optional): A number that controls the likelihood of tokens based on the frequency
|
|
71
|
+
of their appearance in the text. Positive decrease the likelihood of repeated tokens or phrases.
|
|
72
|
+
Must be in the range [-2, 2].
|
|
73
|
+
Defaults to None.
|
|
74
|
+
min_p (float, optional): A number that controls the minimum percentage value that a token must reach to
|
|
75
|
+
be considered during sampling.
|
|
76
|
+
Must be in the range [0, 1].
|
|
77
|
+
Defaults to None.
|
|
78
|
+
logit_bias (Dict[str, float], optional): A dictionary of tokens and their bias values that modify the
|
|
79
|
+
likelihood of specific tokens being sampled. Bias values must be in the range [-100, 100].
|
|
80
|
+
Defaults to None.
|
|
62
81
|
stream (bool, optional): Flag indicating whether to stream the generated completions.
|
|
63
82
|
Defaults to False.
|
|
64
83
|
logprobs (int, optional): Number of top-k logprobs to return
|
|
@@ -100,6 +119,10 @@ class ChatCompletions:
|
|
|
100
119
|
max_tokens=max_tokens,
|
|
101
120
|
stop=stop,
|
|
102
121
|
repetition_penalty=repetition_penalty,
|
|
122
|
+
presence_penalty=presence_penalty,
|
|
123
|
+
frequency_penalty=frequency_penalty,
|
|
124
|
+
min_p=min_p,
|
|
125
|
+
logit_bias=logit_bias,
|
|
103
126
|
stream=stream,
|
|
104
127
|
logprobs=logprobs,
|
|
105
128
|
echo=echo,
|
|
@@ -142,6 +165,10 @@ class AsyncChatCompletions:
|
|
|
142
165
|
top_p: float | None = None,
|
|
143
166
|
top_k: int | None = None,
|
|
144
167
|
repetition_penalty: float | None = None,
|
|
168
|
+
presence_penalty: float | None = None,
|
|
169
|
+
frequency_penalty: float | None = None,
|
|
170
|
+
min_p: float | None = None,
|
|
171
|
+
logit_bias: Dict[str, float] | None = None,
|
|
145
172
|
stream: bool = False,
|
|
146
173
|
logprobs: int | None = None,
|
|
147
174
|
echo: bool | None = None,
|
|
@@ -173,6 +200,21 @@ class AsyncChatCompletions:
|
|
|
173
200
|
repetition_penalty (float, optional): A number that controls the diversity of generated text
|
|
174
201
|
by reducing the likelihood of repeated sequences. Higher values decrease repetition.
|
|
175
202
|
Defaults to None.
|
|
203
|
+
presence_penalty (float, optional): A number that controls the likelihood of tokens based on if they have
|
|
204
|
+
appeared in the text. Positive values decrease the likelihood of repeated tokens or phrases.
|
|
205
|
+
Must be in the range [-2, 2].
|
|
206
|
+
Defaults to None.
|
|
207
|
+
frequency_penalty (float, optional): A number that controls the likelihood of tokens based on the frequency
|
|
208
|
+
of their appearance in the text. Positive decrease the likelihood of repeated tokens or phrases.
|
|
209
|
+
Must be in the range [-2, 2].
|
|
210
|
+
Defaults to None.
|
|
211
|
+
min_p (float, optional): A number that controls the minimum percentage value that a token must reach to
|
|
212
|
+
be considered during sampling.
|
|
213
|
+
Must be in the range [0, 1].
|
|
214
|
+
Defaults to None.
|
|
215
|
+
logit_bias (Dict[str, float], optional): A dictionary of tokens and their bias values that modify the
|
|
216
|
+
likelihood of specific tokens being sampled. Bias values must be in the range [-100, 100].
|
|
217
|
+
Defaults to None.
|
|
176
218
|
stream (bool, optional): Flag indicating whether to stream the generated completions.
|
|
177
219
|
Defaults to False.
|
|
178
220
|
logprobs (int, optional): Number of top-k logprobs to return
|
|
@@ -214,6 +256,10 @@ class AsyncChatCompletions:
|
|
|
214
256
|
max_tokens=max_tokens,
|
|
215
257
|
stop=stop,
|
|
216
258
|
repetition_penalty=repetition_penalty,
|
|
259
|
+
presence_penalty=presence_penalty,
|
|
260
|
+
frequency_penalty=frequency_penalty,
|
|
261
|
+
min_p=min_p,
|
|
262
|
+
logit_bias=logit_bias,
|
|
217
263
|
stream=stream,
|
|
218
264
|
logprobs=logprobs,
|
|
219
265
|
echo=echo,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import AsyncGenerator, Iterator, List
|
|
3
|
+
from typing import AsyncGenerator, Dict, Iterator, List
|
|
4
4
|
|
|
5
5
|
from together.abstract import api_requestor
|
|
6
6
|
from together.together_response import TogetherResponse
|
|
@@ -28,6 +28,10 @@ class Completions:
|
|
|
28
28
|
top_p: float | None = None,
|
|
29
29
|
top_k: int | None = None,
|
|
30
30
|
repetition_penalty: float | None = None,
|
|
31
|
+
presence_penalty: float | None = None,
|
|
32
|
+
frequency_penalty: float | None = None,
|
|
33
|
+
min_p: float | None = None,
|
|
34
|
+
logit_bias: Dict[str, float] | None = None,
|
|
31
35
|
stream: bool = False,
|
|
32
36
|
logprobs: int | None = None,
|
|
33
37
|
echo: bool | None = None,
|
|
@@ -55,6 +59,21 @@ class Completions:
|
|
|
55
59
|
repetition_penalty (float, optional): A number that controls the diversity of generated text
|
|
56
60
|
by reducing the likelihood of repeated sequences. Higher values decrease repetition.
|
|
57
61
|
Defaults to None.
|
|
62
|
+
presence_penalty (float, optional): A number that controls the likelihood of tokens based on if they have
|
|
63
|
+
appeared in the text. Positive values decrease the likelihood of repeated tokens or phrases.
|
|
64
|
+
Must be in the range [-2, 2].
|
|
65
|
+
Defaults to None.
|
|
66
|
+
frequency_penalty (float, optional): A number that controls the likelihood of tokens based on the frequency
|
|
67
|
+
of their appearance in the text. Positive decrease the likelihood of repeated tokens or phrases.
|
|
68
|
+
Must be in the range [-2, 2].
|
|
69
|
+
Defaults to None.
|
|
70
|
+
min_p (float, optional): A number that controls the minimum percentage value that a token must reach to
|
|
71
|
+
be considered during sampling.
|
|
72
|
+
Must be in the range [0, 1].
|
|
73
|
+
Defaults to None.
|
|
74
|
+
logit_bias (Dict[str, float], optional): A dictionary of tokens and their bias values that modify the
|
|
75
|
+
likelihood of specific tokens being sampled. Bias values must be in the range [-100, 100].
|
|
76
|
+
Defaults to None.
|
|
58
77
|
stream (bool, optional): Flag indicating whether to stream the generated completions.
|
|
59
78
|
Defaults to False.
|
|
60
79
|
logprobs (int, optional): Number of top-k logprobs to return
|
|
@@ -85,6 +104,10 @@ class Completions:
|
|
|
85
104
|
max_tokens=max_tokens,
|
|
86
105
|
stop=stop,
|
|
87
106
|
repetition_penalty=repetition_penalty,
|
|
107
|
+
presence_penalty=presence_penalty,
|
|
108
|
+
frequency_penalty=frequency_penalty,
|
|
109
|
+
min_p=min_p,
|
|
110
|
+
logit_bias=logit_bias,
|
|
88
111
|
stream=stream,
|
|
89
112
|
logprobs=logprobs,
|
|
90
113
|
echo=echo,
|
|
@@ -124,6 +147,10 @@ class AsyncCompletions:
|
|
|
124
147
|
top_p: float | None = None,
|
|
125
148
|
top_k: int | None = None,
|
|
126
149
|
repetition_penalty: float | None = None,
|
|
150
|
+
presence_penalty: float | None = None,
|
|
151
|
+
frequency_penalty: float | None = None,
|
|
152
|
+
min_p: float | None = None,
|
|
153
|
+
logit_bias: Dict[str, float] | None = None,
|
|
127
154
|
stream: bool = False,
|
|
128
155
|
logprobs: int | None = None,
|
|
129
156
|
echo: bool | None = None,
|
|
@@ -151,6 +178,21 @@ class AsyncCompletions:
|
|
|
151
178
|
repetition_penalty (float, optional): A number that controls the diversity of generated text
|
|
152
179
|
by reducing the likelihood of repeated sequences. Higher values decrease repetition.
|
|
153
180
|
Defaults to None.
|
|
181
|
+
presence_penalty (float, optional): A number that controls the likelihood of tokens based on if they have
|
|
182
|
+
appeared in the text. Positive values decrease the likelihood of repeated tokens or phrases.
|
|
183
|
+
Must be in the range [-2, 2].
|
|
184
|
+
Defaults to None.
|
|
185
|
+
frequency_penalty (float, optional): A number that controls the likelihood of tokens based on the frequency
|
|
186
|
+
of their appearance in the text. Positive decrease the likelihood of repeated tokens or phrases.
|
|
187
|
+
Must be in the range [-2, 2].
|
|
188
|
+
Defaults to None.
|
|
189
|
+
min_p (float, optional): A number that controls the minimum percentage value that a token must reach to
|
|
190
|
+
be considered during sampling.
|
|
191
|
+
Must be in the range [0, 1].
|
|
192
|
+
Defaults to None.
|
|
193
|
+
logit_bias (Dict[str, float], optional): A dictionary of tokens and their bias values that modify the
|
|
194
|
+
likelihood of specific tokens being sampled. Bias values must be in the range [-100, 100].
|
|
195
|
+
Defaults to None.
|
|
154
196
|
stream (bool, optional): Flag indicating whether to stream the generated completions.
|
|
155
197
|
Defaults to False.
|
|
156
198
|
logprobs (int, optional): Number of top-k logprobs to return
|
|
@@ -181,6 +223,10 @@ class AsyncCompletions:
|
|
|
181
223
|
max_tokens=max_tokens,
|
|
182
224
|
stop=stop,
|
|
183
225
|
repetition_penalty=repetition_penalty,
|
|
226
|
+
presence_penalty=presence_penalty,
|
|
227
|
+
frequency_penalty=frequency_penalty,
|
|
228
|
+
min_p=min_p,
|
|
229
|
+
logit_bias=logit_bias,
|
|
184
230
|
stream=stream,
|
|
185
231
|
logprobs=logprobs,
|
|
186
232
|
echo=echo,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import warnings
|
|
3
4
|
from enum import Enum
|
|
4
5
|
from typing import Any, Dict, List
|
|
5
6
|
|
|
6
|
-
from pydantic import Field
|
|
7
|
+
from pydantic import Field, model_validator
|
|
8
|
+
from typing_extensions import Self
|
|
7
9
|
|
|
8
10
|
from together.types.abstract import BaseModel
|
|
9
11
|
from together.types.common import (
|
|
@@ -87,6 +89,10 @@ class ChatCompletionRequest(BaseModel):
|
|
|
87
89
|
top_p: float | None = None
|
|
88
90
|
top_k: int | None = None
|
|
89
91
|
repetition_penalty: float | None = None
|
|
92
|
+
presence_penalty: float | None = None
|
|
93
|
+
frequency_penalty: float | None = None
|
|
94
|
+
min_p: float | None = None
|
|
95
|
+
logit_bias: Dict[str, float] | None = None
|
|
90
96
|
# stream SSE token chunks
|
|
91
97
|
stream: bool = False
|
|
92
98
|
# return logprobs
|
|
@@ -103,6 +109,16 @@ class ChatCompletionRequest(BaseModel):
|
|
|
103
109
|
tools: List[Tools] | None = None
|
|
104
110
|
tool_choice: ToolChoice | ToolChoiceEnum | None = None
|
|
105
111
|
|
|
112
|
+
# Raise warning if repetition_penalty is used with presence_penalty or frequency_penalty
|
|
113
|
+
@model_validator(mode="after")
|
|
114
|
+
def verify_parameters(self) -> Self:
|
|
115
|
+
if self.repetition_penalty:
|
|
116
|
+
if self.presence_penalty or self.frequency_penalty:
|
|
117
|
+
warnings.warn(
|
|
118
|
+
"repetition_penalty is not advisable to be used alongside presence_penalty or frequency_penalty"
|
|
119
|
+
)
|
|
120
|
+
return self
|
|
121
|
+
|
|
106
122
|
|
|
107
123
|
class ChatCompletionChoicesData(BaseModel):
|
|
108
124
|
index: int | None = None
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import warnings
|
|
4
|
+
from typing import Dict, List
|
|
5
|
+
|
|
6
|
+
from pydantic import model_validator
|
|
7
|
+
from typing_extensions import Self
|
|
4
8
|
|
|
5
9
|
from together.types.abstract import BaseModel
|
|
6
10
|
from together.types.common import (
|
|
@@ -27,6 +31,10 @@ class CompletionRequest(BaseModel):
|
|
|
27
31
|
top_p: float | None = None
|
|
28
32
|
top_k: int | None = None
|
|
29
33
|
repetition_penalty: float | None = None
|
|
34
|
+
presence_penalty: float | None = None
|
|
35
|
+
frequency_penalty: float | None = None
|
|
36
|
+
min_p: float | None = None
|
|
37
|
+
logit_bias: Dict[str, float] | None = None
|
|
30
38
|
# stream SSE token chunks
|
|
31
39
|
stream: bool = False
|
|
32
40
|
# return logprobs
|
|
@@ -39,6 +47,16 @@ class CompletionRequest(BaseModel):
|
|
|
39
47
|
# moderation model
|
|
40
48
|
safety_model: str | None = None
|
|
41
49
|
|
|
50
|
+
# Raise warning if repetition_penalty is used with presence_penalty or frequency_penalty
|
|
51
|
+
@model_validator(mode="after")
|
|
52
|
+
def verify_parameters(self) -> Self:
|
|
53
|
+
if self.repetition_penalty:
|
|
54
|
+
if self.presence_penalty or self.frequency_penalty:
|
|
55
|
+
warnings.warn(
|
|
56
|
+
"repetition_penalty is not advisable to be used alongside presence_penalty or frequency_penalty"
|
|
57
|
+
)
|
|
58
|
+
return self
|
|
59
|
+
|
|
42
60
|
|
|
43
61
|
class CompletionChoicesData(BaseModel):
|
|
44
62
|
index: int
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|