Skip to main content

client for AICosmos platform

Project description

Client for AICosmos

This package implements the client for AICosmos. Before using this package, please make sure that you have a valid account for AICosmos.

By using this client, you can chat with our backend in "base" mode. To login, you will need the server's address, your username and your password. You can either start a new session, or use an existing one.

Our framework is different from "chat completions", where you give an llm the conversation history. Instead, your conversation history, along with other tool execution results, are stored in our database. This gives your a clean and simple interface to use, without worrying about constructing complicated contexts. The following code signs in to your account, and starts a new conversation in "base" mode.

from aicosmos_client.client import AICosmosClient 

# login
client = AICosmosClient(
    base_url="https://aicosmos.ai/api", api_key="xxx"
)

# create a new session
try:
    new_session_id = client.create_session()
except Exception as e:
    print(f"Error creating new session: {e}")
    exit(0)

# lookup all the sessions
try:
    my_sessions = client.get_my_sessions()
except Exception as e:
    print(f"Error getting my sessions: {e}")
    exit(0)
# [{"session_id", "title"}, ...]
print(my_sessions)

# enjoy the conversation
try:
    conversation_history = client.chat(new_session_id, "Hello")
except Exception as e:
    print(f"Error chatting: {e}")
    exit(0)
print(conversation_history)

Apart from "base" mode, we also support "code" mode and "lean" mode. In these modes, we provide you with a code editor, which you can open and interact with your web browser.

# enjoy the conversation
try:
    conversation_history = client.chat(
        new_session_id, "De Morgan's law. Start now.", mode="lean"
    )
except Exception as e:
    print(f"Error chatting: {e}")
    exit(0)
print(conversation_history)

# open this link with your web browser (e.g. Edge, Chrome)
url = client.get_browser_url(new_session_id)
print(url)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aicosmos_client-0.0.14.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aicosmos_client-0.0.14-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file aicosmos_client-0.0.14.tar.gz.

File metadata

  • Download URL: aicosmos_client-0.0.14.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.0

File hashes

Hashes for aicosmos_client-0.0.14.tar.gz
Algorithm Hash digest
SHA256 7f131cacac4dacf0c7b9005a1dbf3e2f74744483f0d4d491cf77db1c90081412
MD5 6c8b259a14999bc86b8e5241aa813225
BLAKE2b-256 0c80f9d1095907f65af5fb85a36ae636dd194f51c7ccca541b0212b0196038d8

See more details on using hashes here.

File details

Details for the file aicosmos_client-0.0.14-py3-none-any.whl.

File metadata

File hashes

Hashes for aicosmos_client-0.0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 38e9453a88d43b05eab6e98d34ef5a7181210a7e7c5194ae8ac36f11cdf368f0
MD5 e19a3c42da724186b72290b14dceafb8
BLAKE2b-256 389a19c167eb5e7addec186b1c4f676c9975741304ee556f1c01d8dcd591d90c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page