lmstudio-ai / lmstudio-ai/lmstudio-python

Allow in-place Chat history editing

Open
#86 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
875
Forks
166
PR merge metrics
No merged PRs in 30d

Description

`lmstudio-js` supports in-place Chat history editing via:

* offering both mutable and immutable chat history and chat message instances via an internal mutability flag (using the [`MaybeMutable` base class](https://github.com/lmstudio-ai/lmstudio-js/blob/05df1a2284304e20ed931a125f5b4d06a21483df/packages/lms-client/src/Chat.ts#L369))
* the [`.replaceText()` method](https://github.com/lmstudio-ai/lmstudio-js/blob/05df1a2284304e20ed931a125f5b4d06a21483df/packages/lms-client/src/Chat.ts#L709) on saved messages (there are also `.appendFile()` and `appendText()` methods on messages)
* the [`.replaceSystemPrompt()` method](https://github.com/lmstudio-ai/lmstudio-js/blob/05df1a2284304e20ed931a125f5b4d06a21483df/packages/lms-client/src/Chat.ts#L369) to remove all previously added system prompt messages and insert the given prompt at the start of the chat history
* the [`.filterInPlace()` method](https://github.com/lmstudio-ai/lmstudio-js/blob/05df1a2284304e20ed931a125f5b4d06a21483df/packages/lms-client/src/Chat.ts#L375) to process all currently saved messages with the given filtering callback
* the [`.pop()` method](https://github.com/lmstudio-ai/lmstudio-js/blob/05df1a2284304e20ed931a125f5b4d06a21483df/packages/lms-client/src/Chat.ts#L221)
* supporting direct iteration over and indexed access to the messages saved in the chat history

The Python SDK should offer similar capabilities (although the exact spelling may differ).

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

Use the linked lmstudio-js Chat.ts implementation as the behavioral reference, then locate the corresponding chat history and message APIs in the Python SDK. Define how mutable and immutable instances, text replacement, system-prompt replacement, filtering, popping, iteration, and indexed access should work, and verify the completed behavior with the repository's existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.