Skip to content

Commit

Permalink
Merge pull request #739 from StampyAI/sundry-fixes
Browse files Browse the repository at this point in the history
fix chrome bug
  • Loading branch information
bryceerobertson authored Jun 19, 2024
2 parents 8ae392e + 343f4dd commit ebe2746
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/hooks/useChat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const ignoreAbort = (error: Error) => {
if (error.name !== 'AbortError') {
throw error
}
console.log(error)
}

export async function* iterateData(res: Response) {
Expand Down Expand Up @@ -240,6 +241,17 @@ export const extractAnswer = async (
return {result, followups}
}

const makePayload = (
sessionId: string | undefined,
history: HistoryEntry[],
settings?: ChatSettings
): string => {
const payload = JSON.stringify({sessionId, history, settings})
if (payload.length < 70000) return payload
if (history.length === 1) throw 'You question is too long - please shorten it'
return makePayload(sessionId, history.slice(1), settings)
}

const fetchLLM = async (
sessionId: string | undefined,
history: HistoryEntry[],
Expand All @@ -255,7 +267,7 @@ const fetchLLM = async (
'Content-Type': 'application/json',
Accept: 'text/event-stream',
},
body: JSON.stringify({sessionId, history, settings}),
body: makePayload(sessionId, history, settings),
}).catch(ignoreAbort)

export const queryLLM = async (
Expand Down

0 comments on commit ebe2746

Please sign in to comment.