Files
langchain/libs/cli/langchain_cli/integration_template/docs/llms.ipynb
T

6.5 KiB

Cell:
[Cell type raw - unsupported, skipped]

__ModuleName__LLM

  • TODO: Make sure API reference link is correct

This will help you get started with ModuleName completion models (LLMs) using LangChain. For detailed documentation on __ModuleName__LLM features and configuration options, please refer to the API reference.

Overview

Integration details

  • TODO: Fill in table features.
  • TODO: Remove JS support link if not relevant, otherwise ensure link is correct.
  • TODO: Make sure API reference links are correct.
Class Package Local Serializable JS support Package downloads Package latest
__ModuleName__LLM package_name ✅/❌ beta/❌ ✅/❌ PyPI - Downloads PyPI - Version

Setup

  • TODO: Update with relevant info.

To access ModuleName models you'll need to create a/an ModuleName account, get an API key, and install the __package_name__ integration package.

Credentials

  • TODO: Update with relevant info.

Head to (TODO: link) to sign up to ModuleName and generate an API key. Once you've done this set the __MODULE_NAME___API_KEY environment variable:

In [ ]:
import getpass
import os

if not os.getenv("__MODULE_NAME___API_KEY"):
    os.environ["__MODULE_NAME___API_KEY"] = getpass.getpass("Enter your __ModuleName__ API key: ")

If you want to get automated tracing of your model calls you can also set your LangSmith API key by uncommenting below:

In [ ]:
# os.environ["LANGCHAIN_TRACING_V2"] = "true"
# os.environ["LANGCHAIN_API_KEY"] = getpass.getpass("Enter your LangSmith API key: ")

Installation

The LangChain ModuleName integration lives in the __package_name__ package:

In [ ]:
%pip install -qU __package_name__

Instantiation

Now we can instantiate our model object and generate chat completions:

  • TODO: Update model instantiation with relevant params.
In [ ]:
from __module_name__ import __ModuleName__LLM

llm = __ModuleName__LLM(
    model="model-name",
    temperature=0,
    max_tokens=None,
    timeout=None,
    max_retries=2,
    # other params...
)

Invocation

  • TODO: Run cells so output can be seen.
In [4]:
input_text = "__ModuleName__ is an AI company that "

completion = llm.invoke(input_text)
completion

Chaining

We can chain our completion model with a prompt template like so:

  • TODO: Run cells so output can be seen.
In [ ]:
from langchain_core.prompts import PromptTemplate

prompt = PromptTemplate(
    "How to say {input} in {output_language}:\n"
)

chain = prompt | llm
chain.invoke(
    {
        "output_language": "German",
        "input": "I love programming.",
    }
)

TODO: Any functionality specific to this model provider

E.g. creating/using finetuned models via this provider. Delete if not relevant

API reference

For detailed documentation of all __ModuleName__LLM features and configurations head to the API reference: https://api.python.langchain.com/en/latest/llms/module_name.llms.__ModuleName__LLM.html