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: [])

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 competition import run_evaluation, TrialLoop, TrialContext, chat_with_chatgpt


class ZeroShotPrompting(TrialLoop):
    message_history = []

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

        response = chat_with_chatgpt(ctx, ZeroShotPrompting.message_history)
        return response


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-0.0.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chatgpt4pcg-0.0.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chatgpt4pcg-0.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for chatgpt4pcg-0.0.1.tar.gz
Algorithm Hash digest
SHA256 98085f17b87032843c78fcc22f808a7af4866c94c45da42994bff17b5c98ac92
MD5 46cb2d5a098dcb853b166c2822d09c44
BLAKE2b-256 b72a81af0499ca94accc243e7a8a72bed76e3197e6f614a724c949ea7d403664

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chatgpt4pcg-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for chatgpt4pcg-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8089649583fc31f951558f832517a55a0bccec380ab6b2527f220e436cdb5dd
MD5 e3d7decdfb653eaa2c310ff144f91de3
BLAKE2b-256 897f1c0343c8ece40d9b5c9a5a831aadb03bceadab6954c6932ac8aaa4e93334

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page