Skip to main content

A tool to link the code with large language models.

Project description

CodeLinker : Link your code with Language Models

CodeLinker aims to provide functions to link your code with language models. It builds on top of the Pydatic library and Tool Calling abilities introduced by OpenAI, which enabling models to generate content according to Json Schema.

Usage

The core concept of this package is to treat language models as a function handler. By defining a schema for return value of the function, we can call the function and let the model generate the return value.

To start with, we need to first define the configuration that will be used during exection:

config = CodeLinkerConfig(api_keys={
    "gpt-3.5-turbo-16k":[{
        "api_key": "your api key here",
        "model": "model name alias here"
    }]
})
cl = CodeLinker(config)

The we can define the schema of the return value:

class HelloWorldSchema(BaseModel):
    message: str = Field(description="the message to be returned")

Then we can use the cl object to wrap the function you want to call:

@cl.smartFunc()
def hello_world() -> HelloWorldSchema:
    """Say hello to the world"""

The function's docstring will be passed to models as instruction about what this function should do. Now we can call the function and let the model generate the return value:

result = hello_world()
print(result.message)
# sample output:
# Hello, World!

The function wrapped by cl.smartFunc will have extra key-world arguments that can be used to control the output of the model:

  • messages: a list of messages that will be inserted into the beginning of the prompt
  • images: a list of images that will be inserted into the end of the prompt, following openai's message image format
  • reply_format: a reply format is a instance of StructureSchema that helps the model to better understand the context of the conversation.

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

codelinker-0.3.22.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

codelinker-0.3.22-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

Details for the file codelinker-0.3.22.tar.gz.

File metadata

  • Download URL: codelinker-0.3.22.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.8.0-1014-azure

File hashes

Hashes for codelinker-0.3.22.tar.gz
Algorithm Hash digest
SHA256 8830f34c7c20c48805f1e9982e580d449ef29c2d85afa7e596e28b61f2f32615
MD5 82a597c75941d31117f360749bb29570
BLAKE2b-256 4735be8830db341968a4d9b932ca122f0e373130e9e9a3e52e4d24eb8d255f60

See more details on using hashes here.

File details

Details for the file codelinker-0.3.22-py3-none-any.whl.

File metadata

  • Download URL: codelinker-0.3.22-py3-none-any.whl
  • Upload date:
  • Size: 22.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Linux/6.8.0-1014-azure

File hashes

Hashes for codelinker-0.3.22-py3-none-any.whl
Algorithm Hash digest
SHA256 8c68c18cc4976d14227d5fc0f18d63892e22ba73ebc04b5df0f718219d52e841
MD5 5f7f8150ed771b1bfb8992bebbfa73f8
BLAKE2b-256 975a7cc6e60d73232f4f954b00de91d6d737008fb1ce64b9a7e1667725b03a6d

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