Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Look up events in local LLM. #226

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

MatthewKhouzam
Copy link
Contributor

What it does

Adds a context menu to the events table if there's a local ollama running.

How to test

Install ollama. Install llama3.2 (ollama pull llama3.2). ollama serve. Then run it and right click on a row.

Follow-ups

Review checklist

  • As an author, I have thoroughly tested my changes and carefully followed the instructions in this template

Addresses bug 211

[Added] Ability to have background markers

Change-Id: Ie681f5577b5e9abdb8ebeb75c456f860625af1cb
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
The original alpha made it harder to read.

[Changed] reduced default alpha on bookmarks

Change-Id: I692d19d51bef2fa4bf41b3b763e21547b89e9444
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
[added] TraceGPT

Change-Id: I5dc5e397c0034eebb21860d64ffca90906e95a51
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
@MatthewKhouzam MatthewKhouzam force-pushed the cat_i_farted_but_in_french branch from eeb5b46 to f46e327 Compare February 26, 2025 03:17
Copy link

@HishamLadha HishamLadha left a comment

Choose a reason for hiding this comment

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

Overall, this is amazing 💯 I just added a couple of comments and potential room for improvement!

@@ -1282,6 +1294,106 @@ public void run() {
builder -> builder.setSynchronized(isChecked()));
}
};
String ollamaUrl = "http://localhost:11434";
final IAction lookupInLLMAction = new Action("Lookup in local LLM", IAction.AS_PUSH_BUTTON) {

Choose a reason for hiding this comment

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

Could change "Lookup in local LLM" to be "Explain event with local LLM" to make it more descriptive to a user.

values.put(column.getText(), fTable.getSelection()[0].getText(i));
}
}
Job jerb = new Job("llm") {

Choose a reason for hiding this comment

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

Could change "llm" to be "LLM Event Lookup" :)

JSONObject jsonObj = new JSONObject(response.toString());
String data = String.valueOf(jsonObj.get("response"));
IProject project = fTrace.getResource().getProject();
IFile file = project.getFile("event.txt");

Choose a reason for hiding this comment

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

  • Naming of the file could be more specific as this gets overwritten every time.
  • I suggest that the current time could be added to each event text file like this:

IFile file = project.getFile("event_" + System.currentTimeMillis() + ".txt");

JSONObject jsonPayload = new JSONObject();
jsonPayload.put("model", "llama3.2"); // Specify the
// model
jsonPayload.put("prompt", "I have an event from a trace of type " + trace.getTraceTypeId() + " in that there is an event content " + values.toString() + " explain it."); // Your

Choose a reason for hiding this comment

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

  • I love this. However, I think this can be improved to make it easier for the LLM to parse particularly because LLMs love a specific format like this:
Explain the following trace event:
Trace Type: org.eclipse.tracecompass.some.type
Event Details:
- Timestamp: 123456789
- Event Name: ThreadStart
- PID: 12
  • I think a format similar to the one below could be used and I have drafted up a quick mockup of how this could look. However, I haven't tested the following code:
StringBuilder prompt = new StringBuilder();
prompt.append("Explain the following trace event:\n");
prompt.append("Trace Type: ").append(trace.getTraceTypeId()).append("\n");
prompt.append("Event Details:\n");
for (Map.Entry<String, String> entry : values.entrySet()) {
    prompt.append("- ").append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
}
jsonPayload.put("prompt", prompt.toString());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants