Skip to main content

llama-index llms konko integration

Project description

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/

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

llama_index_llms_konko-0.5.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_llms_konko-0.5.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_konko-0.5.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_konko-0.5.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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}

File hashes

Hashes for llama_index_llms_konko-0.5.0.tar.gz
Algorithm Hash digest
SHA256 408e19ea2194d89e9330379846ff1a7d54294e6d3e4e92a7a720474e55e71c13
MD5 51e9975dc8d6435113c40b3084862251
BLAKE2b-256 d0896c63537ce2f2a200292e8e504174c48923e06bac6b66d27dca665533d169

See more details on using hashes here.

File details

Details for the file llama_index_llms_konko-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_llms_konko-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","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}

File hashes

Hashes for llama_index_llms_konko-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 597c21b94ec0f98c8d66b74e115bf64728a6b3bfa62b71e9653c3c1e086d275b
MD5 7045237c115b4afcaee5d8bacb56c20a
BLAKE2b-256 c2cb3dec50566cd850243976a338eb563e498946be257167ca2e2cdae47f7d0d

See more details on using hashes here.

Supported by

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