Skip to main content

Funkai Library

Funkai is a Python library that encapsulates linguistic operations and uses OpenAI or Claude to perform them based on user inputs.

Features

  • Diverse Operations: Easily define linguistic tasks that can process various data types.
  • Interaction with LLM: Seamlessly connect and utilize the LLM (OpenAI or Claude) API to run operations.
  • Dynamic Management: Add, remove, and run operations on-the-fly with the FunkManager.

Funkai Setup

Install via pip:

pip install funkai

Or clone the repository:

git clone https://github.com/ciaraadkins/funkai.git
pip install ./funkai/

Once installed, import the necessary modules:

OpenAI Setup

For the OpenAI functionality to work, you need to set up your OpenAI API key with init of FunkManager

from funkai import OpenAIFunk

funk = OpenAIFunk(
        model="gpt-4-turbo-preview",
        api_key='OPEN_API_KEY'
    )

Additionally, if you want to monitor your llm usage, we recommend using llmonitor (you will need to also set up an account and get an app id on llmonitor.com):

pip install openai llmonitor
os.environ["LLMONITOR_APP_ID"] = "YOUR_LLMONITOR_APP_ID"

Claude Setup

For the Claude functionality to work, you need to set up your Claude API key with init of FunkManager

from funkai import ClaudeFunk

funk = ClaudeFunk(
        model="claude-3-opus-20240229",
        api_key='CLAUDE_API_KEY'
    )

Methods

add(name, operation, api_key=None, model=None, retry_count=0, input_dtype=str, output_dtype=str, options={'temperature': int, 'max_tokens': int})

Add a new Funk instance to the manager.

Parameters:

  • name: Unique identifier for the Funk instance.
  • operation: Description of the operation or task performed by the Funk instance.
  • api_key: API key for accessing the LLM API. If not provided, the API key from FunkManager will be used.
  • model: Model to be used for the Funk instance. If not provided, the default model from FunkManager will be used.
  • retry_count: Number of retries allowed if there's an error during execution (default is 0).
  • input_dtype: Data type expected for input to the Funk instance (default is str).
  • output_dtype: Data type expected for output from the Funk instance (default is str).
  • options: Allows you to pass parameters such as temperate and max_tokens to each jobs.

Raises:

  • ValueError: If a Funk with the same name already exists or if the parameters are invalid.
update(name, **kwargs)

Update parameters of an existing Funk instance.

Parameters:

  • name: Name of the Funk instance to update.

  • **kwargs: Parameters to update. Supported parameters are retry_count, input_dtype, output_dtype.

Raises:

  • ValueError: If no Funk with the specified name is found or if an invalid parameter is provided.
run(name, input_content, examples=None, full_resp=False)

Execute a Funk operation by name.

Parameters:

  • name: Name of the Funk instance to run.
  • input_content: Input data for the Funk operation.
  • examples: Dictionary of examples to provide context or guidance to the Funk operation (default is None).
  • full_resp: Boolean indicating whether to return the full response including metadata (default is False).

Returns:

  • Output of the Funk operation.

Raises:

  • ValueError: If no Funk with the specified name is found.

Example Usage

# Initialize FunkManager
manager = OpenAIFunk(model="gpt-4-turbo-preview", api_key="YOUR_OPENAI_API_KEY")

# Add a new Funk instance
manager.add(name="example_funk", operation="Perform a sample task")

# Update parameters of the Funk instance
manager.update("example_funk", retry_count=3, output_dtype=int)

# Run the Funk operation
output = manager.run(name="example_funk", input_content="Input data")

print(output)

## Using Functions (Funks)
## Execute your defined function:

my_funks.run("rhyme5", "cat")
# should return something like: ['bat', 'hat', 'mat', 'rat', 'sat']

items = ["apple", "bike", "carrot", "date", "elephant", "fig", "grape", "helicopter", "ice cream", "jackfruit", "kite", "lemon", "mango", "notebook","strawberry", "television", "umbrella", "van", "watermelon", "xylophone", "yellow", "zebra"]

my_funks.run("find fruit", items)
# should return something like: ['apple','date','fig','grape','jackfruit','lemon','mango','strawberry','watermelon']

Prerequisites

This library is built on top of the OpenAI & Claude API. Ensure you have the OpenAI or Claude Python client installed and configured.

Contributing

If you find any bugs or want to propose enhancements, feel free to create issues and pull requests on GitHub.

License

This library is under the MIT license. See LICENSE for more details.

Metadata

Release files for funkai 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for funkai 1.1
File Size Uploaded
funkai-1.1.tar.gz 10.3 kB Details

Release files / funkai-1.1.tar.gz

Download URL funkai-1.1.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
06b68956b61601d5b0aab75953bf56379f3915f82392dc024d5be945e7d774ff
BLAKE2b-256 checksum
How to use checksums
5269616e5b17e80cef306b9d5e3575ea0c63403cc687dff4ddd3f89ddc6a95a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.1 This release

1 release file

1.0

2 release files

0.9

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page