Skip to main content

CodeChain

CodeChain is a library for generating and evaluating code with LLMs.

To install: pip install codechain

To install from source: pip install -e .

To run unit tests: python tests/*.py

Code completion

Usage is very simple:

from codechain.generation import CompleteCodeChain
from langchain.chat_models import ChatOpenAI

generator = CompleteCodeChain.from_llm(
    ChatOpenAI(model="gpt-3.5-turbo", temperature=0.2)
    )

result = generator.run("""
def fibonacci(n):
# Generate the n-th fibonacci number.
""")

print(result)

Output:

def fibonacci(n):
    # Generate the n-th fibonacci number.
    if n <= 0:
        return "Invalid input. n must be a positive integer."
    elif n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        fib_list = [0, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

LLM evaluation

See here for an example of how to use this library with HumanEval.

Metadata

Release files for codechain 0.0.5

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

Source distribution (sdist)

Source distribution for codechain 0.0.5
File Size Uploaded
codechain-0.0.5.tar.gz 3.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for codechain 0.0.5
File Interpreter ABI Platform
codechain-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 7.3 kB

Release files / codechain-0.0.5.tar.gz

Download URL codechain-0.0.5.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
cb5c5c475d46cff7888b89bc27814d67c82c2bc46e39387abf19c296f4b42ac6
BLAKE2b-256 checksum
How to use checksums
a76feac0204b19a64c02b5b4bfb31b3b9d9b4b9ff2c203c681f3f598024d3f05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release files / codechain-0.0.5-py3-none-any.whl

Download URL codechain-0.0.5-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d508207efecb103f1b08419c658e6854eb830d7691c91a1ffc2bab4ac1454a28
BLAKE2b-256 checksum
How to use checksums
8ef9b4e431595cd0f5983c7a4b7955a609d74f9be01db3fdc081ee6478f1faff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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