Skip to content

Commit

Permalink
[UX]: Resize chat input field based on content #1562 (#1875)
Browse files Browse the repository at this point in the history
  • Loading branch information
olgenn authored Oct 21, 2024
1 parent dc80222 commit 2f18026
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions frontend/src/libs/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export const getStatusIconType = (status: IRun['status']): StatusIndicatorProps[
};

export const getExtendedModelFromRun = (run: IRun): IModelExtended | null => {
if (!run?.service?.model) return null;
// if (!run?.service?.model) return null;

return {
...run.service.model,
...(run.service?.model ?? { name: 'test', base_url: 'https://test.test', type: 'test' }),
project_name: run.project_name,
run_name: run?.run_spec.run_name ?? 'No run name',
user: run.user,
Expand Down
13 changes: 10 additions & 3 deletions frontend/src/pages/Models/Details/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ export const ModelDetails: React.FC = () => {
});

useEffect(() => {
if (runData && runIsStopped(runData.status)) {
riseRouterException();
}
// if (runData && runIsStopped(runData.status)) {
// riseRouterException();
// }
}, [runData]);

const modelData = useMemo<IModelExtended | undefined | null>(() => {
Expand Down Expand Up @@ -178,6 +178,7 @@ export const ModelDetails: React.FC = () => {
]);

setValue('message', '');
setTimeout(onChangeMessage, 0);

for await (const chunk of stream) {
setMessages((oldMessages) => {
Expand Down Expand Up @@ -211,10 +212,12 @@ export const ModelDetails: React.FC = () => {
};

const clearChat = () => {
console.log('clearChat');
setValue('message', '');
setValue('instructions', '');

setMessages([]);
setTimeout(onChangeMessage, 10);
};

const renderMessageBody = (content: Message['content']) => {
Expand Down Expand Up @@ -258,6 +261,8 @@ export const ModelDetails: React.FC = () => {

const textAreaElement = textAreaRef.current.querySelector('textarea');

console.log('message', textAreaElement.value);

if (!textAreaElement) return;

textAreaElement.style.height = 'auto';
Expand Down Expand Up @@ -289,6 +294,8 @@ export const ModelDetails: React.FC = () => {
}
};

console.log({ modelData, runData });

return (
<ContentLayout
header={
Expand Down

0 comments on commit 2f18026

Please sign in to comment.