Skip to main content

Python interface to the Codicent API

Project description

Codicent Python Library

This library provides a Python interface to the Codicent API.

Installation


To install using pip, run:

pip install codicent-py

For development installation from source:

pip install git+https://github.com/izaxon/codicent-py.git

To use this library, simply import it into your Python script:

from codicentpy import Codicent

Usage


Initialization

Create a Codicent object with your API token and optional SignalR host:

codicent = Codicent("YOUR_API_TOKEN")

Uploading a file

Upload a file to Codicent:

file_id = codicent.upload(open("example.txt", "rb"))
print(file_id)

Posting a message

Post a message to Codicent:

message_id = codicent.post_message("Hello, world!", type="info")
print(message_id)

Getting messages

Get a list of messages from Codicent:

messages = codicent.get_messages(start=0, length=10)
print(messages)

Get AI chat reply

Sends a message to the Codicent chat (AI) and waits for the reply:

reply = codicent.get_chat_reply("What can you help me with?")
print(reply)

Methods

__init__

Initialize the Codicent object with a Codicent API token.

upload

Upload a file to Codicent.

  • file: The file to upload.

Returns the ID of the uploaded file.

post_message

Post a message to Codicent.

  • message: The message to post.
  • parent_id: The ID of the parent message (optional).
  • type: The type of message (default: "info").

Returns the ID of the posted message.

get_messages

Get a list of messages from Codicent.

  • start: The starting index (default: 0).
  • length: The number of messages to retrieve (default: 10).
  • search: A search query (optional).
  • after_timestamp: A timestamp to retrieve messages after (optional).
  • before_timestamp: A timestamp to retrieve messages before (optional).

Returns a list of message objects.

get_chat_reply

Sends a message to the Codicent chat (AI) and waits for the reply.

  • message: The message to send.

post_chat_reply

Posts a message to the Codicent AI chat and returns the reply.

  • message: The message to send.

Returns a dictionary with:

  • id: The message ID.
  • content: The reply message content.

Running Tests

To run tests, first install the required dependencies:

pip install -r requirements.txt

Then execute:

pytest

Building

To build the package, run:

python setup.py sdist bdist_wheel

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

codicent_py-1.3.5.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

codicent_py-1.3.5-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file codicent_py-1.3.5.tar.gz.

File metadata

  • Download URL: codicent_py-1.3.5.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for codicent_py-1.3.5.tar.gz
Algorithm Hash digest
SHA256 ebba98dffac8ce19830e78c2cb45e389e02f6e9fae1fc4c900359ba8be7df52c
MD5 7a8cfaa6a4ae1dce8c513f723071f496
BLAKE2b-256 4496f211e7ec31cb686f9709c6173067b5432b5df87ad7846492ac2955bea1a2

See more details on using hashes here.

File details

Details for the file codicent_py-1.3.5-py3-none-any.whl.

File metadata

  • Download URL: codicent_py-1.3.5-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.8

File hashes

Hashes for codicent_py-1.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f35f16873fe8829a40bea2c3930dc79abb16aa9e34c82033831ee8eb0e5823b2
MD5 c87971964cfb3dd29500c48c634b5949
BLAKE2b-256 2f7d9cff41f9b1c95329c460caac1a7ab8381995cc1ce8bb0edb72194c04e9a8

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