Skip to main content

Delos CosmosHub

CosmosHub client for interacting with the CosmosHub API.

Installation

To install the package, use pip:

pip install delos-cosmoshub

Or if you are using poetry:

poetry add delos-cosmoshub

Client Initialization

You can create an API key to access all services through CosmosPlatform https://platform.cosmos-suite.ai/dashboard/keys.

To create a CosmosHub client instance, you need to initialize it with your API key, and optionally the server URL:

from delos_cosmoshub import CosmosHubClient

client = CosmosHubClient("your-api-key") # will be equivalent to:
client = CosmosHubClient("your-api-key", "https://platform.cosmos-suite.ai", debug_mode=False)

Endpoints

This delos-cosmoshub client provides access to the following endpoints:

Status Endpoints

  • status_health_request: Check the health of the server.

Translate Endpoints

  • translate_text_request: Translate text.
  • translate_file_request: Translate a file.

Web Endpoints

  • web_search_request: Perform a web search.

LLM Endpoints

  • chat: Chat with the LLM.
  • embed: Embed data into the LLM.

Files Endpoints

  • files_chunker_request: Chunk a file.
  • files_index_operation_request: Index group a set of files in order to be able to query them using natural language.
  • files_index_operation_request: Ask a question about the index documents (it requires that your index.status.vectorized is set to True).
  • files_index_operation_request: Embed data into an index.
  • files_index_operation_request: List all indexes.
  • files_index_operation_request: Get details of an index.

These endpoints are accessible through delos-cosmoshub client methods.

ℹ️ Info: For all the endpoints, there are specific models that structure the data to be sent to the API.

They may contain the text or files to operate with, the output_language for your result, the index_uuid that identifies the set of documents, the model to use for the LLM operations, etc.

You can find them in the delos_cosmoshub.models module.


Status Endpoints

Status Health Request

To check the health of the server and the validity of your API key:

response = client.status_health_request()
if response:
    print(f"Response: {response}")

Translate Endpoints

1. Translate Text Request

To translate text, you can use the translate_text_request method:

from delos_cosmoshub.models import TranslateTextData

translate_data = TranslateTextData(text="Hello, world!", target_language="fr")
response = client.translate_text_request(translate_data)
if response:
    print(f"Translated Text: {response}")

2. Translate File Request

To translate a file, use the translate_file_request method:

from delos_cosmoshub.models import TranslateFileData

translate_file_data = TranslateFileData(file=my_file, target_language="es")
response = client.translate_file_request(translate_file_data)
if response:
    print(f"Translated File Response: {response}")

Web Endpoints

Web Search Request

To perform a web search:

from delos_cosmoshub.models import SearchData

search_data = SearchData(query="CosmosHub")
response = client.web_search_request(search_data)
if response:
    print(f"Search Results: {response}")

LLM Endpoints

1. Chat Request

To chat with the LLM:

from delos_cosmoshub.models import ChatData

chat_data = ChatData(text="Hello, how are you?", model="gpt-4o-mini")
response = client.chat(chat_data)
if response:
    print(f"Chat Response: {response}")

2. Embed Request

To embed data using a LLM:

from delos_cosmoshub.models import EmbedData

embed_data = EmbedData(text="Hello, how are you?", model="ada-v2")
response = client.embed(embed_data)
if response:
    print(f"Embed Response: {response}")

Files Endpoints

Files Chunker Request

Universal reader and parser. To chunk a file:

from delos_cosmoshub.models import ChunkerData

chunker_data = ChunkerData(file=my_file)
response = client.files_chunker_request(chunker_data)
if response:
    print(f"Chunked File Response: {response}")

Files Index Operation Request

Index group a set of files in order to be able to query them using natural language. The following operations are available:

  • INDEX_CREATE: Create a new index and parse files.
  • INDEX_ADD_FILES: Add files to an existing index.
  • INDEX_DELETE_FILES: Delete files from an index.
  • INDEX_DELETE: Delete an index. Warning: This is a delayed (2h) operation, allowed to be reverted with INDEX_RESTORE. After 2h, the index will be deleted and not recoverable.
  • INDEX_RESTORE: Restore a deleted index (within the 2h after it was marked for deletion).
  • INDEX_EMBED: Embed data into an index.
  • INDEX_ASK: Ask a question to the index. It requires that INDEX_EMBED is performed to allow index contents querying.
  • INDEX_LIST: List all indexes.
  • INDEX_DETAILS: Get details of an index.

Examples

To create a new index and parse files:

from delos_cosmoshub.data import IndexOperationData, FileEndpoints

index_operation_data = IndexOperationData(files=[my_file], index_uuid="new-index-uuid")
response = client.files_index_operation_request(index_operation_data, FileEndpoints.INDEX_CREATE)
if response:
    print(f"Index Create Response: {response}")

To add files to an existing index:

index_operation_data = IndexOperationData(files=[my_file], index_uuid="existing-index-uuid")
response = client.files_index_operation_request(index_operation_data, FileEndpoints.INDEX_ADD_FILES)
if response:
    print(f"Add Files to Index Response: {response}")

To delete files from an existing index:

index_operation_data = IndexOperationData(files=[my_file], index_uuid="existing-index-uuid")
response = client.files_index_operation_request(index_operation_data, FileEndpoints.INDEX_DELETE_FILES)
if response:
    print(f"Delete Files from Index Response: {response}")

To delete an index (it will be marked for deletion which will become effective after 2h):

index_operation_data = IndexOperationData(index_uuid="index-to-delete-uuid")
response = client.files_index_operation_request(index_operation_data, FileEndpoints.INDEX_DELETE)
if response:
    print(f"Delete Index Response: {response}")

To restore an index marked for deletion (only possible during the 2h after the INDEX_DELETE was requested):

index_operation_data = IndexOperationData(index_uuid="index-to-restore-uuid")
response = client.files_index_operation_request(index_operation_data, FileEndpoints.INDEX_RESTORE)
if response:
    print(f"Restore Index Response: {response}")

To embed or vectorize index contents in order to allow the query operations:

index_operation_data = IndexOperationData(index_uuid="index-uuid", data_to_embed=my_data)
response = client.files_index_operation_request(index_operation_data, FileEndpoints.INDEX_EMBED)
if response:
    print(f"Embed Data Response: {response}")

To ask a question about the index documents (it requires that your index.status.vectorized is set to True):

index_operation_data = IndexOperationData(index_uuid="index-uuid", question="What is CosmosHub?")
response = client.files_index_operation_request(index_operation_data, FileEndpoints.INDEX_ASK)
if response:
    print(f"Ask Index Response: {response}")

To list all indexes in your organization, files included and storage details:

response = client.files_index_operation_request(None, FileEndpoints.INDEX_LIST)
if response:
    print(f"List Indexes Response: {response}")

To get details of an index:

index_operation_data = IndexOperationData(index_uuid="index-uuid")
response = client.files_index_operation_request(index_operation_data, FileEndpoints.INDEX_DETAILS)
if response:
    print(f"Index Details Response: {response}")

Development

To contribute to the project, clone the repository and install the dependencies:

git clone https://github.com/yourusername/delos-cosmoshub.git
cd delos-cosmoshub
poetry install

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

For any inquiries, please contact the project maintainers at support@cosmos-suite.ai.

Metadata

Release files for delos-cosmoshub 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for delos-cosmoshub 0.1.1
File Size Uploaded Provenance Actions
delos_cosmoshub-0.1.1.tar.gz 8.8 kB Without provenance Details for delos_cosmoshub-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for delos-cosmoshub 0.1.1
File Interpreter ABI Platform Actions
delos_cosmoshub-0.1.1-py3-none-any.whl Python 3 none any Details for delos_cosmoshub-0.1.1-py3-none-any.whl

Total release size: 17.7 kB

Release files / delos_cosmoshub-0.1.1.tar.gz

Download URL delos_cosmoshub-0.1.1.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
99fec8c4b541c4f07bd5d0fc0712e6842b6b494e1fccf702c3bd262b99dbb2ce
BLAKE2b-256 checksum
How to use checksums
d59604250162a92a5a60b39fd973f60eaa7d435a7d0fd7fb1c5b29fd4ef311b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.7

Release files / delos_cosmoshub-0.1.1-py3-none-any.whl

Download URL delos_cosmoshub-0.1.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
249d333db816c9f2a66994c1edc8049c3ec86eb0cee3f4da730b6b71682cc9bb
BLAKE2b-256 checksum
How to use checksums
8d6bbf8a9715b63c38486df51eed1ac437455cad1b14561b6b4db7d06decbabe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.7

Security for delos-cosmoshub 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page