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.4.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: codechain-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 0244734c2b34d8586b661d9f62fcfe1e025a1348c494bebfa88715c2a1cfec8c
MD5 22a0e37e97c2b92b338125989980a819
BLAKE2b-256 6e7e221bf5414349fba5f6365098cc73de9a7868cea714324702d478074cd553

See more details on using hashes here.

File details

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

File metadata

  • Download URL: codechain-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f07a0e330ba2563f485b546132d19390a6b80e6ede8621a21e892a12c1a85845
MD5 ab169a1d11fd2b09f1a52a5d6c18112d
BLAKE2b-256 8390bd862cfc16b4dcf7914fd7b4eae0ad989279f8280e6cc1c00931dade3d79

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