Skip to main content

litchain

Project description

LitChain

Docs

Simple wrapper around openai's client.chat.completions.create. To simplify function/tool calling. openai docs

This repo takes some inspiration from langchain. But does not use it.

We think that, in langchain, it's fast changes make it a good forum to be aware of the most recent advances and methods in llm usage. But that is unstable, unnecessary complex, sometimes redundant, and makes you loss control over your code and prompts. And that using a simple prompt and an external library is enough for a lot of cases. So we don't want to use it in production.

Usage

Main operator

from litchain import LlmBaseModel, tool


@tool
def get_current_weather(location, unit="fahrenheit"):
    """Get the current weather in a given location."""
    [...]


model = LlmBaseModel(
    system="GPT assistant",
    prompt_template="What's the weather in {city}?",
    tools=[get_current_weather],
    tool_choice="get_weather")

prompt = model.get_prompt(city="San Francisco")
model.predict_sample(prompt=prompt)

For full code, check examples/hello_world

Examples

Run

/examples/mail_classifier/mail_classifier.py --email "I want to buy a car"

for a simple example.

List of examples:

  • hello_world.py: A simple example using get_current_weather func from openai docs.
  • mail_classifier.py: A simple example of a mail classifier.
  • movie_trivia_autogpt.py: A simple example of a movie trivia generator using sequential llm calls.

Setup

Instalation

pip install litchain

or from source

pip install -r requirements.txt
pip install -e .

Env variables

You will need to set the following env variables:

  • OPENAI_API_KEY: Your openai api key.

Authors

Iuiu

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

litchain-0.0.2.tar.gz (9.1 kB view details)

Uploaded Source

File details

Details for the file litchain-0.0.2.tar.gz.

File metadata

  • Download URL: litchain-0.0.2.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.9

File hashes

Hashes for litchain-0.0.2.tar.gz
Algorithm Hash digest
SHA256 404f801de6ea8230ed29a1d82e2d521774c4f005bf12cb2f30fb982506f7e493
MD5 80192c806eb2579ee1931ad5dbff0963
BLAKE2b-256 845df4097c3aea0694573bebcb2fd60e485becf305c0c2ad0d63441e87ba5b75

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