Skip to main content

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

Project description

LLMs4PCG

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

Installation

Use the package manager pip to install LLMs4PCG.

pip install llms4pcg

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, model_name=None, local_model_base_url=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.

To use local LLM, specify model_name and local_model_base_url parameters. If model_name is not specified, it will use the default model name gpt-3.5-turbo. If local_model_base_url is not specified, it will use the default base url of OpenAI API.

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_llm(ctx: TrialContext, messages: []) -> list[str]

This function chats with the LLM. It sends a list of messages to the LLM 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 llms4pcg.competition import run_evaluation, TrialLoop, TrialContext, chat_with_llm


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_llm(ctx, message_history)
        return response[0]


run_evaluation("y_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

llms4pcg-2.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

llms4pcg-2.0.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file llms4pcg-2.0.0.tar.gz.

File metadata

  • Download URL: llms4pcg-2.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for llms4pcg-2.0.0.tar.gz
Algorithm Hash digest
SHA256 620407c6bf6e0ff12d0f7cb460fe87401f915c2683aceca38b548d28fd18196c
MD5 647915d980878ceabca4955705893175
BLAKE2b-256 3ca4cdb7532da5a5fdcbbf43c60bc6ffad550d0c4a07b674300588391b724236

See more details on using hashes here.

File details

Details for the file llms4pcg-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: llms4pcg-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for llms4pcg-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 97f339204e3e402ff4663a4f6aa38603fb3154da51c8f1a6990f9069cfc47a20
MD5 29f894298716c0a995a216cab6ab0959
BLAKE2b-256 1023afd5f0f7fc7454caa61404486f8c5e7df7e9584e27585c0a91576fb7e517

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