Skip to main content

LlamaIndex Llms Integration: Konko

Installation

  1. Install the required Python packages:

    %pip install llama-index-llms-konko
    !pip install llama-index
    
  2. Set the API keys as environment variables:

    export KONKO_API_KEY=<your-api-key>
    export OPENAI_API_KEY=<your-api-key>
    

Usage

Import Required Libraries

import os
from llama_index.llms.konko import Konko
from llama_index.core.llms import ChatMessage

Chat with Konko Model

To chat with a Konko model:

os.environ["KONKO_API_KEY"] = "<your-api-key>"
llm = Konko(model="meta-llama/llama-2-13b-chat")
messages = ChatMessage(role="user", content="Explain Big Bang Theory briefly")

resp = llm.chat([messages])
print(resp)

Chat with OpenAI Model

To chat with an OpenAI model:

os.environ["OPENAI_API_KEY"] = "<your-api-key>"
llm = Konko(model="gpt-3.5-turbo")
message = ChatMessage(role="user", content="Explain Big Bang Theory briefly")

resp = llm.chat([message])
print(resp)

Streaming Responses

To stream a response for longer messages:

message = ChatMessage(role="user", content="Tell me a story in 250 words")
resp = llm.stream_chat([message], max_tokens=1000)

for r in resp:
    print(r.delta, end="")

Complete with Prompt

To generate a completion based on a system prompt:

llm = Konko(model="phind/phind-codellama-34b-v2", max_tokens=100)
text = """### System Prompt
You are an intelligent programming assistant.

### User Message
Implement a linked list in C++

### Assistant
..."""

resp = llm.stream_complete(text, max_tokens=1000)
for r in resp:
    print(r.delta, end="")

LLM Implementation example

https://docs.llamaindex.ai/en/stable/examples/llm/konko/

Metadata

Release files for llama-index-llms-konko 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-llms-konko 0.6.0
File Size Uploaded Provenance Actions
llama_index_llms_konko-0.6.0.tar.gz 9.1 kB Without provenance Details for llama_index_llms_konko-0.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-llms-konko 0.6.0
File Interpreter ABI Platform Actions
llama_index_llms_konko-0.6.0-py3-none-any.whl Python 3 none any Details for llama_index_llms_konko-0.6.0-py3-none-any.whl

Total release size: 18.3 kB

Release files / llama_index_llms_konko-0.6.0.tar.gz

Download URL llama_index_llms_konko-0.6.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3ea18569f27ba955c7ff40c3173ff7feeabcc3f0d1d1e0a8a2b975e549f706ef
BLAKE2b-256 checksum
How to use checksums
19118da15a004ebc475d21e1dfa7c9221a92ef2ba89d2d2da0b82499f8ccee61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / llama_index_llms_konko-0.6.0-py3-none-any.whl

Download URL llama_index_llms_konko-0.6.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df2d354832680dd7adb7933b25370fd633c69e6a84eed2c0ab9e12bcaa991551
BLAKE2b-256 checksum
How to use checksums
4a89cbf3e0c5ac3ec5cabfd00a62ee53d2533e79df2fe672bd508e875cd682a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for llama-index-llms-konko 0.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page