kork


Namekork JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/langchain-ai/kork
SummaryNatural Language Interfaces Powered by LLMs
upload_time2023-05-12 15:33:13
maintainer
docs_urlNone
authorLangChain
requires_python>=3.8.1,<4.0.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Unit Tests](https://github.com/langchain-ai/kork/actions/workflows/test.yml/badge.svg?branch=main&event=push)](https://github.com/langchain-ai/kork/actions/workflows/test.yml)

# Kork ![alt The Parrot](assets/parrot.png)

`Kork` is an *experimental* [Langchain chain](https://python.langchain.com/en/latest/modules/chains.html) that helps build natural language APIs powered by LLMs.

## Features

1. Assemble a natural language API from a set of python functions.
2. Generate a prompt to help the LLM write a **correct** program.
3. Execute the program generated by the LLM **safely**.
4. Program generation takes a single LLM call, as opposed to agents that use a call per action taken.

## Show me! 😹 

[Image manipulation API using PIL](https://langchain-ai.github.io/kork/examples/image_manipulation.html)

<img src="assets/cats.png" alt="Cats!!!" style="max-width: 500px;">

## How

The chain takes a user query, translates it into a program, and executes it using the `Kork` interpreter.

The interpreter is used to run code written in the `Kork` programming language.

The language is limited by design to variable declarations, function invocations and arithmetic operations.

This limitation allows controlling the kind of programs the LLMs can generate, making the output of the LLM more predictable and safer to execute in a production setting. (An agent with access to "constrained" tools has similar benefits, but requires a call per action taken.)

`Kork` adds a few additional tricks (e.g., retriever interfaces for examples and foreign functions) to help guide the LLM to generate a **correct** program.

## What?

*No loops, no conditionals, no file access, no network access, no arbitrary code execution. WHAT?!*

The ability to invoke custom functions goes a long way in terms of the kinds of programs that can be written! (You can always add a `write_to_file` function!)


## Limitations

- `Kork` **cannot write arbitrary** code. If that's what you need, save yourself some time and use [docker](https://www.docker.com/) and a real programming language.
- The `Kork` chain is **not** an Agent, so it cannot inspect intermediate steps, instead it generates a pre-defined set of function calls that need to be executed. (But remember that function calls can involve calls to an agent!)
- The `Kork` language and interpreter are limited to *function invocation*, *variable declaration* and
  *basic arithmetic* (no function declaration, loops etc.)
- Only supporting `int`, `float`, `str`, `type(None)`, `bool` types. No support for `lists` or `object` types.
- Very limited type annotations.

## Quality

The short version: No benchmarks yet!

The long version: Quality of generated programs depends on many factors.

You can experiment with tweaking the prompt (e.g., explain the syntax of the language), changing the foreign function retriever (e.g., retrieve the most relevant foreign functions based on the user query), or providing examples in the form of (query, expected program).

The prompt, examples and syntax of the language can trip up the LLM to assume
it's programming in a specific language (e.g., typescript or python) and assume
that it can use language features that are not supported by `Kork` or to import
libraries that are not available.

## Safety

Nothing is bulletproof when humans are involved.

* Don't do silly things like exposing `eval` as a foreign function.
* If a foreign function allocates memory, the LLM could ask for more memory than is available crashing the process.
* Think carefully before using the output of an LLM. If the LLM behaves maliciously, is it safe to use an LLM in the given context? 

## Future Work

Let us know if you're interested in contributing or have ideas for improvements!

- Allow enabling/disabling language features
- Allow changing underlying language syntax
- Add support for objects
- Add other language features (e.g., loops) 
- Provide foreign function retriever implementations based on similarity to user query

## Compatibility

`Kork` is tested against python 3.8, 3.9, 3.10, 3.11.

## Installation 

```sh
pip install kork
```

## 🙏 Appreciation

* [Lark](https://github.com/lark-parser/lark) -- For making it easy to define a grammar and parse it!
* [Bob Nystrom](https://github.com/munificent) -- For writing [Crafting Interpreters](https://www.craftinginterpreters.com/)!

## © Contributing

If you have any ideas or feature requests, please open an issue and share!

See [CONTRIBUTING.md](https://github.com/langchain-ai/kork/blob/main/CONTRIBUTING.md) for more information.

## 🎶 Why the name?

Fast to type and maybe sufficiently unique.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/langchain-ai/kork",
    "name": "kork",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.1,<4.0.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "LangChain",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/a6/6b/27a45d91976c5d0b477c801f28798696b56118b75bcc5521e705aa5f62c6/kork-0.0.3.tar.gz",
    "platform": null,
    "description": "[![Unit Tests](https://github.com/langchain-ai/kork/actions/workflows/test.yml/badge.svg?branch=main&event=push)](https://github.com/langchain-ai/kork/actions/workflows/test.yml)\n\n# Kork ![alt The Parrot](assets/parrot.png)\n\n`Kork` is an *experimental* [Langchain chain](https://python.langchain.com/en/latest/modules/chains.html) that helps build natural language APIs powered by LLMs.\n\n## Features\n\n1. Assemble a natural language API from a set of python functions.\n2. Generate a prompt to help the LLM write a **correct** program.\n3. Execute the program generated by the LLM **safely**.\n4. Program generation takes a single LLM call, as opposed to agents that use a call per action taken.\n\n## Show me! \ud83d\ude39 \n\n[Image manipulation API using PIL](https://langchain-ai.github.io/kork/examples/image_manipulation.html)\n\n<img src=\"assets/cats.png\" alt=\"Cats!!!\" style=\"max-width: 500px;\">\n\n## How\n\nThe chain takes a user query, translates it into a program, and executes it using the `Kork` interpreter.\n\nThe interpreter is used to run code written in the `Kork` programming language.\n\nThe language is limited by design to variable declarations, function invocations and arithmetic operations.\n\nThis limitation allows controlling the kind of programs the LLMs can generate, making the output of the LLM more predictable and safer to execute in a production setting. (An agent with access to \"constrained\" tools has similar benefits, but requires a call per action taken.)\n\n`Kork` adds a few additional tricks (e.g., retriever interfaces for examples and foreign functions) to help guide the LLM to generate a **correct** program.\n\n## What?\n\n*No loops, no conditionals, no file access, no network access, no arbitrary code execution. WHAT?!*\n\nThe ability to invoke custom functions goes a long way in terms of the kinds of programs that can be written! (You can always add a `write_to_file` function!)\n\n\n## Limitations\n\n- `Kork` **cannot write arbitrary** code. If that's what you need, save yourself some time and use [docker](https://www.docker.com/) and a real programming language.\n- The `Kork` chain is **not** an Agent, so it cannot inspect intermediate steps, instead it generates a pre-defined set of function calls that need to be executed. (But remember that function calls can involve calls to an agent!)\n- The `Kork` language and interpreter are limited to *function invocation*, *variable declaration* and\n  *basic arithmetic* (no function declaration, loops etc.)\n- Only supporting `int`, `float`, `str`, `type(None)`, `bool` types. No support for `lists` or `object` types.\n- Very limited type annotations.\n\n## Quality\n\nThe short version: No benchmarks yet!\n\nThe long version: Quality of generated programs depends on many factors.\n\nYou can experiment with tweaking the prompt (e.g., explain the syntax of the language), changing the foreign function retriever (e.g., retrieve the most relevant foreign functions based on the user query), or providing examples in the form of (query, expected program).\n\nThe prompt, examples and syntax of the language can trip up the LLM to assume\nit's programming in a specific language (e.g., typescript or python) and assume\nthat it can use language features that are not supported by `Kork` or to import\nlibraries that are not available.\n\n## Safety\n\nNothing is bulletproof when humans are involved.\n\n* Don't do silly things like exposing `eval` as a foreign function.\n* If a foreign function allocates memory, the LLM could ask for more memory than is available crashing the process.\n* Think carefully before using the output of an LLM. If the LLM behaves maliciously, is it safe to use an LLM in the given context? \n\n## Future Work\n\nLet us know if you're interested in contributing or have ideas for improvements!\n\n- Allow enabling/disabling language features\n- Allow changing underlying language syntax\n- Add support for objects\n- Add other language features (e.g., loops) \n- Provide foreign function retriever implementations based on similarity to user query\n\n## Compatibility\n\n`Kork` is tested against python 3.8, 3.9, 3.10, 3.11.\n\n## Installation \n\n```sh\npip install kork\n```\n\n## \ud83d\ude4f Appreciation\n\n* [Lark](https://github.com/lark-parser/lark) -- For making it easy to define a grammar and parse it!\n* [Bob Nystrom](https://github.com/munificent) -- For writing [Crafting Interpreters](https://www.craftinginterpreters.com/)!\n\n## \u00a9 Contributing\n\nIf you have any ideas or feature requests, please open an issue and share!\n\nSee [CONTRIBUTING.md](https://github.com/langchain-ai/kork/blob/main/CONTRIBUTING.md) for more information.\n\n## \ud83c\udfb6 Why the name?\n\nFast to type and maybe sufficiently unique.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Natural Language Interfaces Powered by LLMs",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/langchain-ai/kork",
        "Repository": "https://github.com/langchain-ai/kork"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "372ad87b8b62731f063cef8e126458a2581310ab18b782b0e5c6f98d989474ac",
                "md5": "1f2d13f17861d0fca72e386e0d71257e",
                "sha256": "dbf572091b2c5504cd9e95fd2c65f7a7f304a2e084b79ab0058505ec71472395"
            },
            "downloads": -1,
            "filename": "kork-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1f2d13f17861d0fca72e386e0d71257e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.1,<4.0.0",
            "size": 24170,
            "upload_time": "2023-05-12T15:33:12",
            "upload_time_iso_8601": "2023-05-12T15:33:12.930441Z",
            "url": "https://files.pythonhosted.org/packages/37/2a/d87b8b62731f063cef8e126458a2581310ab18b782b0e5c6f98d989474ac/kork-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a66b27a45d91976c5d0b477c801f28798696b56118b75bcc5521e705aa5f62c6",
                "md5": "073caea190fd68c5f039a0cce0c3bbff",
                "sha256": "ba02eb494cb53489cd8fd567868f6a895b2f5250d436a8503827d13a0f048935"
            },
            "downloads": -1,
            "filename": "kork-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "073caea190fd68c5f039a0cce0c3bbff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.1,<4.0.0",
            "size": 22257,
            "upload_time": "2023-05-12T15:33:13",
            "upload_time_iso_8601": "2023-05-12T15:33:13.976521Z",
            "url": "https://files.pythonhosted.org/packages/a6/6b/27a45d91976c5d0b477c801f28798696b56118b75bcc5521e705aa5f62c6/kork-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-12 15:33:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "langchain-ai",
    "github_project": "kork",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "kork"
}
        
Elapsed time: 0.08051s