Skip to main content

Intelligence/AI services for the Lifsys Enterprise with enhanced max_history_words and efficient history trimming

Project description

Intelisys

Intelisys is a powerful and flexible Python library that provides a unified interface for interacting with various AI providers and models. It simplifies the process of chatting with AI models, handling image inputs, and managing conversation history across different platforms.

Table of Contents

Installation

To install Intelisys, you can use pip:

pip install intelisys

Usage

Basic Usage

Here's a simple example of how to use Intelisys:

from intelisys import Intelisys

# Initialize Intelisys
ai = Intelisys(provider="openai", model="gpt-3.5-turbo")

# Set a system message
ai.set_system_message("You are a helpful assistant.")

# Chat with the AI
response = ai.chat("Hello, how are you?")

# Get the AI's response
print(ai.get_response())

Advanced Usage

Intelisys supports method chaining for a more fluent interface:

from intelisys import Intelisys

ai = (Intelisys(provider="anthropic", model="claude-2")
      .set_system_message("You are a creative writing assistant.")
      .set_default_template("User: {}\nAI: ")
      .set_default_persona("You are a witty and sarcastic AI."))

response = ai.chat("Write a short story about a time-traveling toaster.")
print(ai.get_response())

Asynchronous Usage

Intelisys also supports asynchronous operations:

import asyncio
from intelisys import Intelisys

async def main():
    ai = Intelisys(provider="openai", model="gpt-4")
    await ai.set_system_message_async("You are a helpful assistant.")
    await ai.chat_async("What's the capital of France?")
    response = await ai.get_response_async()
    print(response)

asyncio.run(main())

API Reference

Class: Intelisys

__init__(self, provider: str, model: str = None, **kwargs)

Initializes an Intelisys instance.

set_log_level(self, level: Union[int, str])

Sets the log level for the Intelisys instance.

set_system_message(self, message=None)

Sets the system message for the conversation.

chat(self, user_input)

Sends a user message to the AI and gets a response.

get_response(self)

Retrieves the latest response from the AI.

trim_history(self)

Trims the conversation history to stay within token limits.

add_message(self, role, content)

Adds a message to the conversation history.

set_default_template(self, template: str) -> 'Intelisys'

Sets a default template for formatting messages.

set_default_persona(self, persona: str) -> 'Intelisys'

Sets a default persona for the AI.

remove_preface(text: str) -> str

Removes preface from the given text.

safe_json_loads(json_str: str, error_prefix: str = "") -> Dict

Safely loads a JSON string into a dictionary.

chat_async(self, user_input, **kwargs)

Asynchronous version of chat method.

add_message_async(self, role, content)

Asynchronous version of add_message method.

set_system_message_async(self, message=None)

Asynchronous version of set_system_message method.

get_response_async(self, color=None, should_print=True, **kwargs)

Asynchronous version of get_response method.

trim_history_async(self)

Asynchronous version of trim_history method.

For detailed information on parameters and return values, please refer to the method docstrings in the source code.

Contributing

We welcome contributions to Intelisys! If you'd like to contribute, please follow these steps:

  1. Fork the repository
  2. Create a new branch for your feature or bug fix
  3. Make your changes and write tests if applicable
  4. Run the existing tests to ensure nothing was broken
  5. Commit your changes and push to your fork
  6. Create a pull request with a clear description of your changes

Please ensure your code adheres to the existing style and passes all tests before submitting a pull request.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

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

intelisys-0.5.4.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

intelisys-0.5.4-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file intelisys-0.5.4.tar.gz.

File metadata

  • Download URL: intelisys-0.5.4.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for intelisys-0.5.4.tar.gz
Algorithm Hash digest
SHA256 7bbd7a8eb145cfbf61f6f58ab4370016bf0c1fbb3d86039aa5c16ba196ac608d
MD5 2cdf206e67e9add1bc3d14c6deff44f5
BLAKE2b-256 74924647be2e37f4cd4985e4b8431ee73152724e3bc194deafc9be879c6164be

See more details on using hashes here.

File details

Details for the file intelisys-0.5.4-py3-none-any.whl.

File metadata

  • Download URL: intelisys-0.5.4-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for intelisys-0.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 dc86db82a4099a7ea0b9d268ddb8000b669cefe41f0e5d34f29b9083accd1326
MD5 0451f4aee7f8ee8990df45f857ef7106
BLAKE2b-256 d9219a20b8aeafb6e05683bf20f20a047914cbd31c060051c6071814bd1c811a

See more details on using hashes here.

Supported by

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