Skip to main content

ChatGPT4PCG is a python package containing required and utility functions as a part of ChatGPT4PCG competition.

Project description

ChatGPT4PCG

ChatGPT4PCG is a python package containing required and utility functions as a part of ChatGPT4PCG competition.

Installation

Use the package manager pip to install ChatGPT4PCG.

pip install chatgpt4pcg

Dependency

This file uses the following Python libraries:

  • openai

Functions

run_evaluation(team_name: str, fn: Type[TrialLoop], num_trials=10, characters: list[str] = None)

This function runs a trial for each character in the alphabet for a given team. It creates directories for logging and output, and generates a log file with a timestamp and timezone in the filename. It then runs trials for each character, skipping any that already exist.

run_trial(ctx: TrialContext, fn: Type[TrialLoop])

This function runs a single trial. It writes the result of the trial to the log file and the final response to a text file in the output directory.

chat_with_chatgpt(ctx: TrialContext, messages: []) -> list[str]

This function chats with ChatGPT. It sends a list of messages to the ChatGPT model and writes the response and token counts to the log file. It also checks for time and token limits, raising errors if these are exceeded.

Usage

To use this file, import it and call the run_evaluation function with the team name and trial loop function as arguments. You can also specify the number of trials to run and the characters to run trials for.

from chatgpt4pcg.competition import run_evaluation, TrialLoop, TrialContext, chat_with_chatgpt


class ZeroShotPrompting(TrialLoop):
    @staticmethod
    def run(ctx: TrialContext, target_character: str) -> str:
        message_history = [{
            "role": "user",
            "content": "Return this is a test message."
        }]

        response = chat_with_chatgpt(ctx, message_history)
        return response[0]


run_evaluation("x_wing", ZeroShotPrompting)

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

chatgpt4pcg-1.2.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

chatgpt4pcg-1.2.2-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file chatgpt4pcg-1.2.2.tar.gz.

File metadata

  • Download URL: chatgpt4pcg-1.2.2.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for chatgpt4pcg-1.2.2.tar.gz
Algorithm Hash digest
SHA256 a4f6808855e95e708d5ccf322a413476c54890894aff25c7d6a0a42f19b52f79
MD5 43a22f9a60695146731824db13aa78ef
BLAKE2b-256 4825900b9e139c1b62731011fd2961048e71932c85d65050a66b1177fcf80dd8

See more details on using hashes here.

File details

Details for the file chatgpt4pcg-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: chatgpt4pcg-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for chatgpt4pcg-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 59aa89982c6097e78c0c7df0d217d854e303627a2cfed9147af33f860866e9ce
MD5 942999b2f1891bfbfcccc4fd06a1318c
BLAKE2b-256 71de3d127f65528906d1f3239f6320ebceb0ce12b32611a47df3d291c2e92944

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