Skip to main content

🚀 GPTBase

Welcome to GPTBase! This Python library provides a straightforward and user-friendly interface to leverage OpenAI's powerful GPT-3.5-Turbo and GPT-4 models for text generation. 📚🔍

✨ Features

  • 🎛️ Configurable parameters for chat completion.
  • 💬 Support for both individual prompts and chat conversations.
  • ⚡ Stream output option for faster response times.
  • 📝 Built-in logging and rich printing for enhanced visualization.
  • 🔄 Customizable model choice, including GPT-3.5-Turbo, GPT-4, and other variants.
  • 📈 Easy model parameter adjustment.
  • 🤖 Support for function calls in chat completions.

📦 Installation

You can easily install the GPTBase library from PyPI with a single command line:

pip install gptbase

Once installed, import it in your Python script:

from gptbase.basev2 import ChatAssistant, CompletionParameters, FunctionCall

📚 Usage

The library includes two powerful classes: Assistant for individual prompts and ChatAssistant for engaging, multi-turn chat conversations.

Here's a snippet showcasing a simple usage of the ChatAssistant class:

from gptbase.basev2 import ChatAssistant, CompletionParameters

cm = CompletionParameters(stream=True)
assistant = ChatAssistant(memory_turns=3)
message = assistant.chat("I want to learn Python", cm)

And here's an example of how to use function calls:

from gptbase.basev2 import Assistant, CompletionParameters, FunctionCall

# Define the function
get_weather_function = FunctionCall("get_current_weather", {"location": "Boston"})

# Define the functions that the model can call
functions = [
    {
        "name": "get_current_weather",
        "description": "Gets the current weather for a given location",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {
                    "type": "string",
                    "description": "The location to get the weather for"
                }
            },
            "required": ["location"]
        }
    }
]

# Define the parameters for the chat completion
params = CompletionParameters(
    model="gpt-3.5-turbo-0613",
    function_call=get_weather_function,
    functions=functions,
    # Add other parameters as needed
)

# Create an instance of the Assistant class
assistant = Assistant()

# Call the function
response = assistant.ask("What's the weather like in Boston?", params=params)

# Print the response
print(response)
extract_function_call(response)

def get_current_weather(location):
    """fake get current weather function."""
    print(f"Today's fake weather for {location} is _°")

func_dic = {get_current_weather.__name__: get_current_weather}
call_with_chat_completion(response, func_dic)

And you will get output like this:

Today's fake weather for Boston is _°

You can also use the command line interface for chat conversations:

gptbase-chat --memory-turns 3 --system-prompt "This is a system prompt."

For more examples and a deeper dive into usage, please refer to the detailed documentation. 📘

🙋 Support

If you have any questions, run into any issues, or just need a little help, don't hesitate to reach out. We're here to help! 🤝


Whether you're a veteran developer or just getting started, GPTBase is a powerful tool for any text generation task. Give it a try today! 🌟

Release files for gptbase 0.3.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 gptbase 0.3.1
File Size Uploaded
gptbase-0.3.1.tar.gz 12.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gptbase 0.3.1
File Interpreter ABI Platform
gptbase-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.1 kB

Release files / gptbase-0.3.1.tar.gz

Download URL gptbase-0.3.1.tar.gz
Size 12.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d8857c3bb45c500ca638f4df04f6deb3b4241ee9f16dbeeb9d619d207d6879ad
BLAKE2b-256 checksum
How to use checksums
2dda071df5ddb976d17564ab2eb14c43a6fffb7c0d087eb4f18a4960989c466b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release files / gptbase-0.3.1-py3-none-any.whl

Download URL gptbase-0.3.1-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d8037f0a939d0e0917e3d14701ab2bb55bdb808d9a7be14d33c0b467b3ee7df
BLAKE2b-256 checksum
How to use checksums
c170af21dc7f77bccbe7a949bbd4e562fdf8e582c4c11b20a8b0a6c282934a6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.5

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

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