Skip to content

Commit

Permalink
fix: make only last message of a run scorable
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Jul 12, 2024
1 parent aaebd3b commit a1ce820
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 158 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Nothing unreleased!
- disable_feedback has been removed
- root_message has been removed

## [1.1.306] - 2024-07-03

### Added

- Messages are now editable. You can disable this feature with `config.features.edit_message = false`
Expand Down
62 changes: 0 additions & 62 deletions cypress/e2e/video_element/.chainlit/config.toml

This file was deleted.

46 changes: 0 additions & 46 deletions cypress/e2e/video_element/main.py

This file was deleted.

45 changes: 0 additions & 45 deletions cypress/e2e/video_element/spec.cy.ts

This file was deleted.

4 changes: 3 additions & 1 deletion frontend/src/components/molecules/messages/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface Props {
actions: IAction[];
indent: number;
isRunning?: boolean;
isScorable?: boolean;
scorableRun?: IStep;
}

Expand All @@ -39,6 +40,7 @@ const Message = memo(
actions,
isRunning,
indent,
isScorable,
scorableRun
}: Props) => {
const {
Expand Down Expand Up @@ -175,7 +177,7 @@ const Message = memo(
{actions?.length ? (
<MessageActions message={message} actions={actions} />
) : null}
{scorableRun ? (
{scorableRun && isScorable ? (
<MessageButtons message={message} run={scorableRun} />
) : null}
</Stack>
Expand Down
15 changes: 11 additions & 4 deletions frontend/src/components/molecules/messages/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ const Messages = memo(
const { config } = useConfig();
return (
<>
{messages.map((m) => {
{messages.map((m, mIndex) => {
if (CL_RUN_NAMES.includes(m.name)) {
const isRunning = !m.end && !m.isError && messageContext.loading;
const showLoader =
config?.ui.cot === 'tool_call'
? isRunning && !hasToolStep(m)
: !m.steps?.length && isRunning;
const scorableRun =
!isRunning && m.name !== 'on_chat_start' ? m : undefined;
return (
<>
{m.steps?.length ? (
Expand All @@ -49,15 +51,19 @@ const Messages = memo(
actions={actions}
indent={indent}
isRunning={isRunning}
scorableRun={
!isRunning && m.name !== 'on_chat_start' ? m : undefined
}
scorableRun={scorableRun}
/>
) : null}
<MessageLoader show={showLoader} />
</>
);
} else {
const isScorable =
mIndex ===
scorableRun?.steps?.findLastIndex(
(_m) => _m.type === 'assistant_message'
);

return (
<Message
message={m}
Expand All @@ -67,6 +73,7 @@ const Messages = memo(
indent={indent}
isRunning={isRunning}
scorableRun={scorableRun}
isScorable={isScorable}
/>
);
}
Expand Down

0 comments on commit a1ce820

Please sign in to comment.