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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file versacorellmchatapi-0.1.8.tar.gz
.
File metadata
- Download URL: versacorellmchatapi-0.1.8.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f2a13de102a9d3b4257ab333127361947c6a0c66ce7bf750eecdfe70d3fcb12 |
|
MD5 | af15d67673c04bfe226ab40e98a18e06 |
|
BLAKE2b-256 | b3c71815e36636187ee6c3008b660df595f477799e44b62cff97da8ec8d04de2 |
File details
Details for the file versacorellmchatapi-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: versacorellmchatapi-0.1.8-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcb30a9470daf781af5c1e828aec5bbe7b14a8d2ec241918f7690f5d1da3b084 |
|
MD5 | c88049f8fae1c78a91d702995fa6f79c |
|
BLAKE2b-256 | a0c3f883f003b71d392601d7ea42da36753014ae531d11a0aadc329d247446cd |