diff --git a/.castiron.stats.yml b/.castiron.stats.yml index 2697253a83..667f73dd89 100644 --- a/.castiron.stats.yml +++ b/.castiron.stats.yml @@ -1,7 +1,7 @@ schema_version: 1 -generation_id: c42efbb5-43e9-44f9-8f53-8cb2a9ed8eb9 -openapi_spec_hash: 1403763f6039e921885b467cd2a6434c -openapi_transformed_spec_hash: c6c28455ed2114dd8c1e303072f3fe7d -config_hash: 58da74f4c4c6660f376fa9007e3c4fa2 -codegen_sha: 1e18b7c3085cae651cff6472bde1cba31289cb10 -codegen_hash: c8556f71e15a60487833ee790cfbc15048ed59cc911cb617af8a232ba3d98640 +generation_id: 246f879d-8464-4b41-bb24-d89bc1e8df3c +openapi_spec_hash: 0ce316f78a89857b9483e1ec86e095ea +openapi_transformed_spec_hash: 45b9b080467ec914b61d840811bed260 +config_hash: 036100415594abcf279907b22cc8d2f1 +codegen_sha: cc041f0d27315d1a33d649dd1e5fb6f2ec04c72b +codegen_hash: 52084edd6ec47c7ad6066c4f16600f52381ceb96fcad79a85380928a81299e80 diff --git a/api.md b/api.md index 3e7df32ded..2ee97d3501 100644 --- a/api.md +++ b/api.md @@ -868,6 +868,59 @@ Methods: - client.beta.agents.sessions.turns.items.list(turn_id, \*, session_id, \*\*params) -> SyncConversationCursorPage[AgentSessionItem] +### HistoryStores + +Types: + +```python +from openai.types.beta.agents import HistoryStore, HistoryStoreDeleted +``` + +Methods: + +- client.beta.agents.history_stores.create(\*\*params) -> HistoryStore +- client.beta.agents.history_stores.retrieve(store_id) -> HistoryStore +- client.beta.agents.history_stores.update(store_id, \*\*params) -> HistoryStore +- client.beta.agents.history_stores.list(\*\*params) -> SyncTokenPage[HistoryStore] +- client.beta.agents.history_stores.delete(store_id) -> HistoryStoreDeleted + +#### Sessions + +Methods: + +- client.beta.agents.history_stores.sessions.list(store_id, \*\*params) -> SyncTokenPage[AgentSession] + +### MemoryStores + +Types: + +```python +from openai.types.beta.agents import MemoryStore +``` + +Methods: + +- client.beta.agents.memory_stores.create(\*\*params) -> MemoryStore +- client.beta.agents.memory_stores.retrieve(store_id) -> MemoryStore +- client.beta.agents.memory_stores.update(store_id, \*\*params) -> MemoryStore +- client.beta.agents.memory_stores.list(\*\*params) -> SyncTokenPage[MemoryStore] + +#### Notes + +Types: + +```python +from openai.types.beta.agents.memory_stores import MemoryNote, MemoryNoteDeleted, MemoryNoteMetadata +``` + +Methods: + +- client.beta.agents.memory_stores.notes.create(store_id, \*\*params) -> MemoryNote +- client.beta.agents.memory_stores.notes.retrieve(note_id, \*, store_id) -> MemoryNote +- client.beta.agents.memory_stores.notes.update(note_id, \*, store_id, \*\*params) -> MemoryNote +- client.beta.agents.memory_stores.notes.list(store_id, \*\*params) -> SyncCursorPage[MemoryNoteMetadata] +- client.beta.agents.memory_stores.notes.delete(note_id, \*, store_id, \*\*params) -> MemoryNoteDeleted + ## Responses Types: diff --git a/api_reference/openapi.transformed.yml b/api_reference/openapi.transformed.yml index dea1bcac1d..f8af3d4f7f 100644 --- a/api_reference/openapi.transformed.yml +++ b/api_reference/openapi.transformed.yml @@ -39465,6 +39465,1079 @@ paths: } security: - AdminApiKeyAuth: [] + /agents/history_stores: + post: + operationId: createHistoryStore + summary: Create a history store + description: Create a history store. + tags: + - Agents + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/StoreParams' + required: true + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/HistoryStoreResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + get: + operationId: listHistoryStores + summary: List history stores + description: List history stores. + tags: + - Agents + parameters: + - name: limit + in: query + required: false + schema: + type: + - integer + - 'null' + format: int64 + minimum: 1 + maximum: 100 + default: 20 + - name: page + in: query + required: false + schema: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Pass the next cursor from the previous page, even if that page was empty. + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/HistoryStoreList' + description: A page of history stores. + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + /agents/history_stores/{store_id}: + get: + operationId: retrieveHistoryStore + summary: Retrieve a history store + description: Retrieve a history store. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/HistoryStoreResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + post: + operationId: updateHistoryStore + summary: Update a history store + description: Update a history store name or metadata. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/StoreParams' + required: true + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/HistoryStoreResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + delete: + operationId: deleteHistoryStore + summary: Delete a history store + description: Delete a history store without deleting its source sessions. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedHistoryStoreResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + /agents/history_stores/{store_id}/sessions: + get: + operationId: listHistoryStoreSessions + summary: List history store sessions + description: List sessions enrolled in a history store. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + - name: limit + in: query + required: false + schema: + type: + - integer + - 'null' + format: int64 + minimum: 1 + maximum: 100 + default: 20 + - name: page + in: query + required: false + schema: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Pass the next cursor from the previous page, even if that page was empty. + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/HistoryStoreSessionList' + description: A page of member sessions. + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + /agents/memory_stores: + post: + operationId: createMemoryStore + summary: Create a memory store + description: Create a memory store. + tags: + - Agents + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/StoreParams' + required: true + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/MemoryStoreResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + get: + operationId: listMemoryStores + summary: List memory stores + description: List memory stores. + tags: + - Agents + parameters: + - name: limit + in: query + required: false + schema: + type: + - integer + - 'null' + format: int64 + minimum: 1 + maximum: 100 + default: 20 + - name: page + in: query + required: false + schema: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Pass the next cursor from the previous page, even if that page was empty. + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/MemoryStoreList' + description: A page of memory stores. + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + /agents/memory_stores/{store_id}: + get: + operationId: retrieveMemoryStore + summary: Retrieve a memory store + description: Retrieve a memory store. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/MemoryStoreResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + post: + operationId: updateMemoryStore + summary: Update a memory store + description: Update a memory store. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/StoreParams' + required: true + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/MemoryStoreResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + /agents/memory_stores/{store_id}/notes: + post: + operationId: createMemoryNote + summary: Create a memory note + description: Create a memory note. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateNoteParams' + required: true + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/MemoryNoteResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + get: + operationId: listMemoryNotes + summary: List memory notes + description: List memory notes. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + - name: limit + in: query + required: false + schema: + type: + - integer + - 'null' + format: int64 + minimum: 1 + maximum: 100 + default: 20 + - name: after + in: query + required: false + schema: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/MemoryNoteList' + description: A page of memory note metadata. + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + /agents/memory_stores/{store_id}/notes/{note_id}: + get: + operationId: retrieveMemoryNote + summary: Retrieve a memory note + description: Retrieve a memory note. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + - name: note_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/MemoryNoteResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + post: + operationId: updateMemoryNote + summary: Update a memory note + description: Update a memory note. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + - name: note_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateNoteParams' + required: true + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/MemoryNoteResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + delete: + operationId: deleteMemoryNote + summary: Delete a memory note + description: Delete a memory note. + tags: + - Agents + parameters: + - name: store_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + - name: note_id + in: path + required: true + schema: + type: string + minLength: 0 + maxLength: 1048576 + - name: expected_revision + in: query + required: true + schema: + type: integer + format: int64 + minimum: 0 + responses: + '200': + description: Success. + content: + application/json: + schema: + $ref: '#/components/schemas/DeletedMemoryResource' + '400': + description: The request was invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '401': + description: Authentication or project context was missing. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '404': + description: The requested session or event was not found. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '409': + description: The request conflicted with the current session state. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '429': + description: The request exceeded this endpoint's rate limit. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '500': + description: An internal error occurred. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' + '503': + description: The service is temporarily unavailable. + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorResponse-2' webhooks: agent_environment_expired: post: @@ -87897,6 +88970,8 @@ components: web_search: '#/components/schemas/AgentToolResourceWebSearch' computer_use: '#/components/schemas/AgentToolResourceComputerUse' automations: '#/components/schemas/AgentToolResourceAutomations' + memory: '#/components/schemas/AgentToolResourceMemory' + history: '#/components/schemas/AgentToolResourceHistory' x-oai-discriminator-values: - function - programmatic_tool_calling @@ -87904,6 +88979,8 @@ components: - web_search - computer_use - automations + - memory + - history anyOf: - $ref: '#/components/schemas/AgentToolResourceFunction' - $ref: '#/components/schemas/AgentToolResourceProgrammaticToolCalling' @@ -87911,6 +88988,8 @@ components: - $ref: '#/components/schemas/AgentToolResourceWebSearch' - $ref: '#/components/schemas/AgentToolResourceComputerUse' - $ref: '#/components/schemas/AgentToolResourceAutomations' + - $ref: '#/components/schemas/AgentToolResourceMemory' + - $ref: '#/components/schemas/AgentToolResourceHistory' MultiAgentConfigResource: type: object properties: @@ -89407,6 +90486,8 @@ components: web_search: '#/components/schemas/AgentToolConfigParamWebSearch' computer_use: '#/components/schemas/AgentToolConfigParamComputerUse' automations: '#/components/schemas/AgentToolConfigParamAutomations' + memory: '#/components/schemas/AgentToolConfigParamMemory' + history: '#/components/schemas/AgentToolConfigParamHistory' x-oai-discriminator-values: - function - tool_search @@ -89415,6 +90496,8 @@ components: - web_search - computer_use - automations + - memory + - history anyOf: - $ref: '#/components/schemas/AgentToolConfigParamFunction' - $ref: '#/components/schemas/AgentToolConfigParamToolSearch' @@ -89423,6 +90506,8 @@ components: - $ref: '#/components/schemas/AgentToolConfigParamWebSearch' - $ref: '#/components/schemas/AgentToolConfigParamComputerUse' - $ref: '#/components/schemas/AgentToolConfigParamAutomations' + - $ref: '#/components/schemas/AgentToolConfigParamMemory' + - $ref: '#/components/schemas/AgentToolConfigParamHistory' SessionAgentConfigParam: type: object properties: @@ -92871,6 +93956,8 @@ components: web_search: '#/components/schemas/PersistedAgentToolResourceWebSearch' computer_use: '#/components/schemas/PersistedAgentToolResourceComputerUse' automations: '#/components/schemas/PersistedAgentToolResourceAutomations' + memory: '#/components/schemas/PersistedAgentToolResourceMemory' + history: '#/components/schemas/PersistedAgentToolResourceHistory' x-oai-discriminator-values: - function - tool_search @@ -92879,6 +93966,8 @@ components: - web_search - computer_use - automations + - memory + - history anyOf: - $ref: '#/components/schemas/PersistedAgentToolResourceFunction' - $ref: '#/components/schemas/PersistedAgentToolResourceToolSearch' @@ -92887,6 +93976,8 @@ components: - $ref: '#/components/schemas/PersistedAgentToolResourceWebSearch' - $ref: '#/components/schemas/PersistedAgentToolResourceComputerUse' - $ref: '#/components/schemas/PersistedAgentToolResourceAutomations' + - $ref: '#/components/schemas/PersistedAgentToolResourceMemory' + - $ref: '#/components/schemas/PersistedAgentToolResourceHistory' AgentResource: type: object properties: @@ -93345,6 +94436,8 @@ components: web_search: '#/components/schemas/PersistedAgentToolConfigParamWebSearch' computer_use: '#/components/schemas/PersistedAgentToolConfigParamComputerUse' automations: '#/components/schemas/PersistedAgentToolConfigParamAutomations' + memory: '#/components/schemas/PersistedAgentToolConfigParamMemory' + history: '#/components/schemas/PersistedAgentToolConfigParamHistory' x-oai-discriminator-values: - function - tool_search @@ -93353,6 +94446,8 @@ components: - web_search - computer_use - automations + - memory + - history anyOf: - $ref: '#/components/schemas/PersistedAgentToolConfigParamFunction' - $ref: '#/components/schemas/PersistedAgentToolConfigParamToolSearch' @@ -93361,6 +94456,8 @@ components: - $ref: '#/components/schemas/PersistedAgentToolConfigParamWebSearch' - $ref: '#/components/schemas/PersistedAgentToolConfigParamComputerUse' - $ref: '#/components/schemas/PersistedAgentToolConfigParamAutomations' + - $ref: '#/components/schemas/PersistedAgentToolConfigParamMemory' + - $ref: '#/components/schemas/PersistedAgentToolConfigParamHistory' CreateAgentParams: type: object properties: @@ -115738,6 +116835,536 @@ components: type: object required: [] description: Routing for customer-hosted PSP storage. + StoreParams: + type: object + properties: + name: + type: string + minLength: 0 + maxLength: 1048576 + metadata: + type: object + additionalProperties: + type: string + minLength: 0 + maxLength: 1048576 + propertyNames: + type: string + minLength: 1 + maxLength: 256 + minProperties: 0 + maxProperties: 1024 + additionalProperties: false + HistoryStoreResource: + type: object + properties: + id: + type: string + minLength: 0 + created_at: + type: integer + format: int64 + name: + type: + - string + - 'null' + minLength: 0 + metadata: + type: + - object + - 'null' + additionalProperties: + type: string + minLength: 0 + propertyNames: + type: string + minLength: 0 + minProperties: 0 + required: + - id + - created_at + - name + - metadata + additionalProperties: false + DeletedHistoryStoreResource: + type: object + properties: + id: + type: string + minLength: 0 + deleted: + type: boolean + required: + - id + - deleted + additionalProperties: false + HistoryStoreSessionList: + type: object + properties: + object: + type: string + enum: + - page + default: page + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/SessionResource' + minItems: 0 + maxItems: 2000 + next: + type: + - string + - 'null' + minLength: 0 + description: Pass this cursor as page to continue scanning. Null means the scan is complete. + has_more: + type: boolean + description: More candidates remain to check. A page can contain fewer than limit results or be empty. + required: + - object + - data + - next + - has_more + additionalProperties: false + MemoryStoreResource: + type: object + properties: + id: + type: string + minLength: 0 + created_at: + type: integer + format: int64 + name: + type: + - string + - 'null' + minLength: 0 + metadata: + type: + - object + - 'null' + additionalProperties: + type: string + minLength: 0 + propertyNames: + type: string + minLength: 0 + minProperties: 0 + required: + - id + - created_at + - name + - metadata + additionalProperties: false + CreateNoteParams: + type: object + properties: + path: + type: string + minLength: 0 + maxLength: 1048576 + content: + type: string + minLength: 0 + maxLength: 1048576 + required: + - path + - content + additionalProperties: false + MemoryNoteResource: + type: object + properties: + id: + type: string + minLength: 0 + path: + type: string + minLength: 0 + content: + type: string + minLength: 0 + revision: + type: integer + format: int64 + minimum: 0 + created_at: + type: integer + format: int64 + updated_at: + type: integer + format: int64 + required: + - id + - path + - content + - revision + - created_at + - updated_at + additionalProperties: false + MemoryNoteList: + type: object + properties: + object: + type: string + enum: + - list + default: list + x-stainless-const: true + description: The object type, which is always `list`. + data: + type: array + items: + $ref: '#/components/schemas/MemoryNoteMetadataResource' + minItems: 0 + maxItems: 2000 + description: The resources returned in this page, in the requested sort order. + first_id: + type: + - string + - 'null' + minLength: 0 + description: The ID of the first resource in `data`, or `null` if the page is empty. + last_id: + type: + - string + - 'null' + minLength: 0 + description: The ID of the last resource in `data`, or `null` if the page is empty. Pass this as `after` with the same order and filters. + has_more: + type: boolean + description: Whether there are more resources to retrieve after this page. + required: + - object + - data + - first_id + - last_id + - has_more + additionalProperties: false + description: A page of Agents API resources, with IDs for retrieving additional pages. + UpdateNoteParams: + type: object + properties: + content: + type: string + minLength: 0 + maxLength: 1048576 + expected_revision: + type: integer + format: int64 + minimum: 0 + required: + - content + - expected_revision + additionalProperties: false + DeletedMemoryResource: + type: object + properties: + id: + type: string + minLength: 0 + deleted: + type: boolean + required: + - id + - deleted + additionalProperties: false + AgentToolConfigParamMemory: + type: object + properties: + type: + type: string + enum: + - memory + default: memory + x-stainless-const: true + description: The type of the object. Always `memory`. + store_id: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Share an existing store in this project, or omit to create a store for the session. + instructions: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Additional instructions for this memory store. + required: + - type + additionalProperties: false + description: Enables notes in a project-owned memory store. + AgentToolConfigParamHistory: + type: object + properties: + type: + type: string + enum: + - history + default: history + x-stainless-const: true + description: The type of the object. Always `history`. + store_id: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Reuse a project-owned history store, or omit to create one. + required: + - type + additionalProperties: false + description: Search, list, and read indexed session history. + AgentToolResourceMemory: + type: object + properties: + type: + type: string + enum: + - memory + default: memory + x-stainless-const: true + description: The type of the object. Always `memory`. + store_id: + type: + - string + - 'null' + minLength: 0 + description: Share an existing store in this project, or omit to create a store for the session. + memory_store_id: + type: + - string + - 'null' + minLength: 0 + description: Deprecated response alias for `store_id`. + deprecated: true + instructions: + type: + - string + - 'null' + minLength: 0 + description: Additional instructions for this memory store. + required: + - type + - store_id + - instructions + additionalProperties: false + description: Enables notes in a project-owned memory store. + AgentToolResourceHistory: + type: object + properties: + type: + type: string + enum: + - history + default: history + x-stainless-const: true + description: The type of the object. Always `history`. + store_id: + type: + - string + - 'null' + minLength: 0 + required: + - type + - store_id + additionalProperties: false + description: Search, list, and read indexed session history. + PersistedAgentToolConfigParamMemory: + type: object + properties: + type: + type: string + enum: + - memory + default: memory + x-stainless-const: true + description: The type of the object. Always `memory`. + store_id: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Share an existing store in this project, or omit to create a store for the session. + instructions: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Additional instructions for this memory store. + required: + - type + additionalProperties: false + description: Enables notes in a project-owned memory store. + PersistedAgentToolConfigParamHistory: + type: object + properties: + type: + type: string + enum: + - history + default: history + x-stainless-const: true + description: The type of the object. Always `history`. + store_id: + type: + - string + - 'null' + minLength: 0 + maxLength: 1048576 + description: Reuse a project-owned history store, or omit to create one. + required: + - type + additionalProperties: false + description: Search, list, and read indexed session history. + PersistedAgentToolResourceMemory: + type: object + properties: + type: + type: string + enum: + - memory + default: memory + x-stainless-const: true + description: The type of the object. Always `memory`. + store_id: + type: + - string + - 'null' + minLength: 0 + description: Share an existing store in this project, or omit to create a store for the session. + memory_store_id: + type: + - string + - 'null' + minLength: 0 + description: Deprecated response alias for `store_id`. + deprecated: true + instructions: + type: + - string + - 'null' + minLength: 0 + description: Additional instructions for this memory store. + required: + - type + - store_id + - instructions + additionalProperties: false + description: Enables notes in a project-owned memory store. + PersistedAgentToolResourceHistory: + type: object + properties: + type: + type: string + enum: + - history + default: history + x-stainless-const: true + description: The type of the object. Always `history`. + store_id: + type: + - string + - 'null' + minLength: 0 + required: + - type + - store_id + additionalProperties: false + description: Search, list, and read indexed session history. + MemoryNoteMetadataResource: + type: object + properties: + id: + type: string + minLength: 0 + path: + type: string + minLength: 0 + revision: + type: integer + format: int64 + minimum: 0 + created_at: + type: integer + format: int64 + updated_at: + type: integer + format: int64 + required: + - id + - path + - revision + - created_at + - updated_at + additionalProperties: false + MemoryStoreList: + type: object + properties: + object: + type: string + enum: + - page + default: page + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/MemoryStoreResource' + minItems: 0 + maxItems: 2000 + next: + type: + - string + - 'null' + minLength: 0 + description: Pass this cursor as page to continue scanning. Null means the scan is complete. + has_more: + type: boolean + description: More candidates remain to check. A page can contain fewer than limit results or be empty. + required: + - object + - data + - next + - has_more + additionalProperties: false + HistoryStoreList: + type: object + properties: + object: + type: string + enum: + - page + default: page + x-stainless-const: true + data: + type: array + items: + $ref: '#/components/schemas/HistoryStoreResource' + minItems: 0 + maxItems: 2000 + next: + type: + - string + - 'null' + minLength: 0 + description: Pass this cursor as page to continue scanning. Null means the scan is complete. + has_more: + type: boolean + description: More candidates remain to check. A page can contain fewer than limit results or be empty. + required: + - object + - data + - next + - has_more + additionalProperties: false CostsResultWithDimensions: type: object description: The aggregated costs details of the specific time bucket. diff --git a/scripts/castiron/generated-files.json b/scripts/castiron/generated-files.json index fb38e01782..2b6725f575 100644 --- a/scripts/castiron/generated-files.json +++ b/scripts/castiron/generated-files.json @@ -3,7 +3,7 @@ "files": { "api.md": { "mode": "100644", - "sha256": "322f7b3402ec35ed625d0457d38d380e9a67ba4a0a4d8656ab5c193965c74e7e" + "sha256": "023cc38670f9e15c47e8592fb4c04b1c879f7178060446775ae3f57f22d25d83" }, "src/openai/__init__.py": { "mode": "100644", @@ -283,11 +283,11 @@ }, "src/openai/resources/beta/agents/__init__.py": { "mode": "100644", - "sha256": "e569c61815e1ee18c4fc57e7d26b34223ed964a0324bb679e1599985e190bf5a" + "sha256": "80a94d507cd83e8994cfe28a3af161de2642d4a5a7e9b847ae9c940801b19c82" }, "src/openai/resources/beta/agents/agents.py": { "mode": "100644", - "sha256": "8b75829c492b050a9ef3f714523626d70d2ad363ab1f8d79e0cbaaf3174f1e58" + "sha256": "c772ada6e0b146b7347a4aff40c2299c0e0d152bed16bea6540283d571536afb" }, "src/openai/resources/beta/agents/automations/__init__.py": { "mode": "100644", @@ -317,6 +317,30 @@ "mode": "100644", "sha256": "cc38927c8619191657d2f75ce40f6ce3f18f7b553aaa7acdb6d0c455c2343f53" }, + "src/openai/resources/beta/agents/history_stores/__init__.py": { + "mode": "100644", + "sha256": "c1f9a0117034c4b87186d02369b1b7b942ac4f9ba8a87994718cde13c7757379" + }, + "src/openai/resources/beta/agents/history_stores/history_stores.py": { + "mode": "100644", + "sha256": "16332bd3754583f8e9f468a718ba6da6d03ce50890e82830f52a390b8f6e61c8" + }, + "src/openai/resources/beta/agents/history_stores/sessions.py": { + "mode": "100644", + "sha256": "5f892c029fee9bb4da74308de25604febd8031f7845812dfd6e7babb2b58dd9b" + }, + "src/openai/resources/beta/agents/memory_stores/__init__.py": { + "mode": "100644", + "sha256": "ae49bfe3e967031f739b5f57abb43d4c4f0cd3e16087972949c0c729a345abfd" + }, + "src/openai/resources/beta/agents/memory_stores/memory_stores.py": { + "mode": "100644", + "sha256": "2e727bec9e5ce2794e943633029afebdd5df285c6c514ef1d1e4266109d03d53" + }, + "src/openai/resources/beta/agents/memory_stores/notes.py": { + "mode": "100644", + "sha256": "b394500e71f31c9d35227c91c9920d70bc0b2284bb861a2ae8ec278e23725f17" + }, "src/openai/resources/beta/agents/sessions/__init__.py": { "mode": "100644", "sha256": "ce812a7dde5f001ba200f8cf803c4b404363262a667e06175cb9212654d01aae" @@ -2051,11 +2075,11 @@ }, "src/openai/types/beta/agent_tool.py": { "mode": "100644", - "sha256": "145a8f0a9e15d6aa46b116296c9cfbdfd3fc7f5530d99fdb070b3f43439a39b5" + "sha256": "8f7d053dc08f07ad2232e8db181f6c8c94595b6c0561699edb17295d260b21ee" }, "src/openai/types/beta/agent_tool_param.py": { "mode": "100644", - "sha256": "44b83c04613add6637b8de7bb48cbf4b1220ddde3d1a2e50e1edfb9d6d4b8990" + "sha256": "b5e2ba720dd13b3d27992192c2f023bc5b173224759824e292a3a76978208cb1" }, "src/openai/types/beta/agent_update_params.py": { "mode": "100644", @@ -2071,7 +2095,7 @@ }, "src/openai/types/beta/agents/__init__.py": { "mode": "100644", - "sha256": "b67d5c4e10eb60f3b20cd18df8b715563116130e0bcdc27729524803c1929167" + "sha256": "c23ca3ec11f750e64bf9975559aaa45b79367f143991223995639471ac660b28" }, "src/openai/types/beta/agents/automation.py": { "mode": "100644", @@ -2181,6 +2205,82 @@ "mode": "100644", "sha256": "6bf1e5694ad8be2cf17549f965ac593502144419d052a8314499d80e75f47d9f" }, + "src/openai/types/beta/agents/history_store.py": { + "mode": "100644", + "sha256": "d905477cf1908917acaf9d5e426264eb491c68b7ee41e741b3e4f9e53ce9b3e4" + }, + "src/openai/types/beta/agents/history_store_create_params.py": { + "mode": "100644", + "sha256": "3c71ff7b7898fca3c3840f47ff5df308dc078805b56126847143d82451000c7c" + }, + "src/openai/types/beta/agents/history_store_deleted.py": { + "mode": "100644", + "sha256": "d417d046f551ffb3d73613ceddfbf5575535ad9c383e9e31898d3f6a9c4fe7b4" + }, + "src/openai/types/beta/agents/history_store_list_params.py": { + "mode": "100644", + "sha256": "91c91d9a68ac735d8b76b36895f5c4cd68e9b03346cc32d95047b22fa419ed20" + }, + "src/openai/types/beta/agents/history_store_update_params.py": { + "mode": "100644", + "sha256": "14cb3adad938fa1fc7c881951a6bd28114c59e69d561331c685e4e06ce0412be" + }, + "src/openai/types/beta/agents/history_stores/__init__.py": { + "mode": "100644", + "sha256": "1c7281de05a0b00a34b9491b00d2924c00a67bafd520800679d83acc7ab07dd7" + }, + "src/openai/types/beta/agents/history_stores/session_list_params.py": { + "mode": "100644", + "sha256": "faa154e1598582a6525d4e65c360ee2ee062c3326287e1bdeec432ca2aa98b3e" + }, + "src/openai/types/beta/agents/memory_store.py": { + "mode": "100644", + "sha256": "bf7943262448a9348f8f2eebdc64ba8df1e816381646c93699a2a74769eca535" + }, + "src/openai/types/beta/agents/memory_store_create_params.py": { + "mode": "100644", + "sha256": "7f1142ee70d3d6ed277b3555ba451c3a9deea0458429e6375ca31807b5bd65ed" + }, + "src/openai/types/beta/agents/memory_store_list_params.py": { + "mode": "100644", + "sha256": "be8f689d328504effd3eeee7493f365197c20b627f6fe1c9eeff024105daf272" + }, + "src/openai/types/beta/agents/memory_store_update_params.py": { + "mode": "100644", + "sha256": "2ebb81c78f9fc112713bdac4d31bac608f8e793660a40120648789625a18433f" + }, + "src/openai/types/beta/agents/memory_stores/__init__.py": { + "mode": "100644", + "sha256": "4d55506976bc8b52e0d3418934a04934f4630c94b54be17c956640b78d4c187d" + }, + "src/openai/types/beta/agents/memory_stores/memory_note.py": { + "mode": "100644", + "sha256": "2f898815daf4685a77a04ba4c35c72dd7fab848c7fd12d29963cd3ad653dce71" + }, + "src/openai/types/beta/agents/memory_stores/memory_note_deleted.py": { + "mode": "100644", + "sha256": "0b4baa9362c61506b5ccd1ca57d7c668044725b61315564cc2011c736fecc851" + }, + "src/openai/types/beta/agents/memory_stores/memory_note_metadata.py": { + "mode": "100644", + "sha256": "b9847e0a18f3ba4da04ea34d93075d38acb640a2a407df8e62e141dc10367e98" + }, + "src/openai/types/beta/agents/memory_stores/note_create_params.py": { + "mode": "100644", + "sha256": "613588b2989ca14d03b63573d47c90916c397087bcdde440dedf241738abe2df" + }, + "src/openai/types/beta/agents/memory_stores/note_delete_params.py": { + "mode": "100644", + "sha256": "6b11894d3a0f7cfc3b3e72870191f66ec7cf91b84d492751de92eb10ed45754a" + }, + "src/openai/types/beta/agents/memory_stores/note_list_params.py": { + "mode": "100644", + "sha256": "6df3c52496351670246dedea844467e61c19ff9f28a564f49f85dbd6290e7f09" + }, + "src/openai/types/beta/agents/memory_stores/note_update_params.py": { + "mode": "100644", + "sha256": "de17a77feced4107636813ecbdd5e70b7e97992b3e993ac608792a3ab5f07cd7" + }, "src/openai/types/beta/agents/one_time_automation.py": { "mode": "100644", "sha256": "6e14221bd96a3e4ae7538ceaece70c7fd1363fdf1f70a38e6a6cd7e2360b4207" @@ -3579,11 +3679,11 @@ }, "src/openai/types/beta/persisted_agent_tool.py": { "mode": "100644", - "sha256": "b44af4c00085918e647a899f0d6f3efad4b70d59ec7d3034e6130c4128b9374c" + "sha256": "518eab7a50c63657cdbc02beaabe3d299f8f142b0b788f7a39237d2003eeb7e3" }, "src/openai/types/beta/persisted_agent_tool_param.py": { "mode": "100644", - "sha256": "11cd9c21954b53b21883fb68c5f751811663ee653bfef429c53a81a24916b934" + "sha256": "00b4c58edabe5e7e2cb163200b8f171b3ea7e3070e8a3ca993f137fc29878bab" }, "src/openai/types/beta/persisted_mcp_transport.py": { "mode": "100644", @@ -7877,6 +7977,22 @@ "mode": "100644", "sha256": "c76639aa7bdec06f687adf2df1cde1cda5ae8d2fc085e7337e72734fa9fafbe5" }, + "tests/api_resources/beta/agents/history_stores/__init__.py": { + "mode": "100644", + "sha256": "0ee742b76cb44e9e0eb921dca08a89091274455a50e995ba2769688f10a097de" + }, + "tests/api_resources/beta/agents/history_stores/test_sessions.py": { + "mode": "100644", + "sha256": "d813e72f55ef3ead5070d94f31c4146cd148726f61f35ed743f1e93a86a01754" + }, + "tests/api_resources/beta/agents/memory_stores/__init__.py": { + "mode": "100644", + "sha256": "0ee742b76cb44e9e0eb921dca08a89091274455a50e995ba2769688f10a097de" + }, + "tests/api_resources/beta/agents/memory_stores/test_notes.py": { + "mode": "100644", + "sha256": "8a422b7dfa78757c21e85b55e309cd536b870c0d45b3e1336dc663c31547ad3a" + }, "tests/api_resources/beta/agents/sessions/__init__.py": { "mode": "100644", "sha256": "0ee742b76cb44e9e0eb921dca08a89091274455a50e995ba2769688f10a097de" @@ -7941,6 +8057,14 @@ "mode": "100644", "sha256": "529f48933850ff09980fbd8a8ec6c9bef538efa5bffa71660e14421693df02fa" }, + "tests/api_resources/beta/agents/test_history_stores.py": { + "mode": "100644", + "sha256": "f3fe721ca5a889f6f44aff722845a68ffda4fb5e7ff98d3b12a6e2ffa66b34ad" + }, + "tests/api_resources/beta/agents/test_memory_stores.py": { + "mode": "100644", + "sha256": "eac5b8d3729006556ce815a312b558b2fe363dd1727a012c64ab309afb953e88" + }, "tests/api_resources/beta/agents/test_sessions.py": { "mode": "100644", "sha256": "482b6fb0ced713161b35631f52047bfcba1b33a2a41da05ae9fdfdc2ba56e3b8" diff --git a/src/openai/resources/beta/agents/__init__.py b/src/openai/resources/beta/agents/__init__.py index dea64063d3..c8d0caff90 100644 --- a/src/openai/resources/beta/agents/__init__.py +++ b/src/openai/resources/beta/agents/__init__.py @@ -43,6 +43,22 @@ EnvironmentsWithStreamingResponse as EnvironmentsWithStreamingResponse, AsyncEnvironmentsWithStreamingResponse as AsyncEnvironmentsWithStreamingResponse, ) + from .memory_stores import ( + MemoryStores as MemoryStores, + AsyncMemoryStores as AsyncMemoryStores, + MemoryStoresWithRawResponse as MemoryStoresWithRawResponse, + AsyncMemoryStoresWithRawResponse as AsyncMemoryStoresWithRawResponse, + MemoryStoresWithStreamingResponse as MemoryStoresWithStreamingResponse, + AsyncMemoryStoresWithStreamingResponse as AsyncMemoryStoresWithStreamingResponse, + ) + from .history_stores import ( + HistoryStores as HistoryStores, + AsyncHistoryStores as AsyncHistoryStores, + HistoryStoresWithRawResponse as HistoryStoresWithRawResponse, + AsyncHistoryStoresWithRawResponse as AsyncHistoryStoresWithRawResponse, + HistoryStoresWithStreamingResponse as HistoryStoresWithStreamingResponse, + AsyncHistoryStoresWithStreamingResponse as AsyncHistoryStoresWithStreamingResponse, + ) else: _EXPORTS = { @@ -70,6 +86,18 @@ "AsyncSessionsWithRawResponse": (".sessions", "AsyncSessionsWithRawResponse"), "SessionsWithStreamingResponse": (".sessions", "SessionsWithStreamingResponse"), "AsyncSessionsWithStreamingResponse": (".sessions", "AsyncSessionsWithStreamingResponse"), + "HistoryStores": (".history_stores", "HistoryStores"), + "AsyncHistoryStores": (".history_stores", "AsyncHistoryStores"), + "HistoryStoresWithRawResponse": (".history_stores", "HistoryStoresWithRawResponse"), + "AsyncHistoryStoresWithRawResponse": (".history_stores", "AsyncHistoryStoresWithRawResponse"), + "HistoryStoresWithStreamingResponse": (".history_stores", "HistoryStoresWithStreamingResponse"), + "AsyncHistoryStoresWithStreamingResponse": (".history_stores", "AsyncHistoryStoresWithStreamingResponse"), + "MemoryStores": (".memory_stores", "MemoryStores"), + "AsyncMemoryStores": (".memory_stores", "AsyncMemoryStores"), + "MemoryStoresWithRawResponse": (".memory_stores", "MemoryStoresWithRawResponse"), + "AsyncMemoryStoresWithRawResponse": (".memory_stores", "AsyncMemoryStoresWithRawResponse"), + "MemoryStoresWithStreamingResponse": (".memory_stores", "MemoryStoresWithStreamingResponse"), + "AsyncMemoryStoresWithStreamingResponse": (".memory_stores", "AsyncMemoryStoresWithStreamingResponse"), "Agents": (".agents", "Agents"), "AsyncAgents": (".agents", "AsyncAgents"), "AgentsWithRawResponse": (".agents", "AgentsWithRawResponse"), @@ -81,6 +109,8 @@ "agents", "automations", "environments", + "history_stores", + "memory_stores", "sessions", "vaults", } @@ -127,6 +157,18 @@ def __dir__() -> list[str]: "AsyncSessionsWithRawResponse", "SessionsWithStreamingResponse", "AsyncSessionsWithStreamingResponse", + "HistoryStores", + "AsyncHistoryStores", + "HistoryStoresWithRawResponse", + "AsyncHistoryStoresWithRawResponse", + "HistoryStoresWithStreamingResponse", + "AsyncHistoryStoresWithStreamingResponse", + "MemoryStores", + "AsyncMemoryStores", + "MemoryStoresWithRawResponse", + "AsyncMemoryStoresWithRawResponse", + "MemoryStoresWithStreamingResponse", + "AsyncMemoryStoresWithStreamingResponse", "Agents", "AsyncAgents", "AgentsWithRawResponse", diff --git a/src/openai/resources/beta/agents/agents.py b/src/openai/resources/beta/agents/agents.py index dde7eec50a..5a9676eafb 100644 --- a/src/openai/resources/beta/agents/agents.py +++ b/src/openai/resources/beta/agents/agents.py @@ -50,6 +50,22 @@ AsyncEnvironmentsWithStreamingResponse, ) from ....types.beta.agent_deleted import AgentDeleted +from .memory_stores.memory_stores import ( + MemoryStores, + AsyncMemoryStores, + MemoryStoresWithRawResponse, + AsyncMemoryStoresWithRawResponse, + MemoryStoresWithStreamingResponse, + AsyncMemoryStoresWithStreamingResponse, +) +from .history_stores.history_stores import ( + HistoryStores, + AsyncHistoryStores, + HistoryStoresWithRawResponse, + AsyncHistoryStoresWithRawResponse, + HistoryStoresWithStreamingResponse, + AsyncHistoryStoresWithStreamingResponse, +) from ....types.beta.agent_text_param import AgentTextParam from ....types.beta.agent_reasoning_param import AgentReasoningParam from ....types.beta.multi_agent_config_param import MultiAgentConfigParam @@ -75,6 +91,14 @@ def vaults(self) -> Vaults: def sessions(self) -> Sessions: return Sessions(self._client) + @cached_property + def history_stores(self) -> HistoryStores: + return HistoryStores(self._client) + + @cached_property + def memory_stores(self) -> MemoryStores: + return MemoryStores(self._client) + @cached_property def with_raw_response(self) -> AgentsWithRawResponse: """ @@ -450,6 +474,14 @@ def vaults(self) -> AsyncVaults: def sessions(self) -> AsyncSessions: return AsyncSessions(self._client) + @cached_property + def history_stores(self) -> AsyncHistoryStores: + return AsyncHistoryStores(self._client) + + @cached_property + def memory_stores(self) -> AsyncMemoryStores: + return AsyncMemoryStores(self._client) + @cached_property def with_raw_response(self) -> AsyncAgentsWithRawResponse: """ @@ -844,6 +876,14 @@ def vaults(self) -> VaultsWithRawResponse: def sessions(self) -> SessionsWithRawResponse: return SessionsWithRawResponse(self._agents.sessions) + @cached_property + def history_stores(self) -> HistoryStoresWithRawResponse: + return HistoryStoresWithRawResponse(self._agents.history_stores) + + @cached_property + def memory_stores(self) -> MemoryStoresWithRawResponse: + return MemoryStoresWithRawResponse(self._agents.memory_stores) + class AsyncAgentsWithRawResponse: def __init__(self, agents: AsyncAgents) -> None: @@ -881,6 +921,14 @@ def vaults(self) -> AsyncVaultsWithRawResponse: def sessions(self) -> AsyncSessionsWithRawResponse: return AsyncSessionsWithRawResponse(self._agents.sessions) + @cached_property + def history_stores(self) -> AsyncHistoryStoresWithRawResponse: + return AsyncHistoryStoresWithRawResponse(self._agents.history_stores) + + @cached_property + def memory_stores(self) -> AsyncMemoryStoresWithRawResponse: + return AsyncMemoryStoresWithRawResponse(self._agents.memory_stores) + class AgentsWithStreamingResponse: def __init__(self, agents: Agents) -> None: @@ -918,6 +966,14 @@ def vaults(self) -> VaultsWithStreamingResponse: def sessions(self) -> SessionsWithStreamingResponse: return SessionsWithStreamingResponse(self._agents.sessions) + @cached_property + def history_stores(self) -> HistoryStoresWithStreamingResponse: + return HistoryStoresWithStreamingResponse(self._agents.history_stores) + + @cached_property + def memory_stores(self) -> MemoryStoresWithStreamingResponse: + return MemoryStoresWithStreamingResponse(self._agents.memory_stores) + class AsyncAgentsWithStreamingResponse: def __init__(self, agents: AsyncAgents) -> None: @@ -954,3 +1010,11 @@ def vaults(self) -> AsyncVaultsWithStreamingResponse: @cached_property def sessions(self) -> AsyncSessionsWithStreamingResponse: return AsyncSessionsWithStreamingResponse(self._agents.sessions) + + @cached_property + def history_stores(self) -> AsyncHistoryStoresWithStreamingResponse: + return AsyncHistoryStoresWithStreamingResponse(self._agents.history_stores) + + @cached_property + def memory_stores(self) -> AsyncMemoryStoresWithStreamingResponse: + return AsyncMemoryStoresWithStreamingResponse(self._agents.memory_stores) diff --git a/src/openai/resources/beta/agents/history_stores/__init__.py b/src/openai/resources/beta/agents/history_stores/__init__.py new file mode 100644 index 0000000000..7210ead169 --- /dev/null +++ b/src/openai/resources/beta/agents/history_stores/__init__.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +import typing as _t + +if _t.TYPE_CHECKING: + from .sessions import ( + Sessions as Sessions, + AsyncSessions as AsyncSessions, + SessionsWithRawResponse as SessionsWithRawResponse, + AsyncSessionsWithRawResponse as AsyncSessionsWithRawResponse, + SessionsWithStreamingResponse as SessionsWithStreamingResponse, + AsyncSessionsWithStreamingResponse as AsyncSessionsWithStreamingResponse, + ) + from .history_stores import ( + HistoryStores as HistoryStores, + AsyncHistoryStores as AsyncHistoryStores, + HistoryStoresWithRawResponse as HistoryStoresWithRawResponse, + AsyncHistoryStoresWithRawResponse as AsyncHistoryStoresWithRawResponse, + HistoryStoresWithStreamingResponse as HistoryStoresWithStreamingResponse, + AsyncHistoryStoresWithStreamingResponse as AsyncHistoryStoresWithStreamingResponse, + ) + +else: + _EXPORTS = { + "Sessions": (".sessions", "Sessions"), + "AsyncSessions": (".sessions", "AsyncSessions"), + "SessionsWithRawResponse": (".sessions", "SessionsWithRawResponse"), + "AsyncSessionsWithRawResponse": (".sessions", "AsyncSessionsWithRawResponse"), + "SessionsWithStreamingResponse": (".sessions", "SessionsWithStreamingResponse"), + "AsyncSessionsWithStreamingResponse": (".sessions", "AsyncSessionsWithStreamingResponse"), + "HistoryStores": (".history_stores", "HistoryStores"), + "AsyncHistoryStores": (".history_stores", "AsyncHistoryStores"), + "HistoryStoresWithRawResponse": (".history_stores", "HistoryStoresWithRawResponse"), + "AsyncHistoryStoresWithRawResponse": (".history_stores", "AsyncHistoryStoresWithRawResponse"), + "HistoryStoresWithStreamingResponse": (".history_stores", "HistoryStoresWithStreamingResponse"), + "AsyncHistoryStoresWithStreamingResponse": (".history_stores", "AsyncHistoryStoresWithStreamingResponse"), + } + _SUBMODULES = { + "history_stores", + "sessions", + } + + def __getattr__(name: str) -> _t.Any: + import importlib + + if name in _EXPORTS: + module_name, symbol_name = _EXPORTS[name] + value = getattr(importlib.import_module(module_name, __name__), symbol_name) + elif name in _SUBMODULES: + value = importlib.import_module(f".{name}", __name__) + else: + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + globals()[name] = value + return value + + def __dir__() -> list[str]: + return sorted(set(globals()) | set(_EXPORTS) | _SUBMODULES) + + +__all__ = [ + "Sessions", + "AsyncSessions", + "SessionsWithRawResponse", + "AsyncSessionsWithRawResponse", + "SessionsWithStreamingResponse", + "AsyncSessionsWithStreamingResponse", + "HistoryStores", + "AsyncHistoryStores", + "HistoryStoresWithRawResponse", + "AsyncHistoryStoresWithRawResponse", + "HistoryStoresWithStreamingResponse", + "AsyncHistoryStoresWithStreamingResponse", +] diff --git a/src/openai/resources/beta/agents/history_stores/history_stores.py b/src/openai/resources/beta/agents/history_stores/history_stores.py new file mode 100644 index 0000000000..f6e26f7241 --- /dev/null +++ b/src/openai/resources/beta/agents/history_stores/history_stores.py @@ -0,0 +1,611 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Optional + +import httpx2 + +from ..... import _legacy_response +from .sessions import ( + Sessions, + AsyncSessions, + SessionsWithRawResponse, + AsyncSessionsWithRawResponse, + SessionsWithStreamingResponse, + AsyncSessionsWithStreamingResponse, +) +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import path_template, maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper +from .....pagination import SyncTokenPage, AsyncTokenPage +from ....._base_client import AsyncPaginator, make_request_options +from .....types.beta.agents import ( + history_store_list_params, + history_store_create_params, + history_store_update_params, +) +from .....types.beta.agents.history_store import HistoryStore +from .....types.beta.agents.history_store_deleted import HistoryStoreDeleted + +__all__ = ["HistoryStores", "AsyncHistoryStores"] + + +class HistoryStores(SyncAPIResource): + @cached_property + def sessions(self) -> Sessions: + return Sessions(self._client) + + @cached_property + def with_raw_response(self) -> HistoryStoresWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers + """ + return HistoryStoresWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> HistoryStoresWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/openai/openai-python#with_streaming_response + """ + return HistoryStoresWithStreamingResponse(self) + + def create( + self, + *, + metadata: Dict[str, str] | Omit = omit, + name: str | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> HistoryStore: + """ + Create a history store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._post( + "/agents/history_stores", + body=maybe_transform( + { + "metadata": metadata, + "name": name, + }, + history_store_create_params.HistoryStoreCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=HistoryStore, + ) + + def retrieve( + self, + store_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> HistoryStore: + """ + Retrieve a history store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get( + path_template("/agents/history_stores/{store_id}", store_id=store_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=HistoryStore, + ) + + def update( + self, + store_id: str, + *, + metadata: Dict[str, str] | Omit = omit, + name: str | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> HistoryStore: + """ + Update a history store name or metadata. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._post( + path_template("/agents/history_stores/{store_id}", store_id=store_id), + body=maybe_transform( + { + "metadata": metadata, + "name": name, + }, + history_store_update_params.HistoryStoreUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=HistoryStore, + ) + + def list( + self, + *, + limit: Optional[int] | Omit = omit, + page: Optional[str] | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> SyncTokenPage[HistoryStore]: + """ + List history stores. + + Args: + page: Pass the next cursor from the previous page, even if that page was empty. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get_api_list( + "/agents/history_stores", + page=SyncTokenPage[HistoryStore], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "page": page, + }, + history_store_list_params.HistoryStoreListParams, + ), + security={"bearer_auth": True}, + ), + model=HistoryStore, + ) + + def delete( + self, + store_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> HistoryStoreDeleted: + """ + Delete a history store without deleting its source sessions. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._delete( + path_template("/agents/history_stores/{store_id}", store_id=store_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=HistoryStoreDeleted, + ) + + +class AsyncHistoryStores(AsyncAPIResource): + @cached_property + def sessions(self) -> AsyncSessions: + return AsyncSessions(self._client) + + @cached_property + def with_raw_response(self) -> AsyncHistoryStoresWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers + """ + return AsyncHistoryStoresWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncHistoryStoresWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/openai/openai-python#with_streaming_response + """ + return AsyncHistoryStoresWithStreamingResponse(self) + + async def create( + self, + *, + metadata: Dict[str, str] | Omit = omit, + name: str | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> HistoryStore: + """ + Create a history store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._post( + "/agents/history_stores", + body=await async_maybe_transform( + { + "metadata": metadata, + "name": name, + }, + history_store_create_params.HistoryStoreCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=HistoryStore, + ) + + async def retrieve( + self, + store_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> HistoryStore: + """ + Retrieve a history store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._get( + path_template("/agents/history_stores/{store_id}", store_id=store_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=HistoryStore, + ) + + async def update( + self, + store_id: str, + *, + metadata: Dict[str, str] | Omit = omit, + name: str | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> HistoryStore: + """ + Update a history store name or metadata. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._post( + path_template("/agents/history_stores/{store_id}", store_id=store_id), + body=await async_maybe_transform( + { + "metadata": metadata, + "name": name, + }, + history_store_update_params.HistoryStoreUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=HistoryStore, + ) + + def list( + self, + *, + limit: Optional[int] | Omit = omit, + page: Optional[str] | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[HistoryStore, AsyncTokenPage[HistoryStore]]: + """ + List history stores. + + Args: + page: Pass the next cursor from the previous page, even if that page was empty. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get_api_list( + "/agents/history_stores", + page=AsyncTokenPage[HistoryStore], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "page": page, + }, + history_store_list_params.HistoryStoreListParams, + ), + security={"bearer_auth": True}, + ), + model=HistoryStore, + ) + + async def delete( + self, + store_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> HistoryStoreDeleted: + """ + Delete a history store without deleting its source sessions. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._delete( + path_template("/agents/history_stores/{store_id}", store_id=store_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=HistoryStoreDeleted, + ) + + +class HistoryStoresWithRawResponse: + def __init__(self, history_stores: HistoryStores) -> None: + self._history_stores = history_stores + + self.create = _legacy_response.to_raw_response_wrapper( + history_stores.create, + ) + self.retrieve = _legacy_response.to_raw_response_wrapper( + history_stores.retrieve, + ) + self.update = _legacy_response.to_raw_response_wrapper( + history_stores.update, + ) + self.list = _legacy_response.to_raw_response_wrapper( + history_stores.list, + ) + self.delete = _legacy_response.to_raw_response_wrapper( + history_stores.delete, + ) + + @cached_property + def sessions(self) -> SessionsWithRawResponse: + return SessionsWithRawResponse(self._history_stores.sessions) + + +class AsyncHistoryStoresWithRawResponse: + def __init__(self, history_stores: AsyncHistoryStores) -> None: + self._history_stores = history_stores + + self.create = _legacy_response.async_to_raw_response_wrapper( + history_stores.create, + ) + self.retrieve = _legacy_response.async_to_raw_response_wrapper( + history_stores.retrieve, + ) + self.update = _legacy_response.async_to_raw_response_wrapper( + history_stores.update, + ) + self.list = _legacy_response.async_to_raw_response_wrapper( + history_stores.list, + ) + self.delete = _legacy_response.async_to_raw_response_wrapper( + history_stores.delete, + ) + + @cached_property + def sessions(self) -> AsyncSessionsWithRawResponse: + return AsyncSessionsWithRawResponse(self._history_stores.sessions) + + +class HistoryStoresWithStreamingResponse: + def __init__(self, history_stores: HistoryStores) -> None: + self._history_stores = history_stores + + self.create = to_streamed_response_wrapper( + history_stores.create, + ) + self.retrieve = to_streamed_response_wrapper( + history_stores.retrieve, + ) + self.update = to_streamed_response_wrapper( + history_stores.update, + ) + self.list = to_streamed_response_wrapper( + history_stores.list, + ) + self.delete = to_streamed_response_wrapper( + history_stores.delete, + ) + + @cached_property + def sessions(self) -> SessionsWithStreamingResponse: + return SessionsWithStreamingResponse(self._history_stores.sessions) + + +class AsyncHistoryStoresWithStreamingResponse: + def __init__(self, history_stores: AsyncHistoryStores) -> None: + self._history_stores = history_stores + + self.create = async_to_streamed_response_wrapper( + history_stores.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + history_stores.retrieve, + ) + self.update = async_to_streamed_response_wrapper( + history_stores.update, + ) + self.list = async_to_streamed_response_wrapper( + history_stores.list, + ) + self.delete = async_to_streamed_response_wrapper( + history_stores.delete, + ) + + @cached_property + def sessions(self) -> AsyncSessionsWithStreamingResponse: + return AsyncSessionsWithStreamingResponse(self._history_stores.sessions) diff --git a/src/openai/resources/beta/agents/history_stores/sessions.py b/src/openai/resources/beta/agents/history_stores/sessions.py new file mode 100644 index 0000000000..0a9381fd1d --- /dev/null +++ b/src/openai/resources/beta/agents/history_stores/sessions.py @@ -0,0 +1,198 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional + +import httpx2 + +from ..... import _legacy_response +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import path_template, maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper +from .....pagination import SyncTokenPage, AsyncTokenPage +from ....._base_client import AsyncPaginator, make_request_options +from .....types.beta.agent_session import AgentSession +from .....types.beta.agents.history_stores import session_list_params + +__all__ = ["Sessions", "AsyncSessions"] + + +class Sessions(SyncAPIResource): + @cached_property + def with_raw_response(self) -> SessionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers + """ + return SessionsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> SessionsWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/openai/openai-python#with_streaming_response + """ + return SessionsWithStreamingResponse(self) + + def list( + self, + store_id: str, + *, + limit: Optional[int] | Omit = omit, + page: Optional[str] | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> SyncTokenPage[AgentSession]: + """ + List sessions enrolled in a history store. + + Args: + page: Pass the next cursor from the previous page, even if that page was empty. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get_api_list( + path_template("/agents/history_stores/{store_id}/sessions", store_id=store_id), + page=SyncTokenPage[AgentSession], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "page": page, + }, + session_list_params.SessionListParams, + ), + security={"bearer_auth": True}, + ), + model=AgentSession, + ) + + +class AsyncSessions(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncSessionsWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers + """ + return AsyncSessionsWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncSessionsWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/openai/openai-python#with_streaming_response + """ + return AsyncSessionsWithStreamingResponse(self) + + def list( + self, + store_id: str, + *, + limit: Optional[int] | Omit = omit, + page: Optional[str] | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[AgentSession, AsyncTokenPage[AgentSession]]: + """ + List sessions enrolled in a history store. + + Args: + page: Pass the next cursor from the previous page, even if that page was empty. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get_api_list( + path_template("/agents/history_stores/{store_id}/sessions", store_id=store_id), + page=AsyncTokenPage[AgentSession], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "page": page, + }, + session_list_params.SessionListParams, + ), + security={"bearer_auth": True}, + ), + model=AgentSession, + ) + + +class SessionsWithRawResponse: + def __init__(self, sessions: Sessions) -> None: + self._sessions = sessions + + self.list = _legacy_response.to_raw_response_wrapper( + sessions.list, + ) + + +class AsyncSessionsWithRawResponse: + def __init__(self, sessions: AsyncSessions) -> None: + self._sessions = sessions + + self.list = _legacy_response.async_to_raw_response_wrapper( + sessions.list, + ) + + +class SessionsWithStreamingResponse: + def __init__(self, sessions: Sessions) -> None: + self._sessions = sessions + + self.list = to_streamed_response_wrapper( + sessions.list, + ) + + +class AsyncSessionsWithStreamingResponse: + def __init__(self, sessions: AsyncSessions) -> None: + self._sessions = sessions + + self.list = async_to_streamed_response_wrapper( + sessions.list, + ) diff --git a/src/openai/resources/beta/agents/memory_stores/__init__.py b/src/openai/resources/beta/agents/memory_stores/__init__.py new file mode 100644 index 0000000000..a7c7ae4eea --- /dev/null +++ b/src/openai/resources/beta/agents/memory_stores/__init__.py @@ -0,0 +1,73 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +import typing as _t + +if _t.TYPE_CHECKING: + from .notes import ( + Notes as Notes, + AsyncNotes as AsyncNotes, + NotesWithRawResponse as NotesWithRawResponse, + AsyncNotesWithRawResponse as AsyncNotesWithRawResponse, + NotesWithStreamingResponse as NotesWithStreamingResponse, + AsyncNotesWithStreamingResponse as AsyncNotesWithStreamingResponse, + ) + from .memory_stores import ( + MemoryStores as MemoryStores, + AsyncMemoryStores as AsyncMemoryStores, + MemoryStoresWithRawResponse as MemoryStoresWithRawResponse, + AsyncMemoryStoresWithRawResponse as AsyncMemoryStoresWithRawResponse, + MemoryStoresWithStreamingResponse as MemoryStoresWithStreamingResponse, + AsyncMemoryStoresWithStreamingResponse as AsyncMemoryStoresWithStreamingResponse, + ) + +else: + _EXPORTS = { + "Notes": (".notes", "Notes"), + "AsyncNotes": (".notes", "AsyncNotes"), + "NotesWithRawResponse": (".notes", "NotesWithRawResponse"), + "AsyncNotesWithRawResponse": (".notes", "AsyncNotesWithRawResponse"), + "NotesWithStreamingResponse": (".notes", "NotesWithStreamingResponse"), + "AsyncNotesWithStreamingResponse": (".notes", "AsyncNotesWithStreamingResponse"), + "MemoryStores": (".memory_stores", "MemoryStores"), + "AsyncMemoryStores": (".memory_stores", "AsyncMemoryStores"), + "MemoryStoresWithRawResponse": (".memory_stores", "MemoryStoresWithRawResponse"), + "AsyncMemoryStoresWithRawResponse": (".memory_stores", "AsyncMemoryStoresWithRawResponse"), + "MemoryStoresWithStreamingResponse": (".memory_stores", "MemoryStoresWithStreamingResponse"), + "AsyncMemoryStoresWithStreamingResponse": (".memory_stores", "AsyncMemoryStoresWithStreamingResponse"), + } + _SUBMODULES = { + "memory_stores", + "notes", + } + + def __getattr__(name: str) -> _t.Any: + import importlib + + if name in _EXPORTS: + module_name, symbol_name = _EXPORTS[name] + value = getattr(importlib.import_module(module_name, __name__), symbol_name) + elif name in _SUBMODULES: + value = importlib.import_module(f".{name}", __name__) + else: + raise AttributeError(f"module {__name__!r} has no attribute {name!r}") + globals()[name] = value + return value + + def __dir__() -> list[str]: + return sorted(set(globals()) | set(_EXPORTS) | _SUBMODULES) + + +__all__ = [ + "Notes", + "AsyncNotes", + "NotesWithRawResponse", + "AsyncNotesWithRawResponse", + "NotesWithStreamingResponse", + "AsyncNotesWithStreamingResponse", + "MemoryStores", + "AsyncMemoryStores", + "MemoryStoresWithRawResponse", + "AsyncMemoryStoresWithRawResponse", + "MemoryStoresWithStreamingResponse", + "AsyncMemoryStoresWithStreamingResponse", +] diff --git a/src/openai/resources/beta/agents/memory_stores/memory_stores.py b/src/openai/resources/beta/agents/memory_stores/memory_stores.py new file mode 100644 index 0000000000..e3a5163199 --- /dev/null +++ b/src/openai/resources/beta/agents/memory_stores/memory_stores.py @@ -0,0 +1,518 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, Optional + +import httpx2 + +from ..... import _legacy_response +from .notes import ( + Notes, + AsyncNotes, + NotesWithRawResponse, + AsyncNotesWithRawResponse, + NotesWithStreamingResponse, + AsyncNotesWithStreamingResponse, +) +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import path_template, maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper +from .....pagination import SyncTokenPage, AsyncTokenPage +from ....._base_client import AsyncPaginator, make_request_options +from .....types.beta.agents import memory_store_list_params, memory_store_create_params, memory_store_update_params +from .....types.beta.agents.memory_store import MemoryStore + +__all__ = ["MemoryStores", "AsyncMemoryStores"] + + +class MemoryStores(SyncAPIResource): + @cached_property + def notes(self) -> Notes: + return Notes(self._client) + + @cached_property + def with_raw_response(self) -> MemoryStoresWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers + """ + return MemoryStoresWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> MemoryStoresWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/openai/openai-python#with_streaming_response + """ + return MemoryStoresWithStreamingResponse(self) + + def create( + self, + *, + metadata: Dict[str, str] | Omit = omit, + name: str | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryStore: + """ + Create a memory store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._post( + "/agents/memory_stores", + body=maybe_transform( + { + "metadata": metadata, + "name": name, + }, + memory_store_create_params.MemoryStoreCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryStore, + ) + + def retrieve( + self, + store_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryStore: + """ + Retrieve a memory store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get( + path_template("/agents/memory_stores/{store_id}", store_id=store_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryStore, + ) + + def update( + self, + store_id: str, + *, + metadata: Dict[str, str] | Omit = omit, + name: str | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryStore: + """ + Update a memory store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._post( + path_template("/agents/memory_stores/{store_id}", store_id=store_id), + body=maybe_transform( + { + "metadata": metadata, + "name": name, + }, + memory_store_update_params.MemoryStoreUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryStore, + ) + + def list( + self, + *, + limit: Optional[int] | Omit = omit, + page: Optional[str] | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> SyncTokenPage[MemoryStore]: + """ + List memory stores. + + Args: + page: Pass the next cursor from the previous page, even if that page was empty. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get_api_list( + "/agents/memory_stores", + page=SyncTokenPage[MemoryStore], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "page": page, + }, + memory_store_list_params.MemoryStoreListParams, + ), + security={"bearer_auth": True}, + ), + model=MemoryStore, + ) + + +class AsyncMemoryStores(AsyncAPIResource): + @cached_property + def notes(self) -> AsyncNotes: + return AsyncNotes(self._client) + + @cached_property + def with_raw_response(self) -> AsyncMemoryStoresWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers + """ + return AsyncMemoryStoresWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncMemoryStoresWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/openai/openai-python#with_streaming_response + """ + return AsyncMemoryStoresWithStreamingResponse(self) + + async def create( + self, + *, + metadata: Dict[str, str] | Omit = omit, + name: str | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryStore: + """ + Create a memory store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._post( + "/agents/memory_stores", + body=await async_maybe_transform( + { + "metadata": metadata, + "name": name, + }, + memory_store_create_params.MemoryStoreCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryStore, + ) + + async def retrieve( + self, + store_id: str, + *, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryStore: + """ + Retrieve a memory store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._get( + path_template("/agents/memory_stores/{store_id}", store_id=store_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryStore, + ) + + async def update( + self, + store_id: str, + *, + metadata: Dict[str, str] | Omit = omit, + name: str | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryStore: + """ + Update a memory store. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._post( + path_template("/agents/memory_stores/{store_id}", store_id=store_id), + body=await async_maybe_transform( + { + "metadata": metadata, + "name": name, + }, + memory_store_update_params.MemoryStoreUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryStore, + ) + + def list( + self, + *, + limit: Optional[int] | Omit = omit, + page: Optional[str] | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[MemoryStore, AsyncTokenPage[MemoryStore]]: + """ + List memory stores. + + Args: + page: Pass the next cursor from the previous page, even if that page was empty. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get_api_list( + "/agents/memory_stores", + page=AsyncTokenPage[MemoryStore], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "limit": limit, + "page": page, + }, + memory_store_list_params.MemoryStoreListParams, + ), + security={"bearer_auth": True}, + ), + model=MemoryStore, + ) + + +class MemoryStoresWithRawResponse: + def __init__(self, memory_stores: MemoryStores) -> None: + self._memory_stores = memory_stores + + self.create = _legacy_response.to_raw_response_wrapper( + memory_stores.create, + ) + self.retrieve = _legacy_response.to_raw_response_wrapper( + memory_stores.retrieve, + ) + self.update = _legacy_response.to_raw_response_wrapper( + memory_stores.update, + ) + self.list = _legacy_response.to_raw_response_wrapper( + memory_stores.list, + ) + + @cached_property + def notes(self) -> NotesWithRawResponse: + return NotesWithRawResponse(self._memory_stores.notes) + + +class AsyncMemoryStoresWithRawResponse: + def __init__(self, memory_stores: AsyncMemoryStores) -> None: + self._memory_stores = memory_stores + + self.create = _legacy_response.async_to_raw_response_wrapper( + memory_stores.create, + ) + self.retrieve = _legacy_response.async_to_raw_response_wrapper( + memory_stores.retrieve, + ) + self.update = _legacy_response.async_to_raw_response_wrapper( + memory_stores.update, + ) + self.list = _legacy_response.async_to_raw_response_wrapper( + memory_stores.list, + ) + + @cached_property + def notes(self) -> AsyncNotesWithRawResponse: + return AsyncNotesWithRawResponse(self._memory_stores.notes) + + +class MemoryStoresWithStreamingResponse: + def __init__(self, memory_stores: MemoryStores) -> None: + self._memory_stores = memory_stores + + self.create = to_streamed_response_wrapper( + memory_stores.create, + ) + self.retrieve = to_streamed_response_wrapper( + memory_stores.retrieve, + ) + self.update = to_streamed_response_wrapper( + memory_stores.update, + ) + self.list = to_streamed_response_wrapper( + memory_stores.list, + ) + + @cached_property + def notes(self) -> NotesWithStreamingResponse: + return NotesWithStreamingResponse(self._memory_stores.notes) + + +class AsyncMemoryStoresWithStreamingResponse: + def __init__(self, memory_stores: AsyncMemoryStores) -> None: + self._memory_stores = memory_stores + + self.create = async_to_streamed_response_wrapper( + memory_stores.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + memory_stores.retrieve, + ) + self.update = async_to_streamed_response_wrapper( + memory_stores.update, + ) + self.list = async_to_streamed_response_wrapper( + memory_stores.list, + ) + + @cached_property + def notes(self) -> AsyncNotesWithStreamingResponse: + return AsyncNotesWithStreamingResponse(self._memory_stores.notes) diff --git a/src/openai/resources/beta/agents/memory_stores/notes.py b/src/openai/resources/beta/agents/memory_stores/notes.py new file mode 100644 index 0000000000..9d65803e28 --- /dev/null +++ b/src/openai/resources/beta/agents/memory_stores/notes.py @@ -0,0 +1,613 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional + +import httpx2 + +from ..... import _legacy_response +from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given +from ....._utils import path_template, maybe_transform, async_maybe_transform +from ....._compat import cached_property +from ....._resource import SyncAPIResource, AsyncAPIResource +from ....._response import to_streamed_response_wrapper, async_to_streamed_response_wrapper +from .....pagination import SyncCursorPage, AsyncCursorPage +from ....._base_client import AsyncPaginator, make_request_options +from .....types.beta.agents.memory_stores import ( + note_list_params, + note_create_params, + note_delete_params, + note_update_params, +) +from .....types.beta.agents.memory_stores.memory_note import MemoryNote +from .....types.beta.agents.memory_stores.memory_note_deleted import MemoryNoteDeleted +from .....types.beta.agents.memory_stores.memory_note_metadata import MemoryNoteMetadata + +__all__ = ["Notes", "AsyncNotes"] + + +class Notes(SyncAPIResource): + @cached_property + def with_raw_response(self) -> NotesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers + """ + return NotesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> NotesWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/openai/openai-python#with_streaming_response + """ + return NotesWithStreamingResponse(self) + + def create( + self, + store_id: str, + *, + content: str, + path: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryNote: + """ + Create a memory note. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._post( + path_template("/agents/memory_stores/{store_id}/notes", store_id=store_id), + body=maybe_transform( + { + "content": content, + "path": path, + }, + note_create_params.NoteCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryNote, + ) + + def retrieve( + self, + note_id: str, + *, + store_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryNote: + """ + Retrieve a memory note. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + if not note_id: + raise ValueError(f"Expected a non-empty value for `note_id` but received {note_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get( + path_template("/agents/memory_stores/{store_id}/notes/{note_id}", store_id=store_id, note_id=note_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryNote, + ) + + def update( + self, + note_id: str, + *, + store_id: str, + content: str, + expected_revision: int, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryNote: + """ + Update a memory note. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + if not note_id: + raise ValueError(f"Expected a non-empty value for `note_id` but received {note_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._post( + path_template("/agents/memory_stores/{store_id}/notes/{note_id}", store_id=store_id, note_id=note_id), + body=maybe_transform( + { + "content": content, + "expected_revision": expected_revision, + }, + note_update_params.NoteUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryNote, + ) + + def list( + self, + store_id: str, + *, + after: Optional[str] | Omit = omit, + limit: Optional[int] | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> SyncCursorPage[MemoryNoteMetadata]: + """ + List memory notes. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get_api_list( + path_template("/agents/memory_stores/{store_id}/notes", store_id=store_id), + page=SyncCursorPage[MemoryNoteMetadata], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "after": after, + "limit": limit, + }, + note_list_params.NoteListParams, + ), + security={"bearer_auth": True}, + ), + model=MemoryNoteMetadata, + ) + + def delete( + self, + note_id: str, + *, + store_id: str, + expected_revision: int, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryNoteDeleted: + """ + Delete a memory note. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + if not note_id: + raise ValueError(f"Expected a non-empty value for `note_id` but received {note_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._delete( + path_template("/agents/memory_stores/{store_id}/notes/{note_id}", store_id=store_id, note_id=note_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform({"expected_revision": expected_revision}, note_delete_params.NoteDeleteParams), + security={"bearer_auth": True}, + ), + cast_to=MemoryNoteDeleted, + ) + + +class AsyncNotes(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncNotesWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/openai/openai-python#accessing-raw-response-data-eg-headers + """ + return AsyncNotesWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncNotesWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/openai/openai-python#with_streaming_response + """ + return AsyncNotesWithStreamingResponse(self) + + async def create( + self, + store_id: str, + *, + content: str, + path: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryNote: + """ + Create a memory note. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._post( + path_template("/agents/memory_stores/{store_id}/notes", store_id=store_id), + body=await async_maybe_transform( + { + "content": content, + "path": path, + }, + note_create_params.NoteCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryNote, + ) + + async def retrieve( + self, + note_id: str, + *, + store_id: str, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryNote: + """ + Retrieve a memory note. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + if not note_id: + raise ValueError(f"Expected a non-empty value for `note_id` but received {note_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._get( + path_template("/agents/memory_stores/{store_id}/notes/{note_id}", store_id=store_id, note_id=note_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryNote, + ) + + async def update( + self, + note_id: str, + *, + store_id: str, + content: str, + expected_revision: int, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryNote: + """ + Update a memory note. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + if not note_id: + raise ValueError(f"Expected a non-empty value for `note_id` but received {note_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._post( + path_template("/agents/memory_stores/{store_id}/notes/{note_id}", store_id=store_id, note_id=note_id), + body=await async_maybe_transform( + { + "content": content, + "expected_revision": expected_revision, + }, + note_update_params.NoteUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + security={"bearer_auth": True}, + ), + cast_to=MemoryNote, + ) + + def list( + self, + store_id: str, + *, + after: Optional[str] | Omit = omit, + limit: Optional[int] | Omit = omit, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> AsyncPaginator[MemoryNoteMetadata, AsyncCursorPage[MemoryNoteMetadata]]: + """ + List memory notes. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return self._get_api_list( + path_template("/agents/memory_stores/{store_id}/notes", store_id=store_id), + page=AsyncCursorPage[MemoryNoteMetadata], + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=maybe_transform( + { + "after": after, + "limit": limit, + }, + note_list_params.NoteListParams, + ), + security={"bearer_auth": True}, + ), + model=MemoryNoteMetadata, + ) + + async def delete( + self, + note_id: str, + *, + store_id: str, + expected_revision: int, + # 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, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx2.Timeout | None | NotGiven = not_given, + ) -> MemoryNoteDeleted: + """ + Delete a memory note. + + Args: + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + if not store_id: + raise ValueError(f"Expected a non-empty value for `store_id` but received {store_id!r}") + if not note_id: + raise ValueError(f"Expected a non-empty value for `note_id` but received {note_id!r}") + extra_headers = {"OpenAI-Beta": "agents=v1", **(extra_headers or {})} + return await self._delete( + path_template("/agents/memory_stores/{store_id}/notes/{note_id}", store_id=store_id, note_id=note_id), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + query=await async_maybe_transform( + {"expected_revision": expected_revision}, note_delete_params.NoteDeleteParams + ), + security={"bearer_auth": True}, + ), + cast_to=MemoryNoteDeleted, + ) + + +class NotesWithRawResponse: + def __init__(self, notes: Notes) -> None: + self._notes = notes + + self.create = _legacy_response.to_raw_response_wrapper( + notes.create, + ) + self.retrieve = _legacy_response.to_raw_response_wrapper( + notes.retrieve, + ) + self.update = _legacy_response.to_raw_response_wrapper( + notes.update, + ) + self.list = _legacy_response.to_raw_response_wrapper( + notes.list, + ) + self.delete = _legacy_response.to_raw_response_wrapper( + notes.delete, + ) + + +class AsyncNotesWithRawResponse: + def __init__(self, notes: AsyncNotes) -> None: + self._notes = notes + + self.create = _legacy_response.async_to_raw_response_wrapper( + notes.create, + ) + self.retrieve = _legacy_response.async_to_raw_response_wrapper( + notes.retrieve, + ) + self.update = _legacy_response.async_to_raw_response_wrapper( + notes.update, + ) + self.list = _legacy_response.async_to_raw_response_wrapper( + notes.list, + ) + self.delete = _legacy_response.async_to_raw_response_wrapper( + notes.delete, + ) + + +class NotesWithStreamingResponse: + def __init__(self, notes: Notes) -> None: + self._notes = notes + + self.create = to_streamed_response_wrapper( + notes.create, + ) + self.retrieve = to_streamed_response_wrapper( + notes.retrieve, + ) + self.update = to_streamed_response_wrapper( + notes.update, + ) + self.list = to_streamed_response_wrapper( + notes.list, + ) + self.delete = to_streamed_response_wrapper( + notes.delete, + ) + + +class AsyncNotesWithStreamingResponse: + def __init__(self, notes: AsyncNotes) -> None: + self._notes = notes + + self.create = async_to_streamed_response_wrapper( + notes.create, + ) + self.retrieve = async_to_streamed_response_wrapper( + notes.retrieve, + ) + self.update = async_to_streamed_response_wrapper( + notes.update, + ) + self.list = async_to_streamed_response_wrapper( + notes.list, + ) + self.delete = async_to_streamed_response_wrapper( + notes.delete, + ) diff --git a/src/openai/types/beta/agent_tool.py b/src/openai/types/beta/agent_tool.py index 83cc9f2907..9c09e6d82e 100644 --- a/src/openai/types/beta/agent_tool.py +++ b/src/openai/types/beta/agent_tool.py @@ -18,6 +18,8 @@ "AgentToolResourceWebSearchLocation", "AgentToolResourceComputerUse", "AgentToolResourceAutomations", + "AgentToolResourceMemory", + "AgentToolResourceHistory", ] @@ -136,6 +138,34 @@ class AgentToolResourceAutomations(BaseModel): """The type of the object. Always `automations`.""" +class AgentToolResourceMemory(BaseModel): + """Enables notes in a project-owned memory store.""" + + instructions: Optional[str] = None + """Additional instructions for this memory store.""" + + store_id: Optional[str] = None + """ + Share an existing store in this project, or omit to create a store for the + session. + """ + + type: Literal["memory"] + """The type of the object. Always `memory`.""" + + memory_store_id: Optional[str] = None + """Deprecated response alias for `store_id`.""" + + +class AgentToolResourceHistory(BaseModel): + """Search, list, and read indexed session history.""" + + store_id: Optional[str] = None + + type: Literal["history"] + """The type of the object. Always `history`.""" + + AgentTool: TypeAlias = Annotated[ Union[ AgentToolResourceFunction, @@ -144,6 +174,8 @@ class AgentToolResourceAutomations(BaseModel): AgentToolResourceWebSearch, AgentToolResourceComputerUse, AgentToolResourceAutomations, + AgentToolResourceMemory, + AgentToolResourceHistory, ], PropertyInfo(discriminator="type"), ] diff --git a/src/openai/types/beta/agent_tool_param.py b/src/openai/types/beta/agent_tool_param.py index 6a80df5020..77f4458902 100644 --- a/src/openai/types/beta/agent_tool_param.py +++ b/src/openai/types/beta/agent_tool_param.py @@ -18,6 +18,8 @@ "AgentToolConfigParamWebSearchLocation", "AgentToolConfigParamComputerUse", "AgentToolConfigParamAutomations", + "AgentToolConfigParamMemory", + "AgentToolConfigParamHistory", ] _AgentToolConfigParamFunctionReservedKeywords = TypedDict( @@ -166,6 +168,32 @@ class AgentToolConfigParamAutomations(TypedDict, total=False): """The type of the object. Always `automations`.""" +class AgentToolConfigParamMemory(TypedDict, total=False): + """Enables notes in a project-owned memory store.""" + + type: Required[Literal["memory"]] + """The type of the object. Always `memory`.""" + + instructions: Optional[str] + """Additional instructions for this memory store.""" + + store_id: Optional[str] + """ + Share an existing store in this project, or omit to create a store for the + session. + """ + + +class AgentToolConfigParamHistory(TypedDict, total=False): + """Search, list, and read indexed session history.""" + + type: Required[Literal["history"]] + """The type of the object. Always `history`.""" + + store_id: Optional[str] + """Reuse a project-owned history store, or omit to create one.""" + + AgentToolParam: TypeAlias = Union[ AgentToolConfigParamFunction, AgentToolConfigParamToolSearch, @@ -174,4 +202,6 @@ class AgentToolConfigParamAutomations(TypedDict, total=False): AgentToolConfigParamWebSearch, AgentToolConfigParamComputerUse, AgentToolConfigParamAutomations, + AgentToolConfigParamMemory, + AgentToolConfigParamHistory, ] diff --git a/src/openai/types/beta/agents/__init__.py b/src/openai/types/beta/agents/__init__.py index 500bbbceb1..a06dd6663d 100644 --- a/src/openai/types/beta/agents/__init__.py +++ b/src/openai/types/beta/agents/__init__.py @@ -4,7 +4,9 @@ from .vault import Vault as Vault from .automation import Automation as Automation +from .memory_store import MemoryStore as MemoryStore from .vault_status import VaultStatus as VaultStatus +from .history_store import HistoryStore as HistoryStore from .vault_deleted import VaultDeleted as VaultDeleted from .environment_info import EnvironmentInfo as EnvironmentInfo from .automation_target import AutomationTarget as AutomationTarget @@ -16,6 +18,7 @@ from .vault_create_params import VaultCreateParams as VaultCreateParams from .vault_update_params import VaultUpdateParams as VaultUpdateParams from .automation_created_by import AutomationCreatedBy as AutomationCreatedBy +from .history_store_deleted import HistoryStoreDeleted as HistoryStoreDeleted from .session_create_params import SessionCreateParams as SessionCreateParams from .session_update_params import SessionUpdateParams as SessionUpdateParams from .automation_environment import AutomationEnvironment as AutomationEnvironment @@ -25,6 +28,12 @@ from .environment_list_params import EnvironmentListParams as EnvironmentListParams from .automation_create_params import AutomationCreateParams as AutomationCreateParams from .automation_update_params import AutomationUpdateParams as AutomationUpdateParams +from .memory_store_list_params import MemoryStoreListParams as MemoryStoreListParams from .automation_metadata_param import AutomationMetadataParam as AutomationMetadataParam from .environment_create_params import EnvironmentCreateParams as EnvironmentCreateParams +from .history_store_list_params import HistoryStoreListParams as HistoryStoreListParams from .vault_status_filter_param import VaultStatusFilterParam as VaultStatusFilterParam +from .memory_store_create_params import MemoryStoreCreateParams as MemoryStoreCreateParams +from .memory_store_update_params import MemoryStoreUpdateParams as MemoryStoreUpdateParams +from .history_store_create_params import HistoryStoreCreateParams as HistoryStoreCreateParams +from .history_store_update_params import HistoryStoreUpdateParams as HistoryStoreUpdateParams diff --git a/src/openai/types/beta/agents/history_store.py b/src/openai/types/beta/agents/history_store.py new file mode 100644 index 0000000000..9f286c5e65 --- /dev/null +++ b/src/openai/types/beta/agents/history_store.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from typing import Dict, Optional + +from ...._models import BaseModel + +__all__ = ["HistoryStore"] + + +class HistoryStore(BaseModel): + id: str + + created_at: int + + metadata: Optional[Dict[str, str]] = None + + name: Optional[str] = None diff --git a/src/openai/types/beta/agents/history_store_create_params.py b/src/openai/types/beta/agents/history_store_create_params.py new file mode 100644 index 0000000000..a50a97062f --- /dev/null +++ b/src/openai/types/beta/agents/history_store_create_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import TypedDict + +__all__ = ["HistoryStoreCreateParams"] + + +class HistoryStoreCreateParams(TypedDict, total=False): + metadata: Dict[str, str] + + name: str diff --git a/src/openai/types/beta/agents/history_store_deleted.py b/src/openai/types/beta/agents/history_store_deleted.py new file mode 100644 index 0000000000..cbf8b12c73 --- /dev/null +++ b/src/openai/types/beta/agents/history_store_deleted.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from ...._models import BaseModel + +__all__ = ["HistoryStoreDeleted"] + + +class HistoryStoreDeleted(BaseModel): + id: str + + deleted: bool diff --git a/src/openai/types/beta/agents/history_store_list_params.py b/src/openai/types/beta/agents/history_store_list_params.py new file mode 100644 index 0000000000..63ab551b3d --- /dev/null +++ b/src/openai/types/beta/agents/history_store_list_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import TypedDict + +__all__ = ["HistoryStoreListParams"] + + +class HistoryStoreListParams(TypedDict, total=False): + limit: Optional[int] + + page: Optional[str] + """Pass the next cursor from the previous page, even if that page was empty.""" diff --git a/src/openai/types/beta/agents/history_store_update_params.py b/src/openai/types/beta/agents/history_store_update_params.py new file mode 100644 index 0000000000..1b810764eb --- /dev/null +++ b/src/openai/types/beta/agents/history_store_update_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import TypedDict + +__all__ = ["HistoryStoreUpdateParams"] + + +class HistoryStoreUpdateParams(TypedDict, total=False): + metadata: Dict[str, str] + + name: str diff --git a/src/openai/types/beta/agents/history_stores/__init__.py b/src/openai/types/beta/agents/history_stores/__init__.py new file mode 100644 index 0000000000..0bfe76a1ff --- /dev/null +++ b/src/openai/types/beta/agents/history_stores/__init__.py @@ -0,0 +1,5 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .session_list_params import SessionListParams as SessionListParams diff --git a/src/openai/types/beta/agents/history_stores/session_list_params.py b/src/openai/types/beta/agents/history_stores/session_list_params.py new file mode 100644 index 0000000000..fdb1e23194 --- /dev/null +++ b/src/openai/types/beta/agents/history_stores/session_list_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import TypedDict + +__all__ = ["SessionListParams"] + + +class SessionListParams(TypedDict, total=False): + limit: Optional[int] + + page: Optional[str] + """Pass the next cursor from the previous page, even if that page was empty.""" diff --git a/src/openai/types/beta/agents/memory_store.py b/src/openai/types/beta/agents/memory_store.py new file mode 100644 index 0000000000..5e8e86f1fe --- /dev/null +++ b/src/openai/types/beta/agents/memory_store.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from typing import Dict, Optional + +from ...._models import BaseModel + +__all__ = ["MemoryStore"] + + +class MemoryStore(BaseModel): + id: str + + created_at: int + + metadata: Optional[Dict[str, str]] = None + + name: Optional[str] = None diff --git a/src/openai/types/beta/agents/memory_store_create_params.py b/src/openai/types/beta/agents/memory_store_create_params.py new file mode 100644 index 0000000000..92ac12af64 --- /dev/null +++ b/src/openai/types/beta/agents/memory_store_create_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import TypedDict + +__all__ = ["MemoryStoreCreateParams"] + + +class MemoryStoreCreateParams(TypedDict, total=False): + metadata: Dict[str, str] + + name: str diff --git a/src/openai/types/beta/agents/memory_store_list_params.py b/src/openai/types/beta/agents/memory_store_list_params.py new file mode 100644 index 0000000000..4e3fe356a1 --- /dev/null +++ b/src/openai/types/beta/agents/memory_store_list_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import TypedDict + +__all__ = ["MemoryStoreListParams"] + + +class MemoryStoreListParams(TypedDict, total=False): + limit: Optional[int] + + page: Optional[str] + """Pass the next cursor from the previous page, even if that page was empty.""" diff --git a/src/openai/types/beta/agents/memory_store_update_params.py b/src/openai/types/beta/agents/memory_store_update_params.py new file mode 100644 index 0000000000..b647f7a805 --- /dev/null +++ b/src/openai/types/beta/agents/memory_store_update_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict +from typing_extensions import TypedDict + +__all__ = ["MemoryStoreUpdateParams"] + + +class MemoryStoreUpdateParams(TypedDict, total=False): + metadata: Dict[str, str] + + name: str diff --git a/src/openai/types/beta/agents/memory_stores/__init__.py b/src/openai/types/beta/agents/memory_stores/__init__.py new file mode 100644 index 0000000000..5d88c8cc5c --- /dev/null +++ b/src/openai/types/beta/agents/memory_stores/__init__.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from .memory_note import MemoryNote as MemoryNote +from .note_list_params import NoteListParams as NoteListParams +from .note_create_params import NoteCreateParams as NoteCreateParams +from .note_delete_params import NoteDeleteParams as NoteDeleteParams +from .note_update_params import NoteUpdateParams as NoteUpdateParams +from .memory_note_deleted import MemoryNoteDeleted as MemoryNoteDeleted +from .memory_note_metadata import MemoryNoteMetadata as MemoryNoteMetadata diff --git a/src/openai/types/beta/agents/memory_stores/memory_note.py b/src/openai/types/beta/agents/memory_stores/memory_note.py new file mode 100644 index 0000000000..674984e456 --- /dev/null +++ b/src/openai/types/beta/agents/memory_stores/memory_note.py @@ -0,0 +1,19 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from ....._models import BaseModel + +__all__ = ["MemoryNote"] + + +class MemoryNote(BaseModel): + id: str + + content: str + + created_at: int + + path: str + + revision: int + + updated_at: int diff --git a/src/openai/types/beta/agents/memory_stores/memory_note_deleted.py b/src/openai/types/beta/agents/memory_stores/memory_note_deleted.py new file mode 100644 index 0000000000..501f06be7a --- /dev/null +++ b/src/openai/types/beta/agents/memory_stores/memory_note_deleted.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from ....._models import BaseModel + +__all__ = ["MemoryNoteDeleted"] + + +class MemoryNoteDeleted(BaseModel): + id: str + + deleted: bool diff --git a/src/openai/types/beta/agents/memory_stores/memory_note_metadata.py b/src/openai/types/beta/agents/memory_stores/memory_note_metadata.py new file mode 100644 index 0000000000..d5290323b2 --- /dev/null +++ b/src/openai/types/beta/agents/memory_stores/memory_note_metadata.py @@ -0,0 +1,17 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from ....._models import BaseModel + +__all__ = ["MemoryNoteMetadata"] + + +class MemoryNoteMetadata(BaseModel): + id: str + + created_at: int + + path: str + + revision: int + + updated_at: int diff --git a/src/openai/types/beta/agents/memory_stores/note_create_params.py b/src/openai/types/beta/agents/memory_stores/note_create_params.py new file mode 100644 index 0000000000..72e666f192 --- /dev/null +++ b/src/openai/types/beta/agents/memory_stores/note_create_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["NoteCreateParams"] + + +class NoteCreateParams(TypedDict, total=False): + content: Required[str] + + path: Required[str] diff --git a/src/openai/types/beta/agents/memory_stores/note_delete_params.py b/src/openai/types/beta/agents/memory_stores/note_delete_params.py new file mode 100644 index 0000000000..8968e6fb3f --- /dev/null +++ b/src/openai/types/beta/agents/memory_stores/note_delete_params.py @@ -0,0 +1,13 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["NoteDeleteParams"] + + +class NoteDeleteParams(TypedDict, total=False): + store_id: Required[str] + + expected_revision: Required[int] diff --git a/src/openai/types/beta/agents/memory_stores/note_list_params.py b/src/openai/types/beta/agents/memory_stores/note_list_params.py new file mode 100644 index 0000000000..57c246f2a1 --- /dev/null +++ b/src/openai/types/beta/agents/memory_stores/note_list_params.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import TypedDict + +__all__ = ["NoteListParams"] + + +class NoteListParams(TypedDict, total=False): + after: Optional[str] + + limit: Optional[int] diff --git a/src/openai/types/beta/agents/memory_stores/note_update_params.py b/src/openai/types/beta/agents/memory_stores/note_update_params.py new file mode 100644 index 0000000000..621df57d89 --- /dev/null +++ b/src/openai/types/beta/agents/memory_stores/note_update_params.py @@ -0,0 +1,15 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["NoteUpdateParams"] + + +class NoteUpdateParams(TypedDict, total=False): + store_id: Required[str] + + content: Required[str] + + expected_revision: Required[int] diff --git a/src/openai/types/beta/persisted_agent_tool.py b/src/openai/types/beta/persisted_agent_tool.py index f84d002362..76bde6ac94 100644 --- a/src/openai/types/beta/persisted_agent_tool.py +++ b/src/openai/types/beta/persisted_agent_tool.py @@ -19,6 +19,8 @@ "PersistedAgentToolResourceWebSearchLocation", "PersistedAgentToolResourceComputerUse", "PersistedAgentToolResourceAutomations", + "PersistedAgentToolResourceMemory", + "PersistedAgentToolResourceHistory", ] @@ -141,6 +143,34 @@ class PersistedAgentToolResourceAutomations(BaseModel): """The type of the object. Always `automations`.""" +class PersistedAgentToolResourceMemory(BaseModel): + """Enables notes in a project-owned memory store.""" + + instructions: Optional[str] = None + """Additional instructions for this memory store.""" + + store_id: Optional[str] = None + """ + Share an existing store in this project, or omit to create a store for the + session. + """ + + type: Literal["memory"] + """The type of the object. Always `memory`.""" + + memory_store_id: Optional[str] = None + """Deprecated response alias for `store_id`.""" + + +class PersistedAgentToolResourceHistory(BaseModel): + """Search, list, and read indexed session history.""" + + store_id: Optional[str] = None + + type: Literal["history"] + """The type of the object. Always `history`.""" + + PersistedAgentTool: TypeAlias = Annotated[ Union[ PersistedAgentToolResourceFunction, @@ -150,6 +180,8 @@ class PersistedAgentToolResourceAutomations(BaseModel): PersistedAgentToolResourceWebSearch, PersistedAgentToolResourceComputerUse, PersistedAgentToolResourceAutomations, + PersistedAgentToolResourceMemory, + PersistedAgentToolResourceHistory, ], PropertyInfo(discriminator="type"), ] diff --git a/src/openai/types/beta/persisted_agent_tool_param.py b/src/openai/types/beta/persisted_agent_tool_param.py index c0ac64fc42..39201f390f 100644 --- a/src/openai/types/beta/persisted_agent_tool_param.py +++ b/src/openai/types/beta/persisted_agent_tool_param.py @@ -18,6 +18,8 @@ "PersistedAgentToolConfigParamWebSearchLocation", "PersistedAgentToolConfigParamComputerUse", "PersistedAgentToolConfigParamAutomations", + "PersistedAgentToolConfigParamMemory", + "PersistedAgentToolConfigParamHistory", ] _PersistedAgentToolConfigParamFunctionReservedKeywords = TypedDict( @@ -163,6 +165,32 @@ class PersistedAgentToolConfigParamAutomations(TypedDict, total=False): """The type of the object. Always `automations`.""" +class PersistedAgentToolConfigParamMemory(TypedDict, total=False): + """Enables notes in a project-owned memory store.""" + + type: Required[Literal["memory"]] + """The type of the object. Always `memory`.""" + + instructions: Optional[str] + """Additional instructions for this memory store.""" + + store_id: Optional[str] + """ + Share an existing store in this project, or omit to create a store for the + session. + """ + + +class PersistedAgentToolConfigParamHistory(TypedDict, total=False): + """Search, list, and read indexed session history.""" + + type: Required[Literal["history"]] + """The type of the object. Always `history`.""" + + store_id: Optional[str] + """Reuse a project-owned history store, or omit to create one.""" + + PersistedAgentToolParam: TypeAlias = Union[ PersistedAgentToolConfigParamFunction, PersistedAgentToolConfigParamToolSearch, @@ -171,4 +199,6 @@ class PersistedAgentToolConfigParamAutomations(TypedDict, total=False): PersistedAgentToolConfigParamWebSearch, PersistedAgentToolConfigParamComputerUse, PersistedAgentToolConfigParamAutomations, + PersistedAgentToolConfigParamMemory, + PersistedAgentToolConfigParamHistory, ] diff --git a/tests/api_resources/beta/agents/history_stores/__init__.py b/tests/api_resources/beta/agents/history_stores/__init__.py new file mode 100644 index 0000000000..d7a8b19970 --- /dev/null +++ b/tests/api_resources/beta/agents/history_stores/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/beta/agents/history_stores/test_sessions.py b/tests/api_resources/beta/agents/history_stores/test_sessions.py new file mode 100644 index 0000000000..f3cf9078e6 --- /dev/null +++ b/tests/api_resources/beta/agents/history_stores/test_sessions.py @@ -0,0 +1,119 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from openai import OpenAI, AsyncOpenAI +from tests.utils import assert_matches_type +from openai.pagination import SyncTokenPage, AsyncTokenPage +from openai.types.beta import AgentSession + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestSessions: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_list(self, client: OpenAI) -> None: + session = client.beta.agents.history_stores.sessions.list( + store_id="store_id", + ) + assert_matches_type(SyncTokenPage[AgentSession], session, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: OpenAI) -> None: + session = client.beta.agents.history_stores.sessions.list( + store_id="store_id", + limit=1, + page="page", + ) + assert_matches_type(SyncTokenPage[AgentSession], session, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: OpenAI) -> None: + response = client.beta.agents.history_stores.sessions.with_raw_response.list( + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(SyncTokenPage[AgentSession], session, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: OpenAI) -> None: + with client.beta.agents.history_stores.sessions.with_streaming_response.list( + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = response.parse() + assert_matches_type(SyncTokenPage[AgentSession], session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.history_stores.sessions.with_raw_response.list( + store_id="", + ) + + +class TestAsyncSessions: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_list(self, async_client: AsyncOpenAI) -> None: + session = await async_client.beta.agents.history_stores.sessions.list( + store_id="store_id", + ) + assert_matches_type(AsyncTokenPage[AgentSession], session, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: + session = await async_client.beta.agents.history_stores.sessions.list( + store_id="store_id", + limit=1, + page="page", + ) + assert_matches_type(AsyncTokenPage[AgentSession], session, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.history_stores.sessions.with_raw_response.list( + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + session = response.parse() + assert_matches_type(AsyncTokenPage[AgentSession], session, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.history_stores.sessions.with_streaming_response.list( + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + session = await response.parse() + assert_matches_type(AsyncTokenPage[AgentSession], session, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.history_stores.sessions.with_raw_response.list( + store_id="", + ) diff --git a/tests/api_resources/beta/agents/memory_stores/__init__.py b/tests/api_resources/beta/agents/memory_stores/__init__.py new file mode 100644 index 0000000000..d7a8b19970 --- /dev/null +++ b/tests/api_resources/beta/agents/memory_stores/__init__.py @@ -0,0 +1 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/beta/agents/memory_stores/test_notes.py b/tests/api_resources/beta/agents/memory_stores/test_notes.py new file mode 100644 index 0000000000..6c65ab684a --- /dev/null +++ b/tests/api_resources/beta/agents/memory_stores/test_notes.py @@ -0,0 +1,533 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from openai import OpenAI, AsyncOpenAI +from tests.utils import assert_matches_type +from openai.pagination import SyncCursorPage, AsyncCursorPage +from openai.types.beta.agents.memory_stores import ( + MemoryNote, + MemoryNoteDeleted, + MemoryNoteMetadata, +) + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestNotes: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: OpenAI) -> None: + note = client.beta.agents.memory_stores.notes.create( + store_id="store_id", + content="content", + path="path", + ) + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.notes.with_raw_response.create( + store_id="store_id", + content="content", + path="path", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.notes.with_streaming_response.create( + store_id="store_id", + content="content", + path="path", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_create(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.memory_stores.notes.with_raw_response.create( + store_id="", + content="content", + path="path", + ) + + @parametrize + def test_method_retrieve(self, client: OpenAI) -> None: + note = client.beta.agents.memory_stores.notes.retrieve( + note_id="note_id", + store_id="store_id", + ) + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.notes.with_raw_response.retrieve( + note_id="note_id", + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.notes.with_streaming_response.retrieve( + note_id="note_id", + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.memory_stores.notes.with_raw_response.retrieve( + note_id="note_id", + store_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `note_id` but received ''"): + client.beta.agents.memory_stores.notes.with_raw_response.retrieve( + note_id="", + store_id="store_id", + ) + + @parametrize + def test_method_update(self, client: OpenAI) -> None: + note = client.beta.agents.memory_stores.notes.update( + note_id="note_id", + store_id="store_id", + content="content", + expected_revision=0, + ) + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.notes.with_raw_response.update( + note_id="note_id", + store_id="store_id", + content="content", + expected_revision=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.notes.with_streaming_response.update( + note_id="note_id", + store_id="store_id", + content="content", + expected_revision=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.memory_stores.notes.with_raw_response.update( + note_id="note_id", + store_id="", + content="content", + expected_revision=0, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `note_id` but received ''"): + client.beta.agents.memory_stores.notes.with_raw_response.update( + note_id="", + store_id="store_id", + content="content", + expected_revision=0, + ) + + @parametrize + def test_method_list(self, client: OpenAI) -> None: + note = client.beta.agents.memory_stores.notes.list( + store_id="store_id", + ) + assert_matches_type(SyncCursorPage[MemoryNoteMetadata], note, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: OpenAI) -> None: + note = client.beta.agents.memory_stores.notes.list( + store_id="store_id", + after="after", + limit=1, + ) + assert_matches_type(SyncCursorPage[MemoryNoteMetadata], note, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.notes.with_raw_response.list( + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(SyncCursorPage[MemoryNoteMetadata], note, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.notes.with_streaming_response.list( + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = response.parse() + assert_matches_type(SyncCursorPage[MemoryNoteMetadata], note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_list(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.memory_stores.notes.with_raw_response.list( + store_id="", + ) + + @parametrize + def test_method_delete(self, client: OpenAI) -> None: + note = client.beta.agents.memory_stores.notes.delete( + note_id="note_id", + store_id="store_id", + expected_revision=0, + ) + assert_matches_type(MemoryNoteDeleted, note, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.notes.with_raw_response.delete( + note_id="note_id", + store_id="store_id", + expected_revision=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(MemoryNoteDeleted, note, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.notes.with_streaming_response.delete( + note_id="note_id", + store_id="store_id", + expected_revision=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = response.parse() + assert_matches_type(MemoryNoteDeleted, note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.memory_stores.notes.with_raw_response.delete( + note_id="note_id", + store_id="", + expected_revision=0, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `note_id` but received ''"): + client.beta.agents.memory_stores.notes.with_raw_response.delete( + note_id="", + store_id="store_id", + expected_revision=0, + ) + + +class TestAsyncNotes: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncOpenAI) -> None: + note = await async_client.beta.agents.memory_stores.notes.create( + store_id="store_id", + content="content", + path="path", + ) + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.notes.with_raw_response.create( + store_id="store_id", + content="content", + path="path", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.notes.with_streaming_response.create( + store_id="store_id", + content="content", + path="path", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = await response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_create(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.memory_stores.notes.with_raw_response.create( + store_id="", + content="content", + path="path", + ) + + @parametrize + async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: + note = await async_client.beta.agents.memory_stores.notes.retrieve( + note_id="note_id", + store_id="store_id", + ) + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.notes.with_raw_response.retrieve( + note_id="note_id", + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.notes.with_streaming_response.retrieve( + note_id="note_id", + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = await response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.memory_stores.notes.with_raw_response.retrieve( + note_id="note_id", + store_id="", + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `note_id` but received ''"): + await async_client.beta.agents.memory_stores.notes.with_raw_response.retrieve( + note_id="", + store_id="store_id", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncOpenAI) -> None: + note = await async_client.beta.agents.memory_stores.notes.update( + note_id="note_id", + store_id="store_id", + content="content", + expected_revision=0, + ) + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.notes.with_raw_response.update( + note_id="note_id", + store_id="store_id", + content="content", + expected_revision=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.notes.with_streaming_response.update( + note_id="note_id", + store_id="store_id", + content="content", + expected_revision=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = await response.parse() + assert_matches_type(MemoryNote, note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.memory_stores.notes.with_raw_response.update( + note_id="note_id", + store_id="", + content="content", + expected_revision=0, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `note_id` but received ''"): + await async_client.beta.agents.memory_stores.notes.with_raw_response.update( + note_id="", + store_id="store_id", + content="content", + expected_revision=0, + ) + + @parametrize + async def test_method_list(self, async_client: AsyncOpenAI) -> None: + note = await async_client.beta.agents.memory_stores.notes.list( + store_id="store_id", + ) + assert_matches_type(AsyncCursorPage[MemoryNoteMetadata], note, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: + note = await async_client.beta.agents.memory_stores.notes.list( + store_id="store_id", + after="after", + limit=1, + ) + assert_matches_type(AsyncCursorPage[MemoryNoteMetadata], note, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.notes.with_raw_response.list( + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(AsyncCursorPage[MemoryNoteMetadata], note, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.notes.with_streaming_response.list( + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = await response.parse() + assert_matches_type(AsyncCursorPage[MemoryNoteMetadata], note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_list(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.memory_stores.notes.with_raw_response.list( + store_id="", + ) + + @parametrize + async def test_method_delete(self, async_client: AsyncOpenAI) -> None: + note = await async_client.beta.agents.memory_stores.notes.delete( + note_id="note_id", + store_id="store_id", + expected_revision=0, + ) + assert_matches_type(MemoryNoteDeleted, note, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.notes.with_raw_response.delete( + note_id="note_id", + store_id="store_id", + expected_revision=0, + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + note = response.parse() + assert_matches_type(MemoryNoteDeleted, note, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.notes.with_streaming_response.delete( + note_id="note_id", + store_id="store_id", + expected_revision=0, + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + note = await response.parse() + assert_matches_type(MemoryNoteDeleted, note, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.memory_stores.notes.with_raw_response.delete( + note_id="note_id", + store_id="", + expected_revision=0, + ) + + with pytest.raises(ValueError, match=r"Expected a non-empty value for `note_id` but received ''"): + await async_client.beta.agents.memory_stores.notes.with_raw_response.delete( + note_id="", + store_id="store_id", + expected_revision=0, + ) diff --git a/tests/api_resources/beta/agents/test_history_stores.py b/tests/api_resources/beta/agents/test_history_stores.py new file mode 100644 index 0000000000..ebd2968e9e --- /dev/null +++ b/tests/api_resources/beta/agents/test_history_stores.py @@ -0,0 +1,403 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from openai import OpenAI, AsyncOpenAI +from tests.utils import assert_matches_type +from openai.pagination import SyncTokenPage, AsyncTokenPage +from openai.types.beta.agents import HistoryStore, HistoryStoreDeleted + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestHistoryStores: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: OpenAI) -> None: + history_store = client.beta.agents.history_stores.create() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: OpenAI) -> None: + history_store = client.beta.agents.history_stores.create( + metadata={"foo": "string"}, + name="name", + ) + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: OpenAI) -> None: + response = client.beta.agents.history_stores.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: OpenAI) -> None: + with client.beta.agents.history_stores.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_retrieve(self, client: OpenAI) -> None: + history_store = client.beta.agents.history_stores.retrieve( + "store_id", + ) + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: OpenAI) -> None: + response = client.beta.agents.history_stores.with_raw_response.retrieve( + "store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: OpenAI) -> None: + with client.beta.agents.history_stores.with_streaming_response.retrieve( + "store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.history_stores.with_raw_response.retrieve( + "", + ) + + @parametrize + def test_method_update(self, client: OpenAI) -> None: + history_store = client.beta.agents.history_stores.update( + store_id="store_id", + ) + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: OpenAI) -> None: + history_store = client.beta.agents.history_stores.update( + store_id="store_id", + metadata={"foo": "string"}, + name="name", + ) + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: OpenAI) -> None: + response = client.beta.agents.history_stores.with_raw_response.update( + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: OpenAI) -> None: + with client.beta.agents.history_stores.with_streaming_response.update( + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.history_stores.with_raw_response.update( + store_id="", + ) + + @parametrize + def test_method_list(self, client: OpenAI) -> None: + history_store = client.beta.agents.history_stores.list() + assert_matches_type(SyncTokenPage[HistoryStore], history_store, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: OpenAI) -> None: + history_store = client.beta.agents.history_stores.list( + limit=1, + page="page", + ) + assert_matches_type(SyncTokenPage[HistoryStore], history_store, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: OpenAI) -> None: + response = client.beta.agents.history_stores.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(SyncTokenPage[HistoryStore], history_store, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: OpenAI) -> None: + with client.beta.agents.history_stores.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = response.parse() + assert_matches_type(SyncTokenPage[HistoryStore], history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_delete(self, client: OpenAI) -> None: + history_store = client.beta.agents.history_stores.delete( + "store_id", + ) + assert_matches_type(HistoryStoreDeleted, history_store, path=["response"]) + + @parametrize + def test_raw_response_delete(self, client: OpenAI) -> None: + response = client.beta.agents.history_stores.with_raw_response.delete( + "store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(HistoryStoreDeleted, history_store, path=["response"]) + + @parametrize + def test_streaming_response_delete(self, client: OpenAI) -> None: + with client.beta.agents.history_stores.with_streaming_response.delete( + "store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = response.parse() + assert_matches_type(HistoryStoreDeleted, history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_delete(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.history_stores.with_raw_response.delete( + "", + ) + + +class TestAsyncHistoryStores: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncOpenAI) -> None: + history_store = await async_client.beta.agents.history_stores.create() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None: + history_store = await async_client.beta.agents.history_stores.create( + metadata={"foo": "string"}, + name="name", + ) + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.history_stores.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.history_stores.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = await response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: + history_store = await async_client.beta.agents.history_stores.retrieve( + "store_id", + ) + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.history_stores.with_raw_response.retrieve( + "store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.history_stores.with_streaming_response.retrieve( + "store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = await response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.history_stores.with_raw_response.retrieve( + "", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncOpenAI) -> None: + history_store = await async_client.beta.agents.history_stores.update( + store_id="store_id", + ) + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None: + history_store = await async_client.beta.agents.history_stores.update( + store_id="store_id", + metadata={"foo": "string"}, + name="name", + ) + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.history_stores.with_raw_response.update( + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.history_stores.with_streaming_response.update( + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = await response.parse() + assert_matches_type(HistoryStore, history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.history_stores.with_raw_response.update( + store_id="", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncOpenAI) -> None: + history_store = await async_client.beta.agents.history_stores.list() + assert_matches_type(AsyncTokenPage[HistoryStore], history_store, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: + history_store = await async_client.beta.agents.history_stores.list( + limit=1, + page="page", + ) + assert_matches_type(AsyncTokenPage[HistoryStore], history_store, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.history_stores.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(AsyncTokenPage[HistoryStore], history_store, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.history_stores.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = await response.parse() + assert_matches_type(AsyncTokenPage[HistoryStore], history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_delete(self, async_client: AsyncOpenAI) -> None: + history_store = await async_client.beta.agents.history_stores.delete( + "store_id", + ) + assert_matches_type(HistoryStoreDeleted, history_store, path=["response"]) + + @parametrize + async def test_raw_response_delete(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.history_stores.with_raw_response.delete( + "store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + history_store = response.parse() + assert_matches_type(HistoryStoreDeleted, history_store, path=["response"]) + + @parametrize + async def test_streaming_response_delete(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.history_stores.with_streaming_response.delete( + "store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + history_store = await response.parse() + assert_matches_type(HistoryStoreDeleted, history_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_delete(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.history_stores.with_raw_response.delete( + "", + ) diff --git a/tests/api_resources/beta/agents/test_memory_stores.py b/tests/api_resources/beta/agents/test_memory_stores.py new file mode 100644 index 0000000000..2f9034e2dc --- /dev/null +++ b/tests/api_resources/beta/agents/test_memory_stores.py @@ -0,0 +1,327 @@ +# File generated from our OpenAPI spec by Castiron. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from openai import OpenAI, AsyncOpenAI +from tests.utils import assert_matches_type +from openai.pagination import SyncTokenPage, AsyncTokenPage +from openai.types.beta.agents import MemoryStore + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestMemoryStores: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create(self, client: OpenAI) -> None: + memory_store = client.beta.agents.memory_stores.create() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + def test_method_create_with_all_params(self, client: OpenAI) -> None: + memory_store = client.beta.agents.memory_stores.create( + metadata={"foo": "string"}, + name="name", + ) + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + def test_raw_response_create(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + def test_streaming_response_create(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_method_retrieve(self, client: OpenAI) -> None: + memory_store = client.beta.agents.memory_stores.retrieve( + "store_id", + ) + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + def test_raw_response_retrieve(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.with_raw_response.retrieve( + "store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + def test_streaming_response_retrieve(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.with_streaming_response.retrieve( + "store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_retrieve(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.memory_stores.with_raw_response.retrieve( + "", + ) + + @parametrize + def test_method_update(self, client: OpenAI) -> None: + memory_store = client.beta.agents.memory_stores.update( + store_id="store_id", + ) + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: OpenAI) -> None: + memory_store = client.beta.agents.memory_stores.update( + store_id="store_id", + metadata={"foo": "string"}, + name="name", + ) + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.with_raw_response.update( + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.with_streaming_response.update( + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + def test_path_params_update(self, client: OpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + client.beta.agents.memory_stores.with_raw_response.update( + store_id="", + ) + + @parametrize + def test_method_list(self, client: OpenAI) -> None: + memory_store = client.beta.agents.memory_stores.list() + assert_matches_type(SyncTokenPage[MemoryStore], memory_store, path=["response"]) + + @parametrize + def test_method_list_with_all_params(self, client: OpenAI) -> None: + memory_store = client.beta.agents.memory_stores.list( + limit=1, + page="page", + ) + assert_matches_type(SyncTokenPage[MemoryStore], memory_store, path=["response"]) + + @parametrize + def test_raw_response_list(self, client: OpenAI) -> None: + response = client.beta.agents.memory_stores.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + memory_store = response.parse() + assert_matches_type(SyncTokenPage[MemoryStore], memory_store, path=["response"]) + + @parametrize + def test_streaming_response_list(self, client: OpenAI) -> None: + with client.beta.agents.memory_stores.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + memory_store = response.parse() + assert_matches_type(SyncTokenPage[MemoryStore], memory_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncMemoryStores: + parametrize = pytest.mark.parametrize( + "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] + ) + + @parametrize + async def test_method_create(self, async_client: AsyncOpenAI) -> None: + memory_store = await async_client.beta.agents.memory_stores.create() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + async def test_method_create_with_all_params(self, async_client: AsyncOpenAI) -> None: + memory_store = await async_client.beta.agents.memory_stores.create( + metadata={"foo": "string"}, + name="name", + ) + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + async def test_raw_response_create(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.with_raw_response.create() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + async def test_streaming_response_create(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.with_streaming_response.create() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + memory_store = await response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_method_retrieve(self, async_client: AsyncOpenAI) -> None: + memory_store = await async_client.beta.agents.memory_stores.retrieve( + "store_id", + ) + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + async def test_raw_response_retrieve(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.with_raw_response.retrieve( + "store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + async def test_streaming_response_retrieve(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.with_streaming_response.retrieve( + "store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + memory_store = await response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_retrieve(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.memory_stores.with_raw_response.retrieve( + "", + ) + + @parametrize + async def test_method_update(self, async_client: AsyncOpenAI) -> None: + memory_store = await async_client.beta.agents.memory_stores.update( + store_id="store_id", + ) + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncOpenAI) -> None: + memory_store = await async_client.beta.agents.memory_stores.update( + store_id="store_id", + metadata={"foo": "string"}, + name="name", + ) + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.with_raw_response.update( + store_id="store_id", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + memory_store = response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.with_streaming_response.update( + store_id="store_id", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + memory_store = await response.parse() + assert_matches_type(MemoryStore, memory_store, path=["response"]) + + assert cast(Any, response.is_closed) is True + + @parametrize + async def test_path_params_update(self, async_client: AsyncOpenAI) -> None: + with pytest.raises(ValueError, match=r"Expected a non-empty value for `store_id` but received ''"): + await async_client.beta.agents.memory_stores.with_raw_response.update( + store_id="", + ) + + @parametrize + async def test_method_list(self, async_client: AsyncOpenAI) -> None: + memory_store = await async_client.beta.agents.memory_stores.list() + assert_matches_type(AsyncTokenPage[MemoryStore], memory_store, path=["response"]) + + @parametrize + async def test_method_list_with_all_params(self, async_client: AsyncOpenAI) -> None: + memory_store = await async_client.beta.agents.memory_stores.list( + limit=1, + page="page", + ) + assert_matches_type(AsyncTokenPage[MemoryStore], memory_store, path=["response"]) + + @parametrize + async def test_raw_response_list(self, async_client: AsyncOpenAI) -> None: + response = await async_client.beta.agents.memory_stores.with_raw_response.list() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + memory_store = response.parse() + assert_matches_type(AsyncTokenPage[MemoryStore], memory_store, path=["response"]) + + @parametrize + async def test_streaming_response_list(self, async_client: AsyncOpenAI) -> None: + async with async_client.beta.agents.memory_stores.with_streaming_response.list() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + memory_store = await response.parse() + assert_matches_type(AsyncTokenPage[MemoryStore], memory_store, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/test_agent_memory_history.py b/tests/test_agent_memory_history.py new file mode 100644 index 0000000000..f7a326b423 --- /dev/null +++ b/tests/test_agent_memory_history.py @@ -0,0 +1,71 @@ +from __future__ import annotations + +import httpx2 +import pytest + +from openai import OpenAI +from tests.respx2 import MockRouter + +BASE_URL = "https://example.test/v1" +pytestmark = pytest.mark.respx2(base_url=BASE_URL, assert_all_called=True) + + +def mock_store_pages(router: MockRouter, path: str, rows: list[dict[str, object]]) -> None: + first = {"object": "page", "data": [], "next": "resume", "has_more": True} + router.get(path, params__eq={}).mock(side_effect=[httpx2.Response(200, json=first)]) + router.get(path, params__eq={"page": "resume"}).respond( + json={"object": "page", "data": rows, "next": None, "has_more": False} + ) + + +@pytest.mark.parametrize("kind", ["memory", "history"]) +def test_stores_continue_past_empty_pages(respx2_mock: MockRouter, kind: str) -> None: + mock_store_pages( + respx2_mock, + f"/agents/{kind}_stores", + [ + {"id": "named", "created_at": 1, "name": "Research", "metadata": {"team": "science"}}, + {"id": "unnamed", "created_at": 2, "name": None, "metadata": None}, + ], + ) + with OpenAI(base_url=BASE_URL, api_key="test-key", http_client=httpx2.Client(trust_env=False)) as client: + agents = client.beta.agents + page = agents.memory_stores.list() if kind == "memory" else agents.history_stores.list() + assert [(store.name, store.metadata) for store in page] == [("Research", {"team": "science"}), (None, None)] + + +@pytest.mark.parametrize("mode", ["value", "null", "omitted_alias"]) +def test_agent_and_history_session_tools(respx2_mock: MockRouter, mode: str) -> None: + memory_id = "mem_test" if mode == "value" else None + history_id = "hist_test" if mode == "value" else None + instructions = "Remember preferences" if mode == "value" else None + memory = {"type": "memory", "store_id": memory_id, "instructions": instructions} + if mode != "omitted_alias": + memory["memory_store_id"] = memory_id + agent = {"tools": [memory, {"type": "history", "store_id": history_id}]} + respx2_mock.get("/agents/agent_test").respond(json=agent) + mock_store_pages(respx2_mock, "/agents/history_stores/hist_test/sessions", [{"agent": agent}]) + + with OpenAI(base_url=BASE_URL, api_key="test-key", http_client=httpx2.Client(trust_env=False)) as client: + saved = client.beta.agents.retrieve("agent_test") + (session,) = client.beta.agents.history_stores.sessions.list("hist_test") + for tools in (saved.tools, session.agent.tools): + memory_tool, history_tool = tools + assert memory_tool.type == "memory" + assert memory_tool.store_id == memory_id + assert memory_tool.memory_store_id == memory_id + assert memory_tool.instructions == instructions + assert history_tool.type == "history" + assert history_tool.store_id == history_id + + +def test_notes_continue_after_the_last_id(respx2_mock: MockRouter) -> None: + path = "/agents/memory_stores/mem_test/notes" + notes = [{"id": key, "path": key, "revision": 1, "created_at": 1, "updated_at": 1} for key in ("a", "b")] + first = {"object": "list", "data": notes, "first_id": "a", "last_id": "b", "has_more": True} + respx2_mock.get(path, params__eq={}).mock(side_effect=[httpx2.Response(200, json=first)]) + respx2_mock.get(path, params__eq={"after": "b"}).respond( + json={"object": "list", "data": [], "first_id": None, "last_id": None, "has_more": False} + ) + with OpenAI(base_url=BASE_URL, api_key="test-key", http_client=httpx2.Client(trust_env=False)) as client: + assert [item.id for item in client.beta.agents.memory_stores.notes.list("mem_test")] == ["a", "b"]