simonw / simonw/llm

Use condense_json() to make response logging more efficient

Open
#760 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement logging
Dominant language
Python
Stars
12.5k
Forks
998
Avg merge
3d 13h
Merged PRs (30d)
10

Description

Most database log entries currently contain both the prompt and the response twice:

llm logs -c --json
[
  {
    "id": "01jmddkan06b0568gjk90k134t",
    "model": "gpt-4o-mini",
    "prompt": "say hi",
    "system": null,
    "prompt_json": {
      "messages": [
        {
          "role": "user",
          "content": "say hi"
        }
      ]
    },
    "options_json": {},
    "response": "Hi there! How can I assist you today?",
    "response_json": {
      "content": "Hi there! How can I assist you today?",
      "finish_reason": "stop",

My new https://github.com/simonw/condense-json library - initially built for #617 - could help here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the llm logs -c --json entry point and inspect how database log records are assembled. Use the referenced condense-json library to avoid duplicating prompt and response data, then verify that the JSON output remains correct and no longer repeats those fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.