Skip to content

feat(api): update via SDK Studio #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2025
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
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 35
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-f12595f01023503858500b15936a1d0d38701e48552d34c98b00a41205d2b8da.yml
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-d79ccb778953ad5c2ae4b99115429c8b3f68b3b23d9b6d90b1b40393f11a4383.yml
8 changes: 4 additions & 4 deletions src/contextual/resources/agents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def create(
suggested_queries: These queries will show up as suggestions in the Contextual UI when users load
the agent. We recommend including common queries that users will ask, as well as
complex queries so users understand the types of complex queries the system can
handle.
handle. The max length of all the suggested queries is 1000.

system_prompt: Instructions that your agent references when generating responses. Note that we
do not guarantee that the system will follow these instructions exactly.
Expand Down Expand Up @@ -199,7 +199,7 @@ def update(
suggested_queries: These queries will show up as suggestions in the Contextual UI when users load
the agent. We recommend including common queries that users will ask, as well as
complex queries so users understand the types of complex queries the system can
handle.
handle. The max length of all the suggested queries is 1000.

system_prompt: Instructions that your agent references when generating responses. Note that we
do not guarantee that the system will follow these instructions exactly.
Expand Down Expand Up @@ -430,7 +430,7 @@ async def create(
suggested_queries: These queries will show up as suggestions in the Contextual UI when users load
the agent. We recommend including common queries that users will ask, as well as
complex queries so users understand the types of complex queries the system can
handle.
handle. The max length of all the suggested queries is 1000.

system_prompt: Instructions that your agent references when generating responses. Note that we
do not guarantee that the system will follow these instructions exactly.
Expand Down Expand Up @@ -493,7 +493,7 @@ async def update(
suggested_queries: These queries will show up as suggestions in the Contextual UI when users load
the agent. We recommend including common queries that users will ask, as well as
complex queries so users understand the types of complex queries the system can
handle.
handle. The max length of all the suggested queries is 1000.

system_prompt: Instructions that your agent references when generating responses. Note that we
do not guarantee that the system will follow these instructions exactly.
Expand Down
34 changes: 30 additions & 4 deletions src/contextual/resources/agents/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def create(
agent_id: str,
*,
messages: Iterable[query_create_params.Message],
include_retrieval_content_text: bool | NotGiven = NOT_GIVEN,
retrievals_only: bool | NotGiven = NOT_GIVEN,
conversation_id: str | NotGiven = NOT_GIVEN,
llm_model_id: str | NotGiven = NOT_GIVEN,
Expand All @@ -82,7 +83,14 @@ def create(
multiple objects to provide conversation history. Last message in the list must
be a `user`-sent message (i.e. `role` equals `"user"`).

retrievals_only: Set to `true` to skip generation of the response.
include_retrieval_content_text: Ignored if `retrievals_only` is True. Set to `true` to include the text of the
retrieved contents in the response. If `false`, only metadata about the
retrieved contents will be included, not content text. Content text and other
metadata can also be fetched separately using the
`/agents/{agent_id}/query/{message_id}/retrieval/info` endpoint.

retrievals_only: Set to `true` to fetch retrieval content and metadata, and then skip generation
of the response.

conversation_id: An optional alternative to providing message history in the `messages` field. If
provided, all messages in the `messages` list prior to the latest user-sent
Expand Down Expand Up @@ -119,7 +127,13 @@ def create(
extra_query=extra_query,
extra_body=extra_body,
timeout=timeout,
query=maybe_transform({"retrievals_only": retrievals_only}, query_create_params.QueryCreateParams),
query=maybe_transform(
{
"include_retrieval_content_text": include_retrieval_content_text,
"retrievals_only": retrievals_only,
},
query_create_params.QueryCreateParams,
),
),
cast_to=QueryResponse,
)
Expand Down Expand Up @@ -328,6 +342,7 @@ async def create(
agent_id: str,
*,
messages: Iterable[query_create_params.Message],
include_retrieval_content_text: bool | NotGiven = NOT_GIVEN,
retrievals_only: bool | NotGiven = NOT_GIVEN,
conversation_id: str | NotGiven = NOT_GIVEN,
llm_model_id: str | NotGiven = NOT_GIVEN,
Expand All @@ -350,7 +365,14 @@ async def create(
multiple objects to provide conversation history. Last message in the list must
be a `user`-sent message (i.e. `role` equals `"user"`).

retrievals_only: Set to `true` to skip generation of the response.
include_retrieval_content_text: Ignored if `retrievals_only` is True. Set to `true` to include the text of the
retrieved contents in the response. If `false`, only metadata about the
retrieved contents will be included, not content text. Content text and other
metadata can also be fetched separately using the
`/agents/{agent_id}/query/{message_id}/retrieval/info` endpoint.

retrievals_only: Set to `true` to fetch retrieval content and metadata, and then skip generation
of the response.

conversation_id: An optional alternative to providing message history in the `messages` field. If
provided, all messages in the `messages` list prior to the latest user-sent
Expand Down Expand Up @@ -388,7 +410,11 @@ async def create(
extra_body=extra_body,
timeout=timeout,
query=await async_maybe_transform(
{"retrievals_only": retrievals_only}, query_create_params.QueryCreateParams
{
"include_retrieval_content_text": include_retrieval_content_text,
"retrievals_only": retrievals_only,
},
query_create_params.QueryCreateParams,
),
),
cast_to=QueryResponse,
Expand Down
2 changes: 1 addition & 1 deletion src/contextual/types/agent_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AgentCreateParams(TypedDict, total=False):
These queries will show up as suggestions in the Contextual UI when users load
the agent. We recommend including common queries that users will ask, as well as
complex queries so users understand the types of complex queries the system can
handle.
handle. The max length of all the suggested queries is 1000.
"""

system_prompt: str
Expand Down
2 changes: 1 addition & 1 deletion src/contextual/types/agent_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AgentMetadata(BaseModel):
These queries will show up as suggestions in the Contextual UI when users load
the agent. We recommend including common queries that users will ask, as well as
complex queries so users understand the types of complex queries the system can
handle.
handle. The max length of all the suggested queries is 1000.
"""

system_prompt: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion src/contextual/types/agent_update_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class AgentUpdateParams(TypedDict, total=False):
These queries will show up as suggestions in the Contextual UI when users load
the agent. We recommend including common queries that users will ask, as well as
complex queries so users understand the types of complex queries the system can
handle.
handle. The max length of all the suggested queries is 1000.
"""

system_prompt: str
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import List
from typing import List, Optional
from datetime import datetime
from typing_extensions import Literal

Expand All @@ -22,6 +22,24 @@ class EvaluationRound(BaseModel):
user_email: str
"""Email of the user who launched the evaluation round"""

finished_at: Optional[datetime] = None
"""Timestamp indicating when the evaluation round finished processing"""

num_failed_predictions: Optional[int] = None
"""Number of predictions that failed during the evaluation round"""

num_predictions: Optional[int] = None
"""Total number of predictions made during the evaluation round"""

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

processing_started_at: Optional[datetime] = None
"""Timestamp indicating when the evaluation round started processing"""

summary_results: Optional[object] = None
"""Score of the evaluation round"""


class ListEvaluationJobsResponse(BaseModel):
evaluation_rounds: List[EvaluationRound]
Expand Down
14 changes: 13 additions & 1 deletion src/contextual/types/agents/query_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@ class QueryCreateParams(TypedDict, total=False):
must be a `user`-sent message (i.e. `role` equals `"user"`).
"""

include_retrieval_content_text: bool
"""Ignored if `retrievals_only` is True.

Set to `true` to include the text of the retrieved contents in the response. If
`false`, only metadata about the retrieved contents will be included, not
content text. Content text and other metadata can also be fetched separately
using the `/agents/{agent_id}/query/{message_id}/retrieval/info` endpoint.
"""

retrievals_only: bool
"""Set to `true` to skip generation of the response."""
"""
Set to `true` to fetch retrieval content and metadata, and then skip generation
of the response.
"""

conversation_id: str
"""An optional alternative to providing message history in the `messages` field.
Expand Down
10 changes: 5 additions & 5 deletions src/contextual/types/agents/query_response.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from typing import Dict, List, Optional
from typing import List, Optional
from typing_extensions import Literal

from ..._models import BaseModel
Expand All @@ -27,11 +27,11 @@ class RetrievalContent(BaseModel):
Will be `file` for any docs ingested through ingestion API.
"""

content: Optional[str] = None
"""Retrieved content"""
content_text: Optional[str] = None
"""Text of the retrieved content.

extras: Optional[Dict[str, str]] = None
"""Reserved for extra metadata"""
Included in response to a query if `include_retrieval_content_text` is True
"""

number: Optional[int] = None
"""Index of the retrieved item in the retrieval_contents list (starting from 1)"""
Expand Down
3 changes: 3 additions & 0 deletions src/contextual/types/agents/retrieval_info_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class ContentMetadata(BaseModel):
content_id: str
"""Id of the content."""

content_text: str
"""Text of the content."""

height: float
"""Height of the image."""

Expand Down
2 changes: 2 additions & 0 deletions tests/api_resources/agents/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def test_method_create_with_all_params(self, client: ContextualAI) -> None:
"role": "user",
}
],
include_retrieval_content_text=True,
retrievals_only=True,
conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
llm_model_id="llm_model_id",
Expand Down Expand Up @@ -287,6 +288,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncContextual
"role": "user",
}
],
include_retrieval_content_text=True,
retrievals_only=True,
conversation_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
llm_model_id="llm_model_id",
Expand Down