Class: Anthropic::Resources::Files
- Inherits:
-
Object
- Object
- Anthropic::Resources::Files
- Defined in:
- lib/anthropic/resources/files.rb,
sig/anthropic/resources/files.rbs
Instance Method Summary collapse
-
#delete(file_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::DeletedFile
Delete File.
-
#download(file_id, workspace_id: nil, request_options: {}) ⇒ StringIO
Download File.
-
#initialize(client:) ⇒ Files
constructor
private
A new instance of Files.
-
#list(ids: nil, limit: nil, page: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::FileMetadata>
List Files.
-
#retrieve_metadata(file_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Get File Metadata.
-
#upload(file:, expires_in_seconds: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Upload File.
Constructor Details
#initialize(client:) ⇒ Files
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 Files.
207 208 209 |
# File 'lib/anthropic/resources/files.rb', line 207 def initialize(client:) @client = client end |
Instance Method Details
#delete(file_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::DeletedFile
Delete File
Some parameter documentations has been truncated, see Models::FileDeleteParams for more details.
70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/anthropic/resources/files.rb', line 70 def delete(file_id, params = {}) parsed, = Anthropic::FileDeleteParams.dump_request(params) @client.request( span_name: Anthropic::Internal::Tracing::SpanName::FILES_DELETE, span_attributes: {"anthropic.file.id" => file_id}, span_route: "/v1/files/{file_id}", method: :delete, path: ["v1/files/%1$s", file_id], headers: parsed.transform_keys(workspace_id: "anthropic-workspace-id"), model: Anthropic::DeletedFile, options: ) end |
#download(file_id, workspace_id: nil, request_options: {}) ⇒ StringIO
Download File
Some parameter documentations has been truncated, see Models::FileDownloadParams for more details.
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/anthropic/resources/files.rb', line 107 def download(file_id, params = {}) parsed, = Anthropic::FileDownloadParams.dump_request(params) @client.request( span_name: Anthropic::Internal::Tracing::SpanName::FILES_DOWNLOAD, span_attributes: {"anthropic.file.id" => file_id}, span_route: "/v1/files/{file_id}/content", method: :get, path: ["v1/files/%1$s/content", file_id], headers: { "accept" => "application/binary", **parsed }.transform_keys(workspace_id: "anthropic-workspace-id"), model: StringIO, options: ) end |
#list(ids: nil, limit: nil, page: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Internal::PageCursor<Anthropic::Models::FileMetadata>
List Files
Some parameter documentations has been truncated, see Models::FileListParams for more details.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/anthropic/resources/files.rb', line 31 def list(params = {}) query_params = [:ids, :limit, :page] parsed, = Anthropic::FileListParams.dump_request(params) query = Anthropic::Internal::Util.encode_query_params(parsed.slice(*query_params)) @client.request( span_name: Anthropic::Internal::Tracing::SpanName::FILES_LIST, span_route: "/v1/files", span_query: %w[ids limit page], method: :get, path: "v1/files", query: query, headers: parsed.except(*query_params).transform_keys(workspace_id: "anthropic-workspace-id"), page: Anthropic::Internal::PageCursor, model: Anthropic::FileMetadata, options: ) end |
#retrieve_metadata(file_id, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Get File Metadata
Some parameter documentations has been truncated, see Models::FileRetrieveMetadataParams for more details.
145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/anthropic/resources/files.rb', line 145 def (file_id, params = {}) parsed, = Anthropic::FileRetrieveMetadataParams.dump_request(params) @client.request( span_name: Anthropic::Internal::Tracing::SpanName::FILES_RETRIEVE_METADATA, span_attributes: {"anthropic.file.id" => file_id}, span_route: "/v1/files/{file_id}", method: :get, path: ["v1/files/%1$s", file_id], headers: parsed.transform_keys(workspace_id: "anthropic-workspace-id"), model: Anthropic::FileMetadata, options: ) end |
#upload(file:, expires_in_seconds: nil, workspace_id: nil, request_options: {}) ⇒ Anthropic::Models::FileMetadata
Upload File
Some parameter documentations has been truncated, see Models::FileUploadParams for more details.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/anthropic/resources/files.rb', line 183 def upload(params) parsed, = Anthropic::FileUploadParams.dump_request(params) header_params = {workspace_id: "anthropic-workspace-id"} @client.request( span_name: Anthropic::Internal::Tracing::SpanName::FILES_UPLOAD, span_created_id: "anthropic.file.id", span_route: "/v1/files", method: :post, path: "v1/files", headers: { "content-type" => "multipart/form-data", **parsed.slice(*header_params.keys) }.transform_keys( header_params ), body: parsed.except(*header_params.keys), model: Anthropic::FileMetadata, options: ) end |