Skip to content

Conversation

@richiejp
Copy link
Collaborator

@richiejp richiejp commented Dec 16, 2025

Description

When creating a data set for fine-tuning or debugging an agent, it is useful to be able to see a log of the requests and responses that took place. LocalAI currently has a text log However, this contains a lot of information in addition to the data which these use cases require.

There are many different ways in which we could record requests made to LocalAI. Including a proxy server that wouldn't require any changes to LocalAI or the client application.

However, this is another component that users must install and configure. In addition, a separate component cannot be used as the basis for further local AI features, For example we could add a button that replays requests.

This initial pull request, however, is very simple. It just adds the ability to trace requests and responses, logging them in memory. They can then be fetched through an API endpoint. It's not enabled by default.

Notes for Reviewers

  • Fix incomplete template error in UI
  • Export to JSON
  • Add to navbar
  • Drop old entries after a maximum size is reached
  • Add runtime menu setting
    • Is performance category appropriate?

Signed commits

  • Yes, I signed my commits.

@netlify
Copy link

netlify bot commented Dec 16, 2025

Deploy Preview for localai ready!

Name Link
🔨 Latest commit 3b5e6ae
🔍 Latest deploy log https://app.netlify.com/projects/localai/deploys/69456eb72b7ae40008cc1f25
😎 Deploy Preview https://deploy-preview-7609--localai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Signed-off-by: Richard Palethorpe <io@richiejp.com>
@richiejp richiejp force-pushed the feat/tracing branch 2 times, most recently from 2faacc1 to 670ae28 Compare December 17, 2025 17:01
function tracesApp() {
return {
traces: [],
selectedTrace: null,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also have an "export" to save as a jsonfile or either have a dump of the whole memory?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implemented as a JSON file. The body of the message is base64 encoded which could be inconvenient, but most of the time I would convert it to Parquet anyway.

go func() {
for exchange := range logChan {
mu.Lock()
apiLogs = append(apiLogs, exchange)
Copy link
Owner

@mudler mudler Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this would at least need some guard, e.g. a max limit that we default with, and keeps only the latest "X" fresh conversation. Just to avoid we don't keep growing in memory indefinetly

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented in a circle buffer. The max number of items are configurable.

UploadLimitMB, Threads, ContextSize int
F16 bool
Debug bool
EnableTracing bool
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be as well a runtime setting?

@@ -0,0 +1,184 @@
<!DOCTYPE html>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an open point: how the user reaches this page? should it be in the navbar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether it should go at the top level of the navbar, or whether it should go in a new menu. I think it is most similar to the system page because they both deal with monitoring.

@richiejp richiejp force-pushed the feat/tracing branch 3 times, most recently from 47a9fa2 to c428e40 Compare December 18, 2025 16:27
Signed-off-by: Richard Palethorpe <io@richiejp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants