Skip to main content
  • Python
  • Javascript
  • cURL

Step 1: /_index_upload

from gradio_client import Client, handle_file

client = Client("Remeinium/Embedding_Siyabasa")
result = client.predict(
    file=handle_file('path/to/documents.txt'),
    api_name="/_index_upload"
)
print(json.dumps(result, indent=4))

Accepts 1 parameter:

  1. file : filepath *Required The input value that is provided in the “Upload .txt or .csv File” File component. The FileData class is a subclass of the GradioModel class that represents a file object within a Gradio interface. It is used to store file data and metadata when a file is uploaded. Attributes: path: The server file path where the file is stored. url: The normalized server URL pointing to the file. size: The size of the file in bytes. orig_name: The original filename before upload. mime_type: The MIME type of the file. is_stream: Indicates whether the file is a stream. meta: Additional metadata used internally (should not be changed).

Returns tuple of 2 elements:

  1. dict(headers: list[Any], data: list[list[Any]], metadata: dict(str, list[Any] | None) | None)
    The output value that appears in the value_45 Dataframe component.
  2. str
    The output value that appears in the “Status” Textbox component.

Step 2: /_search_wrapper

from gradio_client import Client

client = Client("Remeinium/Embedding_Siyabasa")
result = client.predict(
    query="සිංහල භාෂාව",
    topn_=5,
    api_name="/_search_wrapper"
)

Accepts 2 parameters:

  1. query : string *Required
    The input value that is provided in the Search Query Textbox component.
  2. topn_ : float Default 5
    The input value that is provided in the “Number of Results” Slider component.

Returns 1 element

str | float | bool | list | dict
The output value that appears in the Search Results Json component.