[chore] eslint fixes

This commit is contained in:
Cohee 2024-11-18 21:29:56 +02:00
parent c3483bc432
commit 3b03f07ebf

View File

@ -722,7 +722,7 @@ export function convertTextCompletionPrompt(messages) {
export function cachingAtDepthForClaude(messages, cachingAtDepth) { export function cachingAtDepthForClaude(messages, cachingAtDepth) {
let passedThePrefill = false; let passedThePrefill = false;
let depth = 0; let depth = 0;
let previousRoleName = ""; let previousRoleName = '';
for (let i = messages.length - 1; i >= 0; i--) { for (let i = messages.length - 1; i >= 0; i--) {
if (!passedThePrefill && messages[i].role === 'assistant') { if (!passedThePrefill && messages[i].role === 'assistant') {
@ -734,7 +734,7 @@ export function cachingAtDepthForClaude(messages, cachingAtDepth) {
if (messages[i].role !== previousRoleName) { if (messages[i].role !== previousRoleName) {
if (depth === cachingAtDepth || depth === cachingAtDepth + 2) { if (depth === cachingAtDepth || depth === cachingAtDepth + 2) {
const content = messages[i].content; const content = messages[i].content;
content[content.length - 1].cache_control = {type: "ephemeral"}; content[content.length - 1].cache_control = { type: 'ephemeral' };
} }
if (depth === cachingAtDepth + 2) { if (depth === cachingAtDepth + 2) {
@ -758,7 +758,7 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth) {
let passedThePrefill = false; let passedThePrefill = false;
//depth here is the number of message role switches //depth here is the number of message role switches
let depth = 0; let depth = 0;
let previousRoleName = ""; let previousRoleName = '';
for (let i = messages.length - 1; i >= 0; i--) { for (let i = messages.length - 1; i >= 0; i--) {
if (!passedThePrefill && messages[i].role === 'assistant') { if (!passedThePrefill && messages[i].role === 'assistant') {
continue; continue;
@ -773,18 +773,18 @@ export function cachingAtDepthForOpenRouterClaude(messages, cachingAtDepth) {
messages[i].content = [{ messages[i].content = [{
type: 'text', type: 'text',
text: content, text: content,
cache_control: {type: "ephemeral"}, cache_control: { type: 'ephemeral' },
}]; }];
} else { } else {
const contentPartCount = content.length; const contentPartCount = content.length;
content[contentPartCount - 1].cache_control = { content[contentPartCount - 1].cache_control = {
type: "ephemeral" type: 'ephemeral',
} };
} }
} }
if (depth === cachingAtDepth + 2) { if (depth === cachingAtDepth + 2) {
break break;
} }
depth += 1; depth += 1;