feat(api): update via SDK Studio by stainless-app[bot] · Pull Request #59 · ContextualAI/contextual-client-python · GitHub
Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .stats.yml
30 changes: 30 additions & 0 deletions src/contextual/resources/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ def create(
messages: Iterable[generate_create_params.Message],
model: str,
avoid_commentary: bool | NotGiven = NOT_GIVEN,
max_new_tokens: int | NotGiven = NOT_GIVEN,
system_prompt: str | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -83,9 +86,18 @@ def create(
context. However, commentary may provide useful context which improves the
helpfulness of responses.

max_new_tokens: The maximum number of tokens that the model can generate in the response.

system_prompt: Instructions that the model follows when generating responses. Note that we do
not guarantee that the model follows these instructions exactly.

temperature: The sampling temperature, which affects the randomness in the response. Note
that higher temperature values can reduce groundedness

top_p: A parameter for nucleus sampling, an alternative to temperature which also
affects the randomness of the response. Note that higher top_p values can reduce
groundedness

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -102,7 +114,10 @@ def create(
"messages": messages,
"model": model,
"avoid_commentary": avoid_commentary,
"max_new_tokens": max_new_tokens,
"system_prompt": system_prompt,
"temperature": temperature,
"top_p": top_p,
},
generate_create_params.GenerateCreateParams,
),
Expand Down Expand Up @@ -140,7 +155,10 @@ async def create(
messages: Iterable[generate_create_params.Message],
model: str,
avoid_commentary: bool | NotGiven = NOT_GIVEN,
max_new_tokens: int | NotGiven = NOT_GIVEN,
system_prompt: str | NotGiven = NOT_GIVEN,
temperature: float | NotGiven = NOT_GIVEN,
top_p: float | NotGiven = NOT_GIVEN,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand Down Expand Up @@ -170,9 +188,18 @@ async def create(
context. However, commentary may provide useful context which improves the
helpfulness of responses.

max_new_tokens: The maximum number of tokens that the model can generate in the response.

system_prompt: Instructions that the model follows when generating responses. Note that we do
not guarantee that the model follows these instructions exactly.

temperature: The sampling temperature, which affects the randomness in the response. Note
that higher temperature values can reduce groundedness

top_p: A parameter for nucleus sampling, an alternative to temperature which also
affects the randomness of the response. Note that higher top_p values can reduce
groundedness

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -189,7 +216,10 @@ async def create(
"messages": messages,
"model": model,
"avoid_commentary": avoid_commentary,
"max_new_tokens": max_new_tokens,
"system_prompt": system_prompt,
"temperature": temperature,
"top_p": top_p,
},
generate_create_params.GenerateCreateParams,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class EvaluationRound(BaseModel):
num_predictions: Optional[int] = None
"""Total number of predictions made during the evaluation round"""

num_processed_predictions: Optional[int] = None
"""Number of predictions that have been processed during the evaluation round"""

num_successful_predictions: Optional[int] = None
"""Number of predictions that were successful during the evaluation round"""

Expand Down
18 changes: 17 additions & 1 deletion src/contextual/types/generate_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,32 @@ class GenerateCreateParams(TypedDict, total=False):
helpfulness of responses.
"""

max_new_tokens: int
"""The maximum number of tokens that the model can generate in the response."""

system_prompt: str
"""Instructions that the model follows when generating responses.

Note that we do not guarantee that the model follows these instructions exactly.
"""

temperature: float
"""The sampling temperature, which affects the randomness in the response.

Note that higher temperature values can reduce groundedness
"""

top_p: float
"""
A parameter for nucleus sampling, an alternative to temperature which also
affects the randomness of the response. Note that higher top_p values can reduce
groundedness
"""


class Message(TypedDict, total=False):
content: Required[str]
"""Content of the message"""

role: Required[Literal["user", "system", "assistant", "knowledge"]]
role: Required[Literal["user", "assistant"]]
"""Role of the sender"""
6 changes: 6 additions & 0 deletions tests/api_resources/test_generate.py