Switch to vercel's biome setup (#543)

This commit is contained in:
Jared Palmer 2024-11-15 13:00:15 -05:00 committed by GitHub
parent b8643353c0
commit 43aa1c6e58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
52 changed files with 414 additions and 201 deletions

View file

@ -24,7 +24,7 @@ export const fetcher = async (url: string) => {
if (!res.ok) {
const error = new Error(
'An error occurred while fetching the data.'
'An error occurred while fetching the data.',
) as ApplicationError;
error.info = await res.json();
@ -64,7 +64,7 @@ function addToolMessageToChat({
...message,
toolInvocations: message.toolInvocations.map((toolInvocation) => {
const toolResult = toolMessage.content.find(
(tool) => tool.toolCallId === toolInvocation.toolCallId
(tool) => tool.toolCallId === toolInvocation.toolCallId,
);
if (toolResult) {
@ -85,7 +85,7 @@ function addToolMessageToChat({
}
export function convertToUIMessages(
messages: Array<DBMessage>
messages: Array<DBMessage>,
): Array<Message> {
return messages.reduce((chatMessages: Array<Message>, message) => {
if (message.role === 'tool') {
@ -127,7 +127,7 @@ export function convertToUIMessages(
}
export function sanitizeResponseMessages(
messages: Array<CoreToolMessage | CoreAssistantMessage>
messages: Array<CoreToolMessage | CoreAssistantMessage>,
): Array<CoreToolMessage | CoreAssistantMessage> {
const toolResultIds: Array<string> = [];
@ -151,7 +151,7 @@ export function sanitizeResponseMessages(
? toolResultIds.includes(content.toolCallId)
: content.type === 'text'
? content.text.length > 0
: true
: true,
);
return {
@ -161,7 +161,7 @@ export function sanitizeResponseMessages(
});
return messagesBySanitizedContent.filter(
(message) => message.content.length > 0
(message) => message.content.length > 0,
);
}
@ -182,7 +182,7 @@ export function sanitizeUIMessages(messages: Array<Message>): Array<Message> {
const sanitizedToolInvocations = message.toolInvocations.filter(
(toolInvocation) =>
toolInvocation.state === 'result' ||
toolResultIds.includes(toolInvocation.toolCallId)
toolResultIds.includes(toolInvocation.toolCallId),
);
return {
@ -194,7 +194,7 @@ export function sanitizeUIMessages(messages: Array<Message>): Array<Message> {
return messagesBySanitizedToolInvocations.filter(
(message) =>
message.content.length > 0 ||
(message.toolInvocations && message.toolInvocations.length > 0)
(message.toolInvocations && message.toolInvocations.length > 0),
);
}
@ -205,7 +205,7 @@ export function getMostRecentUserMessage(messages: Array<CoreMessage>) {
export function getDocumentTimestampByIndex(
documents: Array<Document>,
index: number
index: number,
) {
if (!documents) return new Date();
if (index > documents.length) return new Date();