Skip to main content

A library to easily create functions based on OpenAI's GPT

Project description

funcgpt: Python library for creating functions with OpenAI's GPT

funcgpt is an easy-to-use Python library that allows you to quickly create Python functions using the power of OpenAI's GPT models. With just a few lines of code, you can create functions that generate human-like responses, answer questions, or anything else that GPT is capable of.

Features

  • Easy to use decorator for creating functions based on GPT models
  • Supports different GPT model versions
  • Customize GPT's behavior with adjustable temperature values
  • Generate responses in streaming or non-streaming modes

Installation

To install funcgpt, use pip:

pip install funcgpt

Usage

To create a function that answers questions like a pirate, you can use the following snippet:

from funcgpt import gpt

@gpt
def answer_like_pirate(message: str) -> str:
    """Answer questions like a pirate."""
    ...

Usage:

>>> answer_like_pirate("How are you doing today?")
"Arrr, I be doin' fine, matey."

To do the same thing, but with a function that streams responses, you can use the following snippet:

from typing import Iterator
from funcgpt import gpt

@gpt
def stream_like_pirate(message: str) -> Iterator[str]:
    """Answers questions like a pirate."""
    ...

Usage:

>>> for token in stream_like_pirate("How are you doing today?"):
...     print(token, end="", flush=True)
...
Arrr, I be doin' fine, matey.

For defining a function that returns a boolean value, you can use the following snippet:

from funcgpt import gpt

@gpt
def is_pirate(message: str) -> bool:
    """Returns true if the message is from a pirate."""
    ...

Usage:

>>> is_pirate("Arrr, I be doin' fine, matey.")
True

For choosing a different model or temperature, you can use the model and temperature keyword arguments:

from funcgpt import gpt

@gpt(model="gpt-4", temperature=0)
def answer_like_pirate(message: str) -> str:
    """Answer questions like a pirate."""
    ...

Contributing

We welcome contributions! Please feel free to fork the repository, make changes, and submit pull requests. If you have any questions or ideas, don't hesitate to open an issue.

License

funcgpt is released under the MIT License. See the LICENSE file for more details.

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

funcgpt-1.1.1.tar.gz (618.3 kB view details)

Uploaded Source

Built Distribution

funcgpt-1.1.1-py3-none-any.whl (617.7 kB view details)

Uploaded Python 3

File details

Details for the file funcgpt-1.1.1.tar.gz.

File metadata

  • Download URL: funcgpt-1.1.1.tar.gz
  • Upload date:
  • Size: 618.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for funcgpt-1.1.1.tar.gz
Algorithm Hash digest
SHA256 0459b89b39125a812804f63a06b95ffd4c9ee5326fc75933a9454dd60306dbec
MD5 51d61e5edf18b8f22df96701f03f3ada
BLAKE2b-256 b6c1eb21ab38c4cea395a4ab42464f446a6db2e915a7ae6a1f4cf017daaa9f12

See more details on using hashes here.

File details

Details for the file funcgpt-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: funcgpt-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 617.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for funcgpt-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d39a0f263ea45e985657ab21b1517452db1facec9f90cde8be68c8bbbf341f99
MD5 47af05bf1c91c1d346cf0d6a1eb450c8
BLAKE2b-256 ffc51fe0481c7d7400958cd01e7a18fe741bcb268c5335d70221bcbe305a379f

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