Quick Start

Interacting with Konko Models using LangChain

Guide for using the LangChain library to communicate with both chat and completion models hosted by Konko. By the end of this tutorial, you will understand how to select and interact with different types of models provided by Konko, including how to send queries and receive responses.

Objective: This guide aims to demonstrate how developers can leverage LangChain and Konko's versatile models, including chat and completion models.



Important: Before starting, ensure you have your Konko API key. If you don't, obtain one from Konko's website. For installation guidance, refer to the Installation and Setup Guide.

Step 1: Importing Modules and Classes

For chat models:

from langchain.chat_models import ChatKonko
from langchain.schema import HumanMessage, SystemMessage

For completion models:

from langchain.llms import Konko

Step 2: Selecting and Using Models

For Chat Models

  1. Find a Suitable Chat Model: Visit the Konko Model List to select a chat model.

  2. Initialize the Chat Model:

    chat = ChatKonko(max_tokens=400, model="meta-llama/llama-2-13b-chat")
  3. Example Usage:

    messages = [
        SystemMessage(content="You are a helpful assistant."),
        HumanMessage(content="Explain Big Bang Theory briefly"),
    response = chat(messages)

For Completion Models

  1. Choose a Completion Model: Review the model list at Konko's Available Models to find a suitable completion model. Check the is_chat attribute to confirm it's a completion model.

  2. Initialize the Completion Model:

    llm = Konko(model="mistralai/mistral-7b-v0.1", temperature=0.1, max_tokens=128)
  3. Example Usage:

    input_ = """You are a helpful assistant. Explain Big Bang Theory briefly."""
    response = llm(input_)

Further Exploration

This guide was a basic introduction on how to use Konko hosted models with LangChain. However, for a deeper understanding and to explore full-fledged real-business use-case examples, vist:

Usecase Examples with LangChain and Konko:

  1. Chatbot Agents with LangChain: Understand how to create conversational agents with LangChain and Konko.
  2. 5 Levels Of Summarization: A comprehensive guide on mastering text summarization using LangChain and Konko.
  3. Generative QA with Konko: Discover how to build retrieval enhanced generative QA systems with Konko.
  4. Retrieval Augmented Generation: A deep dive into summarizing reviews at scale, leveraging LLM, Pinecone, and LangChain with Konko AI.

What’s Next