Skip to main content

Useful classes and methods for researching code-generation by LLMs.

Project description

llm-codegen-research

lint code workflow test code workflow release workflow test coverage

about

A collection of methods and classes I repeatedly use when conducting research on LLM code-generation. Covers both prompting various LLMs, and analysing the markdown responses.

installation

Install directly from PyPI, using pip:

pip install llm-codegen-research

This installs the core package, which includes code parsing and analysis utilities. To also install the LLM API client libraries, use the api extra:

pip install llm-codegen-research[api]

usage

First configure environment vairables for the APIs you want to use:

export OPENAI_API_KEY=...
export ANTHROPIC_API_KEY=...
export TOGETHER_API_KEY=...
export MISTRAL_API_KEY=...
export DEEPSEEK_API_KEY=...
export NSCALE_API_KEY=...

You can get a quick response from an LLM:

from llm_cgr import generate, Markdown

response = generate("Write python code to generate the nth fibonacci number.")

markdown = Markdown(text=response)

Or define a client to generate multiple repsonses, or have a chat interaction:

from llm_cgr import get_llm

# create the llm
llm = get_llm(
    model="gpt-4.1-mini",
    system="You're a really funny comedian.",
)

# get multiple responses and see the difference
responses = llm.generate(
    user="Tell me a joke I haven't heard before!",
    samples=3,
)
print(responses)

# or have a multi-prompt chat interaction
llm.chat(user="Tell me a knock knock joke?")
llm.chat(user="Wait, I'm meant to say who's there!")
print(llm.history)

development

Clone the repository code:

git clone https://github.com/itsluketwist/llm-codegen-research.git

We use uv for project management. Once cloned, create a virtual environment and install uv and the project:

python -m venv .venv

. .venv/bin/activate

pip install uv

uv sync --extra api

Use make commands to lint and test:

make lint

make test

Use uv to add new dependencies into the project and uv.lock:

uv add openai

Or to upgrade dependencies:

uv sync --upgrade

Check typings with ty:

ty check

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

llm_codegen_research-2.10.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

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

llm_codegen_research-2.10-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file llm_codegen_research-2.10.tar.gz.

File metadata

  • Download URL: llm_codegen_research-2.10.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llm_codegen_research-2.10.tar.gz
Algorithm Hash digest
SHA256 d631f8b0d8002db45806d862d6a91b0d28f34a37108eaac7695c54c46988529d
MD5 58cfe7fcb802a3b70cc224dc9d911b08
BLAKE2b-256 380547bd9d461eca769ca7f88afccf9f2d79076912a249a09a3c1c33828be7cd

See more details on using hashes here.

File details

Details for the file llm_codegen_research-2.10-py3-none-any.whl.

File metadata

  • Download URL: llm_codegen_research-2.10-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for llm_codegen_research-2.10-py3-none-any.whl
Algorithm Hash digest
SHA256 2c2c60b637304c922dd952ceb6c7fb0b560023a6c2ea51b6a93380d271f2d0e9
MD5 50bb218cc35c545e7f342bbf56a47652
BLAKE2b-256 be05c338e74bcc352198e3744480400bca95e668f07fd647a194c93837d7ef15

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