chatgpt4pcg


Namechatgpt4pcg JSON
Version 1.2.1 PyPI version JSON
download
home_page
SummaryChatGPT4PCG is a python package containing required and utility functions as a part of ChatGPT4PCG competition.
upload_time2024-02-06 03:59:53
maintainer
docs_urlNone
author
requires_python>=3.11
licenseMIT License Copyright (c) 2024 Pittawat Taveekitworachai Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords chatgpt chatgpt4pcg competition
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ChatGPT4PCG

ChatGPT4PCG is a python package containing required and utility functions as a part of [ChatGPT4PCG](http://chatgpt4pcg.github.io) competition.

## Installation

Use the package manager [pip](https://pip.pypa.io/en/stable/) to install ChatGPT4PCG.

```bash
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.

```python
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)
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "chatgpt4pcg",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "Pittawat Taveekitworachai <pittawat.pete@gmail.com>",
    "keywords": "chatgpt,chatgpt4pcg,competition",
    "author": "",
    "author_email": "ChatGPT4PCG Organizing Team <chatgpt4pcg@gmail.com>, Pittawat Taveekitworachai <pittawat.pete@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b0/7e/afa33537c43fd15e618ec9e524bce01d715a0ca8b37f7c551da1934a11aa/chatgpt4pcg-1.2.1.tar.gz",
    "platform": null,
    "description": "# ChatGPT4PCG\n\nChatGPT4PCG is a python package containing required and utility functions as a part of [ChatGPT4PCG](http://chatgpt4pcg.github.io) competition.\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install ChatGPT4PCG.\n\n```bash\npip install chatgpt4pcg\n```\n\n## Dependency\n\nThis file uses the following Python libraries:\n\n- `openai`\n\n## Functions\n\n### `run_evaluation(team_name: str, fn: Type[TrialLoop], num_trials=10, characters: list[str] = None)`\n\nThis function runs a trial for each character in the alphabet for a given team. It creates directories for logging and\noutput, and generates a log file with a timestamp and timezone in the filename. It then runs trials for each character,\nskipping any that already exist.\n\n### `run_trial(ctx: TrialContext, fn: Type[TrialLoop])`\n\nThis function runs a single trial. It writes the result of the trial to the log file and the final response to a text\nfile in the output directory.\n\n### `chat_with_chatgpt(ctx: TrialContext, messages: []) -> list[str]`\n\nThis function chats with ChatGPT. It sends a list of messages to the ChatGPT model and writes the response and token\ncounts to the log file. It also checks for time and token limits, raising errors if these are exceeded.\n\n## Usage\n\nTo use this file, import it and call the `run_evaluation` function with the team name and trial loop function as\narguments. You can also specify the number of trials to run and the characters to run trials for.\n\n```python\nfrom chatgpt4pcg.competition import run_evaluation, TrialLoop, TrialContext, chat_with_chatgpt\n\n\nclass ZeroShotPrompting(TrialLoop):\n    @staticmethod\n    def run(ctx: TrialContext, target_character: str) -> str:\n        message_history = [{\n            \"role\": \"user\",\n            \"content\": \"Return this is a test message.\"\n        }]\n\n        response = chat_with_chatgpt(ctx, message_history)\n        return response[0]\n\n\nrun_evaluation(\"x_wing\", ZeroShotPrompting)\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Pittawat Taveekitworachai  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "ChatGPT4PCG is a python package containing required and utility functions as a part of ChatGPT4PCG competition.",
    "version": "1.2.1",
    "project_urls": {
        "Bug Reports": "https://github.com/chatgpt4pcg/chatgpt4pcg-python/issues",
        "Homepage": "https://chatgpt4pcg.github.io/",
        "Source": "https://github.com/chatgpt4pcg/chatgpt4pcg-python"
    },
    "split_keywords": [
        "chatgpt",
        "chatgpt4pcg",
        "competition"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f52c27284814c1ce56330e07bf2d61e3c96f58c443afe040aa4e3f7830d28cc8",
                "md5": "ca961e650ebea3a2b5e4567bbec7d084",
                "sha256": "6754606d5992fede5df643be16d97ee8355083b94c0a2bab9a90e343e4cbc729"
            },
            "downloads": -1,
            "filename": "chatgpt4pcg-1.2.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ca961e650ebea3a2b5e4567bbec7d084",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 7049,
            "upload_time": "2024-02-06T03:59:49",
            "upload_time_iso_8601": "2024-02-06T03:59:49.962457Z",
            "url": "https://files.pythonhosted.org/packages/f5/2c/27284814c1ce56330e07bf2d61e3c96f58c443afe040aa4e3f7830d28cc8/chatgpt4pcg-1.2.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b07eafa33537c43fd15e618ec9e524bce01d715a0ca8b37f7c551da1934a11aa",
                "md5": "479d775136f736457a6c610729a78910",
                "sha256": "549f0a236f307ebf503c5a6019c7b9cb8777bb7e290e34c4d940ec0efacd191a"
            },
            "downloads": -1,
            "filename": "chatgpt4pcg-1.2.1.tar.gz",
            "has_sig": false,
            "md5_digest": "479d775136f736457a6c610729a78910",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 6900,
            "upload_time": "2024-02-06T03:59:53",
            "upload_time_iso_8601": "2024-02-06T03:59:53.363458Z",
            "url": "https://files.pythonhosted.org/packages/b0/7e/afa33537c43fd15e618ec9e524bce01d715a0ca8b37f7c551da1934a11aa/chatgpt4pcg-1.2.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-06 03:59:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "chatgpt4pcg",
    "github_project": "chatgpt4pcg-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "chatgpt4pcg"
}
        
Elapsed time: 0.17417s