Skip to main content

A simple framework to interact with conversational LLMs

Project description

PyPI - Downloads GitHub GitHub issues Discord Twitter Follow

Lobsang

Welcome to Lobsang 🧘‍♂️

Lobsang is a framework to interact with conversational LLMs in the simplest way possible.
It's easy to get started, yet designed to scale up to complex use cases. Enjoy the ride! 🚀

Note: This project is still in early development. Expect breaking changes.

Installation

Requires Python 3.11 or higher.

pip install lobsang

Core Concepts

Lobsang is built around a few core concepts:

  • Chat is the main class of Lobsang. It represents a conversation between a user and a LLM. It is the main entry point to the framework and stores the chat history for a single conversation. After creating a Chat instance, you can interact with it by calling itself with one or more messages:
    from lobsang import Chat, UserMessage
    from lobsang.answers import TextAnswer
    from lobsang.llms import FakeLLM
    chat = Chat(llm=FakeLLM()) 
    #                 👆 FakeLLM returns dummy responses
    # Call the chat with one message and a corresponding answer (placeholder for the LLM's response)
    chat([UserMessage("Hello"), TextAnswer()])
    print("Chat history:")  
    print(chat)
    
    # Call the chat with multiple messages
    res = chat([
        UserMessage("What is 1+1?"),
        TextAnswer(),
        UserMessage("What is 2+2?"),
        TextAnswer()
    ])
    
    print("Conversation:")
    print(res)
    
    • Answers are used to guide the LLM to generate a specific response by modifying user messages. For example, you can use the JSONAnswerto instruct the LLM to generate a JSON response (see examples/2_directives.ipynb for more details).

Examples

We provide a few examples to get you started. You can find them in the examples folder. The examples use the openai package, make sure to install it before running the examples (pip install openai). You will also need an OpenAI API key, which you can get here: https://platform.openai.com/account/api-keys.

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

lobsang-0.1.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

lobsang-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file lobsang-0.1.0.tar.gz.

File metadata

  • Download URL: lobsang-0.1.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for lobsang-0.1.0.tar.gz
Algorithm Hash digest
SHA256 de71d177423c8536217260de0d93c51fc69b195887614a81e5a6f9d84b62e43b
MD5 602e211b3e14936de6419f69b827a7ab
BLAKE2b-256 6d0f008307c289e7668cab6b44ea1dbd5c03a68ffae3c243c88afce063eabc71

See more details on using hashes here.

File details

Details for the file lobsang-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lobsang-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for lobsang-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8e7f6adde5bb272ca0ab1a1221a37ab524a91437bdae6fea47b2c3acb6b0539d
MD5 7241e3f202e742b18e5a27fe12a1ec42
BLAKE2b-256 8f1b2c9f3f02d08929c6d4dedec32c37ce6f9e0ccd4976843fac5c7ecfcf08b6

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