Class: Tavus::Resources::Documents

Inherits:
Object
  • Object
show all
Defined in:
lib/tavus/resources/documents.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Documents

Returns a new instance of Documents.



6
7
8
# File 'lib/tavus/resources/documents.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#create(document_url:, **options) ⇒ Hash

Create a new document in the knowledge base

Parameters:

  • document_url (String)

    The URL of the document to be processed (required)

  • options (Hash)

    Additional optional parameters

Options Hash (**options):

  • :document_name (String)

    Optional name for the document

  • :callback_url (String)

    Optional URL for status updates

  • :properties (Hash)

    Optional key-value pairs for additional properties

  • :tags (Array<String>)

    Optional array of tags to categorize the document

Returns:

  • (Hash)

    The created document details



18
19
20
21
# File 'lib/tavus/resources/documents.rb', line 18

def create(document_url:, **options)
  body = options.merge(document_url: document_url)
  @client.post("/v2/documents", body: body)
end

#delete(document_id) ⇒ Hash

Delete a document

Parameters:

  • document_id (String)

    The unique identifier of the document

Returns:

  • (Hash)

    Success response



56
57
58
# File 'lib/tavus/resources/documents.rb', line 56

def delete(document_id)
  @client.delete("/v2/documents/#{document_id}")
end

#get(document_id) ⇒ Hash

Get a single document by ID

Parameters:

  • document_id (String)

    The unique identifier of the document

Returns:

  • (Hash)

    The document details



26
27
28
# File 'lib/tavus/resources/documents.rb', line 26

def get(document_id)
  @client.get("/v2/documents/#{document_id}")
end

#list(**options) ⇒ Hash

List all documents

Parameters:

  • options (Hash)

    Query parameters

Options Hash (**options):

  • :limit (Integer)

    Number of documents to return per page (default: 10)

  • :page (Integer)

    Page number for pagination (0-based, default: 0)

  • :sort (String)

    Sort direction (ascending, descending)

  • :status (String)

    Filter documents by status

  • :name_or_uuid (String)

    Search by name or UUID

  • :tags (String)

    Comma-separated list of tags to filter by

Returns:

  • (Hash)

    List of documents with pagination info



39
40
41
# File 'lib/tavus/resources/documents.rb', line 39

def list(**options)
  @client.get("/v2/documents", params: options)
end

#update(document_id, **options) ⇒ Hash

Update a document’s metadata

Parameters:

  • document_id (String)

    The unique identifier of the document

  • options (Hash)

    Update parameters

Options Hash (**options):

  • :document_name (String)

    New name for the document

  • :tags (Array<String>)

    New array of tags (overwrites existing)

Returns:

  • (Hash)

    The updated document details



49
50
51
# File 'lib/tavus/resources/documents.rb', line 49

def update(document_id, **options)
  @client.patch("/v2/documents/#{document_id}", body: options)
end