Ran prettier formatting

This commit is contained in:
Willie Zutz
2025-04-20 13:12:23 -06:00
parent 67ee9eff53
commit 59a10d7d00
7 changed files with 55 additions and 46 deletions

View File

@@ -234,7 +234,7 @@ export const POST = async (req: Request) => {
}) as unknown as BaseChatModel; }) as unknown as BaseChatModel;
} else if (chatModelProvider && chatModel) { } else if (chatModelProvider && chatModel) {
llm = chatModel.model; llm = chatModel.model;
// Set context window size for Ollama models // Set context window size for Ollama models
if (llm instanceof ChatOllama && body.chatModel?.provider === 'ollama') { if (llm instanceof ChatOllama && body.chatModel?.provider === 'ollama') {
llm.numCtx = body.chatModel.ollamaContextWindow || 2048; llm.numCtx = body.chatModel.ollamaContextWindow || 2048;

View File

@@ -98,7 +98,7 @@ export const POST = async (req: Request) => {
llm = chatModelProviders[chatModelProvider][chatModel] llm = chatModelProviders[chatModelProvider][chatModel]
.model as unknown as BaseChatModel | undefined; .model as unknown as BaseChatModel | undefined;
} }
if (llm instanceof ChatOllama && body.chatModel?.provider === 'ollama') { if (llm instanceof ChatOllama && body.chatModel?.provider === 'ollama') {
llm.numCtx = body.chatModel.ollamaContextWindow || 2048; llm.numCtx = body.chatModel.ollamaContextWindow || 2048;
} }

View File

@@ -337,7 +337,7 @@ const ChatWindow = ({ id }: { id?: string }) => {
} }
}, [isMessagesLoaded, isConfigReady]); }, [isMessagesLoaded, isConfigReady]);
const sendMessage = async ( const sendMessage = async (
message: string, message: string,
messageId?: string, messageId?: string,
options?: { rewriteIndex?: number }, options?: { rewriteIndex?: number },
@@ -359,10 +359,13 @@ const sendMessage = async (
if (options?.rewriteIndex !== undefined) { if (options?.rewriteIndex !== undefined) {
const rewriteIndex = options.rewriteIndex; const rewriteIndex = options.rewriteIndex;
setMessages((prev) => { setMessages((prev) => {
return [...prev.slice(0, messages.length > 2 ? rewriteIndex - 1 : 0)] return [...prev.slice(0, messages.length > 2 ? rewriteIndex - 1 : 0)];
}); });
messageChatHistory = chatHistory.slice(0, messages.length > 2 ? rewriteIndex - 1 : 0) messageChatHistory = chatHistory.slice(
0,
messages.length > 2 ? rewriteIndex - 1 : 0,
);
setChatHistory(messageChatHistory); setChatHistory(messageChatHistory);
} }
@@ -480,7 +483,8 @@ const sendMessage = async (
} }
}; };
const ollamaContextWindow = localStorage.getItem('ollamaContextWindow') || '2048'; const ollamaContextWindow =
localStorage.getItem('ollamaContextWindow') || '2048';
const res = await fetch('/api/chat', { const res = await fetch('/api/chat', {
method: 'POST', method: 'POST',
@@ -542,9 +546,13 @@ const sendMessage = async (
}; };
const rewrite = (messageId: string) => { const rewrite = (messageId: string) => {
const messageIndex = messages.findIndex((msg) => msg.messageId === messageId); const messageIndex = messages.findIndex(
if(messageIndex == -1) return; (msg) => msg.messageId === messageId,
sendMessage(messages[messageIndex - 1].content, messageId, { rewriteIndex: messageIndex }); );
if (messageIndex == -1) return;
sendMessage(messages[messageIndex - 1].content, messageId, {
rewriteIndex: messageIndex,
});
}; };
useEffect(() => { useEffect(() => {

View File

@@ -77,7 +77,9 @@ const MessageInput = ({
}} }}
className={cn( className={cn(
'bg-light-secondary dark:bg-dark-secondary p-4 flex items-center border border-light-200 dark:border-dark-200', 'bg-light-secondary dark:bg-dark-secondary p-4 flex items-center border border-light-200 dark:border-dark-200',
mode === 'multi' ? 'flex-col rounded-lg' : 'flex-col md:flex-row rounded-lg md:rounded-full', mode === 'multi'
? 'flex-col rounded-lg'
: 'flex-col md:flex-row rounded-lg md:rounded-full',
)} )}
> >
{mode === 'single' && ( {mode === 'single' && (
@@ -130,7 +132,7 @@ const MessageInput = ({
</div> </div>
)} )}
</div> </div>
{mode === 'multi' && ( {mode === 'multi' && (
<div className="flex flex-col md:flex-row items-start md:items-center justify-between w-full pt-2"> <div className="flex flex-col md:flex-row items-start md:items-center justify-between w-full pt-2">
<div className="flex flex-row items-center justify-between w-full md:w-auto mb-2 md:mb-0"> <div className="flex flex-row items-center justify-between w-full md:w-auto mb-2 md:mb-0">

View File

@@ -35,12 +35,11 @@ const OptimizationModes = [
const Optimization = ({ const Optimization = ({
optimizationMode, optimizationMode,
setOptimizationMode setOptimizationMode,
}: { }: {
optimizationMode: string; optimizationMode: string;
setOptimizationMode: (mode: string) => void; setOptimizationMode: (mode: string) => void;
}) => { }) => {
const handleOptimizationChange = (mode: string) => { const handleOptimizationChange = (mode: string) => {
setOptimizationMode(mode); setOptimizationMode(mode);
localStorage.setItem('optimizationMode', mode); localStorage.setItem('optimizationMode', mode);

View File

@@ -46,20 +46,20 @@ const SearchImages = ({
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },
body: JSON.stringify({ body: JSON.stringify({
query: query, query: query,
chatHistory: chatHistory, chatHistory: chatHistory,
chatModel: { chatModel: {
provider: chatModelProvider, provider: chatModelProvider,
model: chatModel, model: chatModel,
...(chatModelProvider === 'custom_openai' && { ...(chatModelProvider === 'custom_openai' && {
customOpenAIBaseURL: customOpenAIBaseURL, customOpenAIBaseURL: customOpenAIBaseURL,
customOpenAIKey: customOpenAIKey, customOpenAIKey: customOpenAIKey,
}), }),
...(chatModelProvider === 'ollama' && { ...(chatModelProvider === 'ollama' && {
ollamaContextWindow: parseInt(ollamaContextWindow), ollamaContextWindow: parseInt(ollamaContextWindow),
}), }),
}, },
}), }),
}); });
const data = await res.json(); const data = await res.json();

View File

@@ -56,25 +56,25 @@ const Searchvideos = ({
localStorage.getItem('ollamaContextWindow') || '2048'; localStorage.getItem('ollamaContextWindow') || '2048';
const res = await fetch(`/api/videos`, { const res = await fetch(`/api/videos`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
},
body: JSON.stringify({
query: query,
chatHistory: chatHistory,
chatModel: {
provider: chatModelProvider,
model: chatModel,
...(chatModelProvider === 'custom_openai' && {
customOpenAIBaseURL: customOpenAIBaseURL,
customOpenAIKey: customOpenAIKey,
}),
...(chatModelProvider === 'ollama' && {
ollamaContextWindow: parseInt(ollamaContextWindow),
}),
}, },
body: JSON.stringify({ }),
query: query,
chatHistory: chatHistory,
chatModel: {
provider: chatModelProvider,
model: chatModel,
...(chatModelProvider === 'custom_openai' && {
customOpenAIBaseURL: customOpenAIBaseURL,
customOpenAIKey: customOpenAIKey,
}),
...(chatModelProvider === 'ollama' && {
ollamaContextWindow: parseInt(ollamaContextWindow),
}),
},
}),
}); });
const data = await res.json(); const data = await res.json();