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
4 changes: 2 additions & 2 deletions .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-d79ccb778953ad5c2ae4b99115429c8b3f68b3b23d9b6d90b1b40393f11a4383.yml
configured_endpoints: 46
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-5298551c424bb999f258bdd6c311e96c80c70701ad59bbce19b46c788ee13bd4.yml
39 changes: 39 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Methods:
- <code title="delete /datastores/{datastore_id}/documents/{document_id}">client.datastores.documents.<a href="./src/contextual/resources/datastores/documents.py">delete</a>(document_id, \*, datastore_id) -> <a href="./src/contextual/types/datastores/document_delete_response.py">object</a></code>
- <code title="post /datastores/{datastore_id}/documents">client.datastores.documents.<a href="./src/contextual/resources/datastores/documents.py">ingest</a>(datastore_id, \*\*<a href="src/contextual/types/datastores/document_ingest_params.py">params</a>) -> <a href="./src/contextual/types/datastores/ingestion_response.py">IngestionResponse</a></code>
- <code title="get /datastores/{datastore_id}/documents/{document_id}/metadata">client.datastores.documents.<a href="./src/contextual/resources/datastores/documents.py">metadata</a>(document_id, \*, datastore_id) -> <a href="./src/contextual/types/datastores/document_metadata.py">DocumentMetadata</a></code>
- <code title="post /datastores/{datastore_id}/documents/{document_id}/metadata">client.datastores.documents.<a href="./src/contextual/resources/datastores/documents.py">set_metadata</a>(document_id, \*, datastore_id, \*\*<a href="src/contextual/types/datastores/document_set_metadata_params.py">params</a>) -> <a href="./src/contextual/types/datastores/document_metadata.py">DocumentMetadata</a></code>

# Agents

Expand Down Expand Up @@ -120,6 +121,23 @@ Types:
from contextual.types.agents import CreateDatasetResponse, DatasetMetadata, ListDatasetsResponse
```

### Tune

Types:

```python
from contextual.types.agents.datasets import TuneDeleteResponse
```

Methods:

- <code title="post /agents/{agent_id}/datasets/tune">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">create</a>(agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_create_params.py">params</a>) -> <a href="./src/contextual/types/agents/create_dataset_response.py">CreateDatasetResponse</a></code>
- <code title="get /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">retrieve</a>(dataset_name, \*, agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_retrieve_params.py">params</a>) -> BinaryAPIResponse</code>
- <code title="put /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">update</a>(dataset_name, \*, agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_update_params.py">params</a>) -> <a href="./src/contextual/types/agents/create_dataset_response.py">CreateDatasetResponse</a></code>
- <code title="get /agents/{agent_id}/datasets/tune">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">list</a>(agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_list_params.py">params</a>) -> <a href="./src/contextual/types/agents/list_datasets_response.py">ListDatasetsResponse</a></code>
- <code title="delete /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">delete</a>(dataset_name, \*, agent_id) -> <a href="./src/contextual/types/agents/datasets/tune_delete_response.py">object</a></code>
- <code title="get /agents/{agent_id}/datasets/tune/{dataset_name}/metadata">client.agents.datasets.tune.<a href="./src/contextual/resources/agents/datasets/tune.py">metadata</a>(dataset_name, \*, agent_id, \*\*<a href="src/contextual/types/agents/datasets/tune_metadata_params.py">params</a>) -> <a href="./src/contextual/types/agents/dataset_metadata.py">DatasetMetadata</a></code>

### Evaluate

Types:
Expand Down Expand Up @@ -175,6 +193,27 @@ Methods:

- <code title="get /agents/{agent_id}/tune/models">client.agents.tune.models.<a href="./src/contextual/resources/agents/tune/models.py">list</a>(agent_id) -> <a href="./src/contextual/types/agents/tune/list_tune_models_response.py">ListTuneModelsResponse</a></code>

# Users

Types:

```python
from contextual.types import (
InviteUsersResponse,
ListUsersResponse,
NewUser,
UserUpdateResponse,
UserDeactivateResponse,
)
```

Methods:

- <code title="put /users">client.users.<a href="./src/contextual/resources/users.py">update</a>(\*\*<a href="src/contextual/types/user_update_params.py">params</a>) -> <a href="./src/contextual/types/user_update_response.py">object</a></code>
- <code title="get /users">client.users.<a href="./src/contextual/resources/users.py">list</a>(\*\*<a href="src/contextual/types/user_list_params.py">params</a>) -> <a href="./src/contextual/types/list_users_response.py">ListUsersResponse</a></code>
- <code title="delete /users">client.users.<a href="./src/contextual/resources/users.py">deactivate</a>(\*\*<a href="src/contextual/types/user_deactivate_params.py">params</a>) -> <a href="./src/contextual/types/user_deactivate_response.py">object</a></code>
- <code title="post /users">client.users.<a href="./src/contextual/resources/users.py">invite</a>(\*\*<a href="src/contextual/types/user_invite_params.py">params</a>) -> <a href="./src/contextual/types/invite_users_response.py">InviteUsersResponse</a></code>

# LMUnit

Types:
Expand Down
10 changes: 9 additions & 1 deletion src/contextual/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
get_async_library,
)
from ._version import __version__
from .resources import lmunit, rerank, generate
from .resources import users, lmunit, rerank, generate
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import APIStatusError, ContextualAIError
from ._base_client import (
Expand All @@ -50,6 +50,7 @@
class ContextualAI(SyncAPIClient):
datastores: datastores.DatastoresResource
agents: agents.AgentsResource
users: users.UsersResource
lmunit: lmunit.LMUnitResource
rerank: rerank.RerankResource
generate: generate.GenerateResource
Expand Down Expand Up @@ -112,6 +113,7 @@ def __init__(

self.datastores = datastores.DatastoresResource(self)
self.agents = agents.AgentsResource(self)
self.users = users.UsersResource(self)
self.lmunit = lmunit.LMUnitResource(self)
self.rerank = rerank.RerankResource(self)
self.generate = generate.GenerateResource(self)
Expand Down Expand Up @@ -226,6 +228,7 @@ def _make_status_error(
class AsyncContextualAI(AsyncAPIClient):
datastores: datastores.AsyncDatastoresResource
agents: agents.AsyncAgentsResource
users: users.AsyncUsersResource
lmunit: lmunit.AsyncLMUnitResource
rerank: rerank.AsyncRerankResource
generate: generate.AsyncGenerateResource
Expand Down Expand Up @@ -288,6 +291,7 @@ def __init__(

self.datastores = datastores.AsyncDatastoresResource(self)
self.agents = agents.AsyncAgentsResource(self)
self.users = users.AsyncUsersResource(self)
self.lmunit = lmunit.AsyncLMUnitResource(self)
self.rerank = rerank.AsyncRerankResource(self)
self.generate = generate.AsyncGenerateResource(self)
Expand Down Expand Up @@ -403,6 +407,7 @@ class ContextualAIWithRawResponse:
def __init__(self, client: ContextualAI) -> None:
self.datastores = datastores.DatastoresResourceWithRawResponse(client.datastores)
self.agents = agents.AgentsResourceWithRawResponse(client.agents)
self.users = users.UsersResourceWithRawResponse(client.users)
self.lmunit = lmunit.LMUnitResourceWithRawResponse(client.lmunit)
self.rerank = rerank.RerankResourceWithRawResponse(client.rerank)
self.generate = generate.GenerateResourceWithRawResponse(client.generate)
Expand All @@ -412,6 +417,7 @@ class AsyncContextualAIWithRawResponse:
def __init__(self, client: AsyncContextualAI) -> None:
self.datastores = datastores.AsyncDatastoresResourceWithRawResponse(client.datastores)
self.agents = agents.AsyncAgentsResourceWithRawResponse(client.agents)
self.users = users.AsyncUsersResourceWithRawResponse(client.users)
self.lmunit = lmunit.AsyncLMUnitResourceWithRawResponse(client.lmunit)
self.rerank = rerank.AsyncRerankResourceWithRawResponse(client.rerank)
self.generate = generate.AsyncGenerateResourceWithRawResponse(client.generate)
Expand All @@ -421,6 +427,7 @@ class ContextualAIWithStreamedResponse:
def __init__(self, client: ContextualAI) -> None:
self.datastores = datastores.DatastoresResourceWithStreamingResponse(client.datastores)
self.agents = agents.AgentsResourceWithStreamingResponse(client.agents)
self.users = users.UsersResourceWithStreamingResponse(client.users)
self.lmunit = lmunit.LMUnitResourceWithStreamingResponse(client.lmunit)
self.rerank = rerank.RerankResourceWithStreamingResponse(client.rerank)
self.generate = generate.GenerateResourceWithStreamingResponse(client.generate)
Expand All @@ -430,6 +437,7 @@ class AsyncContextualAIWithStreamedResponse:
def __init__(self, client: AsyncContextualAI) -> None:
self.datastores = datastores.AsyncDatastoresResourceWithStreamingResponse(client.datastores)
self.agents = agents.AsyncAgentsResourceWithStreamingResponse(client.agents)
self.users = users.AsyncUsersResourceWithStreamingResponse(client.users)
self.lmunit = lmunit.AsyncLMUnitResourceWithStreamingResponse(client.lmunit)
self.rerank = rerank.AsyncRerankResourceWithStreamingResponse(client.rerank)
self.generate = generate.AsyncGenerateResourceWithStreamingResponse(client.generate)
Expand Down
14 changes: 14 additions & 0 deletions src/contextual/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .users import (
UsersResource,
AsyncUsersResource,
UsersResourceWithRawResponse,
AsyncUsersResourceWithRawResponse,
UsersResourceWithStreamingResponse,
AsyncUsersResourceWithStreamingResponse,
)
from .agents import (
AgentsResource,
AsyncAgentsResource,
Expand Down Expand Up @@ -54,6 +62,12 @@
"AsyncAgentsResourceWithRawResponse",
"AgentsResourceWithStreamingResponse",
"AsyncAgentsResourceWithStreamingResponse",
"UsersResource",
"AsyncUsersResource",
"UsersResourceWithRawResponse",
"AsyncUsersResourceWithRawResponse",
"UsersResourceWithStreamingResponse",
"AsyncUsersResourceWithStreamingResponse",
"LMUnitResource",
"AsyncLMUnitResource",
"LMUnitResourceWithRawResponse",
Expand Down
22 changes: 18 additions & 4 deletions src/contextual/resources/agents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def create(
self,
*,
name: str,
agent_configs: agent_create_params.AgentConfigs | NotGiven = NOT_GIVEN,
datastore_ids: List[str] | NotGiven = NOT_GIVEN,
description: str | NotGiven = NOT_GIVEN,
suggested_queries: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -128,8 +129,9 @@ def create(
Args:
name: Name of the agent

datastore_ids: The IDs of the datastore associated with the agent. Leave empty to automatically
create a new datastore.
agent_configs: The following advanced parameters are experimental and subject to change.

datastore_ids: The IDs of the datastore to associate with this agent.

description: Description of the agent

Expand All @@ -154,6 +156,7 @@ def create(
body=maybe_transform(
{
"name": name,
"agent_configs": agent_configs,
"datastore_ids": datastore_ids,
"description": description,
"suggested_queries": suggested_queries,
Expand All @@ -171,6 +174,7 @@ def update(
self,
agent_id: str,
*,
agent_configs: agent_update_params.AgentConfigs | NotGiven = NOT_GIVEN,
datastore_ids: List[str] | NotGiven = NOT_GIVEN,
llm_model_id: str | NotGiven = NOT_GIVEN,
suggested_queries: List[str] | NotGiven = NOT_GIVEN,
Expand All @@ -190,6 +194,8 @@ def update(
Args:
agent_id: ID of the agent to edit

agent_configs: The following advanced parameters are experimental and subject to change.

datastore_ids: IDs of the datastore to associate with the agent.

llm_model_id: The model ID to use for generation. Tuned models can only be used for the agents
Expand Down Expand Up @@ -218,6 +224,7 @@ def update(
f"/agents/{agent_id}",
body=maybe_transform(
{
"agent_configs": agent_configs,
"datastore_ids": datastore_ids,
"llm_model_id": llm_model_id,
"suggested_queries": suggested_queries,
Expand Down Expand Up @@ -395,6 +402,7 @@ async def create(
self,
*,
name: str,
agent_configs: agent_create_params.AgentConfigs | NotGiven = NOT_GIVEN,
datastore_ids: List[str] | NotGiven = NOT_GIVEN,
description: str | NotGiven = NOT_GIVEN,
suggested_queries: List[str] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -422,8 +430,9 @@ async def create(
Args:
name: Name of the agent

datastore_ids: The IDs of the datastore associated with the agent. Leave empty to automatically
create a new datastore.
agent_configs: The following advanced parameters are experimental and subject to change.

datastore_ids: The IDs of the datastore to associate with this agent.

description: Description of the agent

Expand All @@ -448,6 +457,7 @@ async def create(
body=await async_maybe_transform(
{
"name": name,
"agent_configs": agent_configs,
"datastore_ids": datastore_ids,
"description": description,
"suggested_queries": suggested_queries,
Expand All @@ -465,6 +475,7 @@ async def update(
self,
agent_id: str,
*,
agent_configs: agent_update_params.AgentConfigs | NotGiven = NOT_GIVEN,
datastore_ids: List[str] | NotGiven = NOT_GIVEN,
llm_model_id: str | NotGiven = NOT_GIVEN,
suggested_queries: List[str] | NotGiven = NOT_GIVEN,
Expand All @@ -484,6 +495,8 @@ async def update(
Args:
agent_id: ID of the agent to edit

agent_configs: The following advanced parameters are experimental and subject to change.

datastore_ids: IDs of the datastore to associate with the agent.

llm_model_id: The model ID to use for generation. Tuned models can only be used for the agents
Expand Down Expand Up @@ -512,6 +525,7 @@ async def update(
f"/agents/{agent_id}",
body=await async_maybe_transform(
{
"agent_configs": agent_configs,
"datastore_ids": datastore_ids,
"llm_model_id": llm_model_id,
"suggested_queries": suggested_queries,
Expand Down
14 changes: 14 additions & 0 deletions src/contextual/resources/agents/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from .tune import (
TuneResource,
AsyncTuneResource,
TuneResourceWithRawResponse,
AsyncTuneResourceWithRawResponse,
TuneResourceWithStreamingResponse,
AsyncTuneResourceWithStreamingResponse,
)
from .datasets import (
DatasetsResource,
AsyncDatasetsResource,
Expand All @@ -18,6 +26,12 @@
)

__all__ = [
"TuneResource",
"AsyncTuneResource",
"TuneResourceWithRawResponse",
"AsyncTuneResourceWithRawResponse",
"TuneResourceWithStreamingResponse",
"AsyncTuneResourceWithStreamingResponse",
"EvaluateResource",
"AsyncEvaluateResource",
"EvaluateResourceWithRawResponse",
Expand Down
32 changes: 32 additions & 0 deletions src/contextual/resources/agents/datasets/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

from __future__ import annotations

from .tune import (
TuneResource,
AsyncTuneResource,
TuneResourceWithRawResponse,
AsyncTuneResourceWithRawResponse,
TuneResourceWithStreamingResponse,
AsyncTuneResourceWithStreamingResponse,
)
from .evaluate import (
EvaluateResource,
AsyncEvaluateResource,
Expand All @@ -17,6 +25,10 @@


class DatasetsResource(SyncAPIResource):
@cached_property
def tune(self) -> TuneResource:
return TuneResource(self._client)

@cached_property
def evaluate(self) -> EvaluateResource:
return EvaluateResource(self._client)
Expand All @@ -42,6 +54,10 @@ def with_streaming_response(self) -> DatasetsResourceWithStreamingResponse:


class AsyncDatasetsResource(AsyncAPIResource):
@cached_property
def tune(self) -> AsyncTuneResource:
return AsyncTuneResource(self._client)

@cached_property
def evaluate(self) -> AsyncEvaluateResource:
return AsyncEvaluateResource(self._client)
Expand Down Expand Up @@ -70,6 +86,10 @@ class DatasetsResourceWithRawResponse:
def __init__(self, datasets: DatasetsResource) -> None:
self._datasets = datasets

@cached_property
def tune(self) -> TuneResourceWithRawResponse:
return TuneResourceWithRawResponse(self._datasets.tune)

@cached_property
def evaluate(self) -> EvaluateResourceWithRawResponse:
return EvaluateResourceWithRawResponse(self._datasets.evaluate)
Expand All @@ -79,6 +99,10 @@ class AsyncDatasetsResourceWithRawResponse:
def __init__(self, datasets: AsyncDatasetsResource) -> None:
self._datasets = datasets

@cached_property
def tune(self) -> AsyncTuneResourceWithRawResponse:
return AsyncTuneResourceWithRawResponse(self._datasets.tune)

@cached_property
def evaluate(self) -> AsyncEvaluateResourceWithRawResponse:
return AsyncEvaluateResourceWithRawResponse(self._datasets.evaluate)
Expand All @@ -88,6 +112,10 @@ class DatasetsResourceWithStreamingResponse:
def __init__(self, datasets: DatasetsResource) -> None:
self._datasets = datasets

@cached_property
def tune(self) -> TuneResourceWithStreamingResponse:
return TuneResourceWithStreamingResponse(self._datasets.tune)

@cached_property
def evaluate(self) -> EvaluateResourceWithStreamingResponse:
return EvaluateResourceWithStreamingResponse(self._datasets.evaluate)
Expand All @@ -97,6 +125,10 @@ class AsyncDatasetsResourceWithStreamingResponse:
def __init__(self, datasets: AsyncDatasetsResource) -> None:
self._datasets = datasets

@cached_property
def tune(self) -> AsyncTuneResourceWithStreamingResponse:
return AsyncTuneResourceWithStreamingResponse(self._datasets.tune)

@cached_property
def evaluate(self) -> AsyncEvaluateResourceWithStreamingResponse:
return AsyncEvaluateResourceWithStreamingResponse(self._datasets.evaluate)
Loading