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-1.0.0.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-1.0.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chatgpt4pcg-1.0.0.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-1.0.0.tar.gz
Algorithm Hash digest
SHA256 75a51091b4ef4f33c7030765a6a9b89bd6be6c8494e3e4b6296eb945be93b665
MD5 753e6b6bc05aa7074bc1c134bae8fccd
BLAKE2b-256 672e8072adc9418bc4f57f175ea701947e6ec08ec696cbf6381be05c45e040b6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: chatgpt4pcg-1.0.0-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-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebb03f0319e30319573a0ab7639975af687934f0a3ead452ec60e90f3d250f57
MD5 1db830981e71ead01eb8d5c3fbfb4222
BLAKE2b-256 a460de543e9ec20071c6fcc75ae206be4db7eb3010069d08b5599103e5f6c300

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