Skip to main content
Glama
MessagesList.tsx1.44 kB
import { Loader } from '@intlayer/design-system'; import { type FC, useEffect, useRef } from 'react'; import { ChatBumble, ChatBumbleType } from './ChatBumble'; export type ChatCompletionRequestMessage = { role: 'system' | 'user' | 'assistant'; content: string; timestamp?: Date; }; export type MessagesListProps = { storedPrompt: ChatCompletionRequestMessage[]; isLoading: boolean; }; export const MessagesList: FC<MessagesListProps> = ({ storedPrompt, isLoading, }) => { const lastPrompt = storedPrompt[storedPrompt.length - 1]; const chatContainerRef = useRef<HTMLDivElement>(null); useEffect(() => { if (lastPrompt?.role === 'user') { // Scroll to the end chatContainerRef.current?.scrollTo({ top: chatContainerRef.current.scrollHeight, behavior: 'smooth', }); } }, [lastPrompt]); return ( <div className="relative flex max-h-full flex-1 flex-col gap-4 overflow-auto pt-5" ref={chatContainerRef} > {storedPrompt.map((promt, index) => ( <ChatBumble key={index} type={ promt.role === 'user' ? ChatBumbleType.QUESTION : ChatBumbleType.ANSWER } > {promt.content} </ChatBumble> ))} <Loader isLoading={isLoading} className="sticky bottom-0 left-0 m-auto h-14 w-auto rounded-full p-2" /> </div> ); };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/aymericzip/intlayer'

If you have feedback or need assistance with the MCP directory API, please join our Discord server