mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-26 13:18:51 +01:00
✨ feat: Add Google Parameters, Ollama/Openrouter Reasoning, & UI Optimizations (#5456)
* feat: Google Model Parameters * fix: dynamic input number value, previously coerced by zod schema * refactor: support openrouter reasoning tokens and XML for thinking directive to conform to ollama * fix: virtualize combobox to prevent performance drop on re-renders of long model/agent/assistant lists * refactor: simplify Fork component by removing unnecessary chat context index * fix: prevent rendering of Thinking component when children are null * refactor: update Markdown component to replace <think> tags and simplify remarkPlugins configuration * refactor: reorder remarkPlugins to improve plugin configuration in Markdown component
This commit is contained in:
parent
7818ae5c60
commit
af430e46f4
12 changed files with 200 additions and 50 deletions
|
|
@ -1253,6 +1253,12 @@ ${convo}
|
|||
delete modelOptions.stop;
|
||||
}
|
||||
|
||||
let reasoningKey = 'reasoning_content';
|
||||
if (this.useOpenRouter) {
|
||||
modelOptions.include_reasoning = true;
|
||||
reasoningKey = 'reasoning';
|
||||
}
|
||||
|
||||
if (modelOptions.stream) {
|
||||
streamPromise = new Promise((resolve) => {
|
||||
streamResolve = resolve;
|
||||
|
|
@ -1291,14 +1297,14 @@ ${convo}
|
|||
|
||||
let reasoningCompleted = false;
|
||||
for await (const chunk of stream) {
|
||||
if (chunk?.choices?.[0]?.delta?.reasoning_content) {
|
||||
if (chunk?.choices?.[0]?.delta?.[reasoningKey]) {
|
||||
if (reasoningTokens.length === 0) {
|
||||
const thinkingDirective = ':::thinking\n';
|
||||
const thinkingDirective = '<think>\n';
|
||||
intermediateReply.push(thinkingDirective);
|
||||
reasoningTokens.push(thinkingDirective);
|
||||
onProgress(thinkingDirective);
|
||||
}
|
||||
const reasoning_content = chunk?.choices?.[0]?.delta?.reasoning_content || '';
|
||||
const reasoning_content = chunk?.choices?.[0]?.delta?.[reasoningKey] || '';
|
||||
intermediateReply.push(reasoning_content);
|
||||
reasoningTokens.push(reasoning_content);
|
||||
onProgress(reasoning_content);
|
||||
|
|
@ -1307,7 +1313,7 @@ ${convo}
|
|||
const token = chunk?.choices?.[0]?.delta?.content || '';
|
||||
if (!reasoningCompleted && reasoningTokens.length > 0 && token) {
|
||||
reasoningCompleted = true;
|
||||
const separatorTokens = '\n:::\n';
|
||||
const separatorTokens = '\n</think>\n';
|
||||
reasoningTokens.push(separatorTokens);
|
||||
onProgress(separatorTokens);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue