Skip to content

Studio: import ShareGPT chats with the right roles - #11149

Merged
Lyxot merged 3 commits into
unslothai:mainfrom
NilayYadav:studio-sharegpt-import-roles
Sep 17, 2026
Merged

Lyxot merged 3 commits into
unslothai:mainfrom
NilayYadav:studio-sharegpt-import-roles

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Importing a ShareGPT file only recognised from: "human" and "system". Anything else, including "user", became an assistant message, so the whole chat looked like the model talking to itself.

The import now trims and lowercases the from value and maps human and user to user, gpt and assistant to assistant, and system to system. Unknown values still become assistant as before.

Tested with a new unit test and by importing user/assistant, human/gpt and mixed case files through Projects > Import chats. Roles are correct on screen and in the saved thread.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-16T20:56:37.787751Z 1ab8cfa Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1ab8cfa31a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Review + UI evidence

Pinned head: b329364ee7 (PR commit 1ab8cfa31a + pre-commit.ci formatting). Codex reviewed 1ab8cfa31a with no major issues, and my own review found no P1/P2/P3 items.

I imported the same ShareGPT JSONL file through Projects > Import chats on two Studio builds, one from the merge base b802399461 and one from the PR head. Both ran in the same CPU container (install.sh --local --no-torch, frontend rebuilt for each side, Chromium 1280x900, no model). The roles below were read back from /api/chat/threads/{id}/messages.

File from values: system, user, assistant, User, assistant

Before (merge base) After (PR head)
Stored roles system, assistant, assistant, assistant, assistant system, user, assistant, user, assistant
Rows on screen 0 user / 5 assistant 2 user / 3 assistant
Control file (human/gpt) user, assistant user, assistant

PR 11149 before/after

Unit test A/B, running the PR's tests/message-jsonl-import.test.ts:

  • Merge-base chat-import.ts: fails. It gets [system, assistant, assistant, assistant, assistant, assistant, assistant] but expects [system, user, assistant, user, assistant, user, assistant].
  • PR head: passes.

Conclusion: Before the fix, importing a user/assistant ShareGPT file stored every turn as assistant. The fix maps those roles correctly and leaves the human/gpt behaviour unchanged.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed this hits chat-import.ts where any from other than human or system is stored as assistant, so a user/assistant ShareGPT file imports as one long assistant monologue, and the before/after import you posted matches what I see. Will get this reviewed.

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

Confirmed this hits chat-import.ts where any from other than human or system is stored as assistant, so a user/assistant ShareGPT file imports as one long assistant monologue, and the before/after import you posted matches what I see. Will get this reviewed.

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Lyxot

Lyxot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

@codex review

1 similar comment
@Lyxot

Lyxot commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@Lyxot
Lyxot merged commit 9138eb9 into unslothai:main Sep 17, 2026
45 of 46 checks passed
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
* Studio: map ShareGPT user/assistant roles on chat import

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Lyxot <[email protected]>
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.

3 participants