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 promptimages
: a list of images that will be inserted into the end of the prompt, following openai's message image formatreply_format
: a reply format is a instance ofStructureSchema
that helps the model to better understand the context of the conversation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file codelinker-0.3.21.tar.gz
.
File metadata
- Download URL: codelinker-0.3.21.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8ff2fe20f594c8c72d73723be3b04585743ba9a1cc9b38c2083c0b0cac907b4 |
|
MD5 | 7f998696925784c906c7d8b2e7083f4b |
|
BLAKE2b-256 | d1ee24bc6330fb6457563fc9ea54d1956de17730cd0a4ff27c4ab5f221ba722f |
File details
Details for the file codelinker-0.3.21-py3-none-any.whl
.
File metadata
- Download URL: codelinker-0.3.21-py3-none-any.whl
- Upload date:
- Size: 22.6 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6479fc0c80b5fd03dd84418bc01961b36508c42e07f2be482e97556b874a426a |
|
MD5 | 7aac901f3ff2585892e1c6d5ed5b457b |
|
BLAKE2b-256 | 7acf545053924e354930df4663d6902f205b14f9834296c9f037a2db686b53ba |