Class: OpenAI::Resources::Beta::Agents::Sessions::Artifacts

Inherits:
Object
  • Object
show all
Defined in:
lib/openai/resources/beta/agents/sessions/artifacts.rb,
sig/openai/resources/beta/agents/sessions/artifacts.rbs

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Artifacts

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Artifacts.

Parameters:



147
148
149
# File 'lib/openai/resources/beta/agents/sessions/artifacts.rb', line 147

def initialize(client:)
  @client = client
end

Instance Method Details

#content(artifact_id, session_id:, request_options: {}) ⇒ StringIO

Downloads immutable session artifact bytes after the execution environment expires. See session artifacts.

Parameters:

  • artifact_id (String)

    The immutable session artifact ID.

  • session_id (String)

    The ID of the session that owns the artifact.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (StringIO)

See Also:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/openai/resources/beta/agents/sessions/artifacts.rb', line 128

def content(artifact_id, params)
  parsed, options = OpenAI::Beta::Agents::Sessions::ArtifactContentParams.dump_request(params)
  session_id = parsed.delete(:session_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :get,
    path: ["agents/sessions/%1$s/artifacts/%2$s/content", session_id, artifact_id],
    headers: {"accept" => "application/octet-stream"},
    model: StringIO,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "agents=v1"}, **options}
  )
end

#delete(artifact_id, session_id:, request_options: {}) ⇒ OpenAI::Models::Beta::Agents::Sessions::SessionArtifactDeleted

Deletes an immutable session artifact without deleting its live environment file or original Files API object. See session artifacts.

Parameters:

  • artifact_id (String)

    The immutable session artifact ID.

  • session_id (String)

    The ID of the session that owns the artifact.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/openai/resources/beta/agents/sessions/artifacts.rb', line 96

def delete(artifact_id, params)
  parsed, options = OpenAI::Beta::Agents::Sessions::ArtifactDeleteParams.dump_request(params)
  session_id = parsed.delete(:session_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :delete,
    path: ["agents/sessions/%1$s/artifacts/%2$s", session_id, artifact_id],
    model: OpenAI::Beta::Agents::Sessions::SessionArtifactDeleted,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "agents=v1"}, **options}
  )
end

#list(session_id, after: nil, environment_id: nil, limit: nil, order: nil, request_options: {}) ⇒ OpenAI::Internal::CursorPage<OpenAI::Models::Beta::Agents::Sessions::SessionArtifact>

Lists immutable artifacts published by completed hosted session turns. See session artifacts.

Parameters:

  • session_id (String)

    The ID of the session.

  • after (String, nil)

    Return artifacts after this immutable artifact ID.

  • environment_id (String, nil)

    Restrict the listing to artifacts produced by this environment.

  • limit (Integer, nil)

    The maximum number of artifacts to return, between 1 and 100.

  • order (Symbol, OpenAI::Models::Beta::Agents::Sessions::ArtifactListParams::Order)

    Sort by creation time and ID. Defaults to descending.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/openai/resources/beta/agents/sessions/artifacts.rb', line 65

def list(session_id, params = {})
  parsed, options = OpenAI::Beta::Agents::Sessions::ArtifactListParams.dump_request(params)
  query = OpenAI::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["agents/sessions/%1$s/artifacts", session_id],
    query: query,
    page: OpenAI::Internal::CursorPage,
    model: OpenAI::Beta::Agents::Sessions::SessionArtifact,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "agents=v1"}, **options}
  )
end

#retrieve(artifact_id, session_id:, request_options: {}) ⇒ OpenAI::Models::Beta::Agents::Sessions::SessionArtifact

Retrieves immutable metadata for one durable session artifact. See session artifacts.

Parameters:

  • artifact_id (String)

    The immutable session artifact ID.

  • session_id (String)

    The ID of the session that owns the artifact.

  • request_options (OpenAI::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/openai/resources/beta/agents/sessions/artifacts.rb', line 25

def retrieve(artifact_id, params)
  parsed, options = OpenAI::Beta::Agents::Sessions::ArtifactRetrieveParams.dump_request(params)
  session_id = parsed.delete(:session_id) do
    raise ArgumentError.new("missing required path argument #{_1}")
  end

  @client.request(
    method: :get,
    path: ["agents/sessions/%1$s/artifacts/%2$s", session_id, artifact_id],
    model: OpenAI::Beta::Agents::Sessions::SessionArtifact,
    security: {bearer_auth: true},
    options: {extra_headers: {"OpenAI-Beta" => "agents=v1"}, **options}
  )
end