Skip to main content

Code generation with LLMs

Project description

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.

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

codechain-0.0.5.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

codechain-0.0.5-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file codechain-0.0.5.tar.gz.

File metadata

  • Download URL: codechain-0.0.5.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for codechain-0.0.5.tar.gz
Algorithm Hash digest
SHA256 cb5c5c475d46cff7888b89bc27814d67c82c2bc46e39387abf19c296f4b42ac6
MD5 f7dc10a2514a8f364ae09089eb1e87b5
BLAKE2b-256 a76feac0204b19a64c02b5b4bfb31b3b9d9b4b9ff2c203c681f3f598024d3f05

See more details on using hashes here.

File details

Details for the file codechain-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: codechain-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for codechain-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d508207efecb103f1b08419c658e6854eb830d7691c91a1ffc2bab4ac1454a28
MD5 cc04fb919b87ac8ef8387b27bd6a5815
BLAKE2b-256 8ef9b4e431595cd0f5983c7a4b7955a609d74f9be01db3fdc081ee6478f1faff

See more details on using hashes here.

Supported by

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