Git Product home page Git Product logo

Comments (7)

simonw avatar simonw commented on May 27, 2024

Current schema:

% sqlite-utils schema "$(llm logs path)"
CREATE TABLE [_llm_migrations] (
   [name] TEXT PRIMARY KEY,
   [applied_at] TEXT
);
CREATE TABLE "log" (
   [id] INTEGER PRIMARY KEY,
   [model] TEXT,
   [timestamp] TEXT,
   [prompt] TEXT,
   [system] TEXT,
   [response] TEXT,
   [chat_id] INTEGER REFERENCES [log]([id])
);

from llm.

simonw avatar simonw commented on May 27, 2024

There's other data about individual runs that I'm interested in storing. For non-streaming responses from OpenAI I get back this:

  "created": 1686896201,
  "id": "chatcmpl-7Rx3BL9grubSusAyCEiRoJta8vEh7",
  "model": "gpt-3.5-turbo-0301",
  "object": "chat.completion",
  "usage": {
    "completion_tokens": 399,
    "prompt_tokens": 15,
    "total_tokens": 414
  }
}

I don't think I get the "usage" block for streaming responses, which is annoying.

from llm.

simonw avatar simonw commented on May 27, 2024

I have another feature in the pipeline that will use a different model from the requested one:

That may want to store "user requested 'auto' but we ran gpt-4-32k." But that's evev more confusing, because there are actually three models there - auto was requested, gpt-4-32k was then selected, but gpt-4-32k-0601 or whatever was actually executed.

I think in that case I don't actually care that they said "auto".

from llm.

simonw avatar simonw commented on May 27, 2024

I'm going to add a duration_ms integer column to store the duration of the prompt, and a debug column which I'll dump JSON into with model-specific debug things - that's usage and model for the OpenAI ones and who-knows-what for the other models.

from llm.

simonw avatar simonw commented on May 27, 2024
@migration
def m005_debug(db):
    db["log"].add_column("debug", str)
    db["log"].add_column("duration_ms", int)

from llm.

simonw avatar simonw commented on May 27, 2024

Example output:

% llm logs
[
  {
    "id": 435,
    "model": "gpt-3.5-turbo",
    "timestamp": "2023-06-16 07:46:45.781006",
    "prompt": "say one duration",
    "system": null,
    "response": "1 hour",
    "chat_id": null,
    "debug": "{\"model\": \"gpt-3.5-turbo-0301\"}",
    "duration_ms": 820
  },
  {
    "id": 434,
    "model": "gpt-3.5-turbo",
    "timestamp": "2023-06-16 07:46:42.106479",
    "prompt": "say one duration",
    "system": null,
    "response": "One hour.",
    "chat_id": null,
    "debug": "{\"model\": \"gpt-3.5-turbo-0301\", \"usage\": {\"prompt_tokens\": 11, \"completion_tokens\": 3, \"total_tokens\": 14}}",
    "duration_ms": 1364
  },

from llm.

simonw avatar simonw commented on May 27, 2024

Updated schema: https://llm.datasette.io/en/latest/logging.html#sql-schema

from llm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.