codechain


Namecodechain JSON
Version 0.0.5 PyPI version JSON
download
home_page
SummaryCode generation with LLMs
upload_time2023-08-03 12:36:50
maintainer
docs_urlNone
authorJames Murdza
requires_python
license
keywords python llms codegen code generation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# 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:

```python
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:
```python
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](https://github.com/jamesmurdza/humaneval-langchain/) for an example of how to use this library with HumanEval.


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "codechain",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,llms,codegen,code generation",
    "author": "James Murdza",
    "author_email": "<james@jamesmurdza.com>",
    "download_url": "https://files.pythonhosted.org/packages/a7/6f/eac0204b19a64c02b5b4bfb31b3b9d9b4b9ff2c203c681f3f598024d3f05/codechain-0.0.5.tar.gz",
    "platform": null,
    "description": "\n# CodeChain\n\nCodeChain is a library for generating and evaluating code with LLMs.\n\nTo install: `pip install codechain`\n\nTo install from source: `pip install -e .`\n\nTo run unit tests: `python tests/*.py`\n\n## Code completion\n\nUsage is very simple:\n\n```python\nfrom codechain.generation import CompleteCodeChain\nfrom langchain.chat_models import ChatOpenAI\n\ngenerator = CompleteCodeChain.from_llm(\n    ChatOpenAI(model=\"gpt-3.5-turbo\", temperature=0.2)\n    )\n\nresult = generator.run(\"\"\"\ndef fibonacci(n):\n# Generate the n-th fibonacci number.\n\"\"\")\n\nprint(result)\n```\n\nOutput:\n```python\ndef fibonacci(n):\n    # Generate the n-th fibonacci number.\n    if n <= 0:\n        return \"Invalid input. n must be a positive integer.\"\n    elif n == 1:\n        return 0\n    elif n == 2:\n        return 1\n    else:\n        fib_list = [0, 1]\n        for i in range(2, n):\n            fib_list.append(fib_list[i-1] + fib_list[i-2])\n        return fib_list[n-1]\n```\n\n## LLM evaluation\n\nSee [here](https://github.com/jamesmurdza/humaneval-langchain/) for an example of how to use this library with HumanEval.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Code generation with LLMs",
    "version": "0.0.5",
    "project_urls": {
        "Source": "https://github.com/jamesmurdza/codechain"
    },
    "split_keywords": [
        "python",
        "llms",
        "codegen",
        "code generation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ef9b4e431595cd0f5983c7a4b7955a609d74f9be01db3fdc081ee6478f1faff",
                "md5": "cc04fb919b87ac8ef8387b27bd6a5815",
                "sha256": "d508207efecb103f1b08419c658e6854eb830d7691c91a1ffc2bab4ac1454a28"
            },
            "downloads": -1,
            "filename": "codechain-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "cc04fb919b87ac8ef8387b27bd6a5815",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 3788,
            "upload_time": "2023-08-03T12:36:49",
            "upload_time_iso_8601": "2023-08-03T12:36:49.324174Z",
            "url": "https://files.pythonhosted.org/packages/8e/f9/b4e431595cd0f5983c7a4b7955a609d74f9be01db3fdc081ee6478f1faff/codechain-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a76feac0204b19a64c02b5b4bfb31b3b9d9b4b9ff2c203c681f3f598024d3f05",
                "md5": "f7dc10a2514a8f364ae09089eb1e87b5",
                "sha256": "cb5c5c475d46cff7888b89bc27814d67c82c2bc46e39387abf19c296f4b42ac6"
            },
            "downloads": -1,
            "filename": "codechain-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "f7dc10a2514a8f364ae09089eb1e87b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 3494,
            "upload_time": "2023-08-03T12:36:50",
            "upload_time_iso_8601": "2023-08-03T12:36:50.835346Z",
            "url": "https://files.pythonhosted.org/packages/a7/6f/eac0204b19a64c02b5b4bfb31b3b9d9b4b9ff2c203c681f3f598024d3f05/codechain-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-03 12:36:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jamesmurdza",
    "github_project": "codechain",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "codechain"
}
        
Elapsed time: 0.27333s