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

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 = await generator.arun("""
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.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

codechain-0.0.2-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: codechain-0.0.2.tar.gz
  • Upload date:
  • Size: 3.4 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.2.tar.gz
Algorithm Hash digest
SHA256 a2274a3913396c4b0aed198d09787f984fdd5583c6517e9d43f3bc036d478f8d
MD5 2e712a7694eeaeb769b0d7320583844c
BLAKE2b-256 94f09fb46e3fcb9abcdb685a6cfcb5a3e970311f6177201554a02413be11fddc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codechain-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 efa74e0693c306ca15bf6572de538651c519a63449fb663f792c1848ddce65c1
MD5 b53e91c387e2a94695352d0d3364e6de
BLAKE2b-256 360cfa6757d5c88d520cdf64ab0d19625d9eb2e5ec383fa5821e66b5401471c7

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