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

usage

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

export OPENAI_API_KEY=...
export ANTHROPIC_API_KEY=...
export TOGETHER_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

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

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-1.10.tar.gz (15.8 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-1.10-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llm_codegen_research-1.10.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.10

File hashes

Hashes for llm_codegen_research-1.10.tar.gz
Algorithm Hash digest
SHA256 ea6c4dc532cf86469af72f072ca6d9800125fb71a841283ca9bda87ffbfed703
MD5 353c06d5253326d3d499e84dfadfdb36
BLAKE2b-256 08055b60c8a44a9079dc1a3a4edd3ced6f5f6ca46d0d29c2217c4cf4e2526d36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for llm_codegen_research-1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 116779e965c7188d3498d92d5ca1a632e67d56cb671e037b4c68ecd626ac96d5
MD5 f30d66923681abf47ce9ec8abea82de6
BLAKE2b-256 3a1cd3086973bf126b41006030ea75ed2581ef88eaff34c2488694f2c57c28df

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