-
Notifications
You must be signed in to change notification settings - Fork 19
feat(chat-messages): add inline source citation #2099
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
Draft
robertwilde
wants to merge
1
commit into
main
Choose a base branch
from
feat/ai/citation-pills
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...pshots/si-chat-messages--si-ai-message-element-examples-chromium-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...shots/si-chat-messages--si-ai-message-element-examples-chromium-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ts/si-chat-messages--si-chat-container-element-examples-chromium-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...s/si-chat-messages--si-chat-container-element-examples-chromium-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
projects/element-ng/chat-messages/si-ai-message.component.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
projects/element-ng/chat-messages/si-annotated-text.model.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * Copyright (c) Siemens 2016 - 2026 | ||
| * SPDX-License-Identifier: MIT | ||
| */ | ||
|
|
||
| /** A single source citation referenced within an AI message. */ | ||
| export interface SiChatCitation { | ||
| /** Unique identifier used to match citation segments to this citation. */ | ||
| id: string; | ||
| /** Human-readable title of the source (e.g. page title or document name). */ | ||
| title: string; | ||
| /** Optional URL to the original source. */ | ||
| url?: string; | ||
| } | ||
|
|
||
| /** A plain-text run within an annotated message. */ | ||
| export interface SiChatTextRun { | ||
| type: 'text'; | ||
| content: string; | ||
| } | ||
|
|
||
| /** A citation placeholder within an annotated message that maps to a {@link SiChatCitation}. */ | ||
| export interface SiChatCitationRun { | ||
| type: 'citation'; | ||
| citationId: string; | ||
| } | ||
|
|
||
| export type SiChatTextSegment = SiChatTextRun | SiChatCitationRun; | ||
|
|
||
| /** | ||
| * Normalized representation of an AI message that contains inline citations. | ||
| * | ||
| * Produced by helper functions such as `parseCitationMarkers` or | ||
| * `parseCitationOffsets` and consumed by {@link SiAiMessageComponent} via its | ||
| * `annotatedText` input. | ||
| */ | ||
| export interface SiChatAnnotatedText { | ||
| /** Ordered segments that make up the full message content. */ | ||
| segments: SiChatTextSegment[]; | ||
| /** All citations referenced by the segments. */ | ||
| citations: SiChatCitation[]; | ||
| } |
42 changes: 42 additions & 0 deletions
42
projects/element-ng/chat-messages/si-citation-pill.component.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| @use 'sass:map'; | ||
| @use '@siemens/element-theme/src/styles/variables'; | ||
|
|
||
| :host { | ||
| display: inline; | ||
| margin-inline: map.get(variables.$spacers, 3); | ||
| } | ||
|
|
||
| .citation-pill { | ||
| display: inline-flex; | ||
| align-items: center; | ||
| gap: 0.25rem; | ||
| padding-block: 0; | ||
| padding-inline: 0.375rem; | ||
| block-size: 20px; | ||
| box-sizing: border-box; | ||
| border: 1px solid variables.$element-ui-3; | ||
| border-radius: 9999px; | ||
| color: variables.$element-text-primary; | ||
| background: transparent; | ||
| font-size: 0.75rem; | ||
| line-height: 1; | ||
| font-weight: 400; | ||
| cursor: pointer; | ||
| text-decoration: none; | ||
| vertical-align: middle; | ||
| white-space: nowrap; | ||
| transition: background 0.15s ease; | ||
|
|
||
| &:hover, | ||
| &:active { | ||
| background: variables.$element-base-1-hover; | ||
| border-color: variables.$element-ui-3; | ||
| color: variables.$element-text-primary; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| &:focus-visible { | ||
| outline: 2px solid variables.$element-focus-default; | ||
| outline-offset: 2px; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.