Skip to main content

A Python library for interacting with the VersaCore LLM Chat API.

Project description

VersaCoreLLMChatAPI

A Python library for interacting with VersaCore LLM Chat API.

Installation

pip install versacorellmchatapi

Usage

if __name__ == "__main__":

    def handle_chunk(chunk, end=False):
        # Custom handling of each chunk
        if chunk:
            print(chunk, end='', flush=True)
        if end:
            print()  # Print a newline at the end of the stream


    lm_studio_llm_api = VersaCoreLLMChatAPI("lmstudio")
    ollama_llm_api = VersaCoreLLMChatAPI("ollama")
    
    messages = [
        { "role": "system", "content": "You are a useful chatbot." },
        { "role": "user", "content": "write a short story of 2000 words about a funny corgi." }
    ]
    
    lm_studio_response = lm_studio_llm_api.chat_completions(
        messages, 
        model="lmstudio-community/Mistral-7B-Instruct-v0.3-GGUF/Mistral-7B-Instruct-v0.3-Q5_K_M.gguf", 
        temperature=0.7, 
        max_tokens=-1, 
        stream=True,
        callback=handle_chunk
    )
    

    ollama_response = ollama_llm_api.chat_completions(
        messages,
        model="mistral", 
        stream=True,
        callback=handle_chunk  # Use the custom callback to handle streaming chunks
    )

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

versacorellmchatapi-0.1.9.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

versacorellmchatapi-0.1.9-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file versacorellmchatapi-0.1.9.tar.gz.

File metadata

  • Download URL: versacorellmchatapi-0.1.9.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for versacorellmchatapi-0.1.9.tar.gz
Algorithm Hash digest
SHA256 66407caf2c7f31040ef61ff147596b87c575c4f28bd5d4b56b0ab3ee5c49ceb9
MD5 16f1859ee0a8a681f162b931c39777ea
BLAKE2b-256 08c43055756465ec9a6a31287bd5d3bc3ca02cd6daefa459840fbcbe17482ab2

See more details on using hashes here.

File details

Details for the file versacorellmchatapi-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for versacorellmchatapi-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 7d0a78f6f0d3b583b26a2d7a3e936d82af866b5bf6b867526780ebcf49ab7e86
MD5 f53897f36af0d574bb13acca627a61e0
BLAKE2b-256 d6ed6faff111bf9af0b36bf1e8863c74c6916f13667ca889c48f804f286e006b

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