helloadhavan/github_issues huggingface dataset:
Repository: ollama/ollama
Pull request: Fix generate test flakyness


Changed files:
filename: server/routes_generate_test.go
patch: @@ -73,8 +73,8 @@ func TestGenerateChat(t *testing.T) {
 			getCpuFn:      gpu.GetCPUInfo,
 			reschedDelay:  250 * time.Millisecond,
 			loadFn: func(req *LlmRequest, ggml *llm.GGML, gpus gpu.GpuInfoList, numParallel int) {
-				// add 10ms delay to simulate loading
-				time.Sleep(10 * time.Millisecond)
+				// add small delay to simulate loading
+				time.Sleep(time.Millisecond)
 				req.successCh <- &runnerRef{
 					llama: &mock,
 				}
@@ -371,6 +371,8 @@ func TestGenerate(t *testing.T) {
 			getCpuFn:      gpu.GetCPUInfo,
 			reschedDelay:  250 * time.Millisecond,
 			loadFn: func(req *LlmRequest, ggml *llm.GGML, gpus gpu.GpuInfoList, numParallel int) {
+				// add small delay to simulate loading
+				time.Sleep(time.Millisecond)
 				req.successCh <- &runnerRef{
 					llama: &mock,
 				}
Repository: vuejs/vue
Pull request: Vue treats `null` expression as `undefined`?

Not sure if it's just me misunderstanding how things work, but Vue is apparently treating `null` expression as `undefined`. Here is a failed test case to demonstrate the issue. 

If this is confirmed to be a bug, I can try to work on a fix.


Changed files:
filename: test/unit/specs/parsers/expression_spec.js
patch: @@ -218,6 +218,12 @@ var testCases = [
     expected: true,
     paths: []
   },
+  {
+    exp: 'null',
+    scope: {},
+    expected: null,
+    paths: []
+  },
   {
     // Date global
     exp: 'Date.now() > new Date("2000-01-01")',
Repository: ollama/ollama
Pull request: OpenAI: update message processing


Changed files:
filename: openai/openai.go
patch: @@ -351,7 +351,6 @@ func fromChatRequest(r ChatCompletionRequest) (*api.ChatRequest, error) {
 		case string:
 			messages = append(messages, api.Message{Role: msg.Role, Content: content})
 		case []any:
-			message := api.Message{Role: msg.Role}
 			for _, c := range content {
 				data, ok := c.(map[string]any)
 				if !ok {
@@ -363,7 +362,7 @@ func fromChatRequest(r ChatCompletionRequest) (*api.ChatRequest, error) {
 					if !ok {
 						return nil, fmt.Errorf("invalid message format")
 					}
-					message.Content = text
+					messages = append(messages, api.Message{Role: msg.Role, Content: text})
 				case "image_url":
 					var url string
 					if urlMap, ok := data["image_url"].(map[string]any); ok {
@@ -395,12 +394,12 @@ func fromChatRequest(r ChatCompletionRequest) (*api.ChatRequest, error) {
 					if err != nil {
 						return nil, fmt.Errorf("invalid message format")
 					}
-					message.Images = append(message.Images, img)
+
+					messages = append(messages, api.Message{Role: msg.Role, Images: []api.ImageData{img}})
 				default:
 					return nil, fmt.Errorf("invalid message format")
 				}
 			}
-			messages = append(messages, message)
 		default:
 			if msg.ToolCalls == nil {
 				return nil, fmt.Errorf("invalid message content type: %T", content)

filename: openai/openai_test.go
patch: @@ -161,8 +161,12 @@ func TestMiddlewareRequests(t *testing.T) {
 
 				img, _ := base64.StdEncoding.DecodeString(imageURL[len(prefix):])
 
-				if !bytes.Equal(chatReq.Messages[0].Images[0], img) {
-					t.Fatalf("expected image encoding, got %s", chatReq.Messages[0].Images[0])
+				if chatReq.Messages[1].Role != "user" {
+					t.Fatalf("expected 'user', got %s", chatReq.Messages[1].Role)
+				}
+
+				if !bytes.Equal(chatReq.Messages[1].Images[0], img) {
+					t.Fatalf("expected image encoding, got %s", chatReq.Messages[1].Images[0])
 				}
 			},
 		},
Repository: vuejs/vue
Pull request: Fix misspelled backer (Nikola Trifunovic)

My name is Nikola not "Nokola" :) Keep up the good work ;)


Changed files:
filename: backers.md
patch: @@ -114,7 +114,7 @@ It could be you!
 - Guido H.
 - Joan Cejudo
 - Ian Walter
-- Nokola Trifunovic
+- Nikola Trifunovic
 - Nicolas Mutis Mesa
 - Fahed Toumi
 - James
Repository: facebook/react
Pull request: Flag for requestPaint

Will run a quick experiment for this. 

Changed files:
filename: packages/scheduler/src/SchedulerFeatureFlags.js
patch: @@ -14,3 +14,4 @@ export const frameYieldMs = 5;
 export const userBlockingPriorityTimeout = 250;
 export const normalPriorityTimeout = 5000;
 export const lowPriorityTimeout = 10000;
+export const enableRequestPaint = true;

filename: packages/scheduler/src/__tests__/Scheduler-test.js
patch: @@ -18,6 +18,7 @@ let scheduleCallback;
 let requestPaint;
 let shouldYield;
 let NormalPriority;
+let SchedulerFeatureFlags;
 
 // The Scheduler implementation uses browser APIs like `MessageChannel` and
 // `setTimeout` to schedule work on the main thread. Most of our tests treat
@@ -42,6 +43,7 @@ describe('SchedulerBrowser', () => {
     NormalPriority = Scheduler.unstable_NormalPriority;
     requestPaint = Scheduler.unstable_requestPaint;
     shouldYield = Scheduler.unstable_shouldYield;
+    SchedulerFeatureFlags = require('../SchedulerFeatureFlags');
   });
 
   afterEach(() => {
@@ -199,7 +201,9 @@ describe('SchedulerBrowser', () => {
     runtime.assertLog([
       'Message Event',
       'Task',
-      'Yield at 0ms',
+      SchedulerFeatureFlags.enableRequestPaint
+        ? 'Yield at 0ms'
+        : `Yield at ${SchedulerFeatureFlags.frameYieldMs}ms`,
       'Post Message',
     ]);
 

filename: packages/scheduler/src/forks/Scheduler.js
patch: @@ -18,6 +18,7 @@ import {
   userBlockingPriorityTimeout,
   lowPriorityTimeout,
   normalPriorityTimeout,
+  enableRequestPaint,
 } from '../SchedulerFeatureFlags';
 
 import {push, pop, peek} from '../SchedulerMinHeap';
@@ -458,7 +459,7 @@ let frameInterval = frameYieldMs;
 let startTime = -1;
 
 function shouldYieldToHost(): boolean {
-  if (needsPaint) {
+  if (enableRequestPaint && needsPaint) {
     // Yield now.
     return true;
   }
@@ -473,7 +474,9 @@ function shouldYieldToHost(): boolean {
 }
 
 function requestPaint() {
-  needsPaint = true;
+  if (enableRequestPaint) {
+    needsPaint = true;
+  }
 }
 
 function forceFrameRate(fps: number) {
@@ -494,7 +497,9 @@ function forceFrameRate(fps: number) {
 }
 
 const performWorkUntilDeadline = () => {
-  needsPaint = false;
+  if (enableRequestPaint) {
+    needsPaint = false;
+  }
   if (isMessageLoopRunning) {
     const currentTime = getCurrentTime();
     // Keep track of the start time so we can measure how long the main thread

filename: packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js
patch: @@ -14,3 +14,4 @@
 export const userBlockingPriorityTimeout = 250;
 export const normalPriorityTimeout = 5000;
 export const lowPriorityTimeout = 10000;
+export const enableRequestPaint = __VARIANT__;

filename: packages/scheduler/src/forks/SchedulerFeatureFlags.www.js
patch: @@ -14,6 +14,7 @@ export const {
   userBlockingPriorityTimeout,
   normalPriorityTimeout,
   lowPriorityTimeout,
+  enableRequestPaint,
 } = dynamicFeatureFlags;
 
 export const frameYieldMs = 10;
Repository: ollama/ollama
Pull request: fix parsing tool calls: break on unexpected eofs


Changed files:
filename: server/model.go
patch: @@ -348,7 +348,7 @@ func (m *Model) parseToolCalls(s string) ([]api.ToolCall, bool) {
 	for offset := 0; offset < len(s); {
 		var obj map[string]any
 		decoder := json.NewDecoder(strings.NewReader(s[offset:]))
-		if err := decoder.Decode(&obj); errors.Is(err, io.EOF) {
+		if err := decoder.Decode(&obj); errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
 			break
 		} else if syntax := &(json.SyntaxError{}); errors.As(err, &syntax) {
 			// skip over any syntax errors
@@ -357,6 +357,7 @@ func (m *Model) parseToolCalls(s string) ([]api.ToolCall, bool) {
 			// skip over any unmarshalable types
 			offset += int(unmarshalType.Offset)
 		} else if err != nil {
+			slog.Error("parseToolCalls", "error", err)
 			return nil, false
 		} else {
 			offset += int(decoder.InputOffset())
Repository: ollama/ollama
Pull request: server: check for empty tools array too


Changed files:
filename: server/routes.go
patch: @@ -1290,7 +1290,7 @@ func (s *Server) ChatHandler(c *gin.Context) {
 	}
 
 	caps := []Capability{CapabilityCompletion}
-	if req.Tools != nil {
+	if len(req.Tools) > 0 {
 		caps = append(caps, CapabilityTools)
 	}
Repository: vercel/next.js
Pull request: Turbopack: use batch add to add initial followers

### What?

use batch add to convert children to followers

Changed files:
filename: turbopack/crates/turbo-tasks-backend/src/backend/operation/aggregation_update.rs
patch: @@ -31,8 +31,8 @@ use crate::{
         storage::{count, get, get_many, iter_many, remove, update, update_count},
     },
     data::{
-        ActivenessState, AggregationNumber, CachedDataItem, CachedDataItemKey, CollectibleRef,
-        DirtyContainerCount,
+        ActivenessState, AggregationNumber, CachedDataItem, CachedDataItemKey, CachedDataItemType,
+        CollectibleRef, DirtyContainerCount,
     },
     utils::swap_retain,
 };
@@ -2295,12 +2295,12 @@ impl AggregationUpdateQueue {
                 // When converted from leaf to aggregating node, all children become
                 // followers
                 let children: Vec<_> = get_many!(task, Child { task } => task);
-                for child_id in children {
-                    task.add_new(CachedDataItem::Follower {
-                        task: child_id,
-                        value: 1,
-                    });
-                }
+                task.extend_new(
+                    CachedDataItemType::Follower,
+                    children
+                        .iter()
+                        .map(|&task| CachedDataItem::Follower { task, value: 1 }),
+                );
             }
 
             if is_aggregating_node(aggregation_number) {
Repository: ollama/ollama
Pull request: api: always provide content even if empty


Changed files:
filename: api/types.go
patch: @@ -119,7 +119,7 @@ func (t Tools) String() string {
 // of images.
 type Message struct {
 	Role      string      `json:"role"`
-	Content   string      `json:"content,omitempty"`
+	Content   string      `json:"content"`
 	Images    []ImageData `json:"images,omitempty"`
 	ToolCalls []ToolCall  `json:"tool_calls,omitempty"`
 }
Repository: facebook/react
Pull request: Fix `commong` typo in <title> multiple children error message


Changed files:
filename: packages/react-dom-bindings/src/server/ReactFizzConfigDOM.js
patch: @@ -3080,7 +3080,7 @@ function pushTitle(
         console.error(
           'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an Array with length %s instead.' +
             ' Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert `children` of <title> tags to a single string value' +
-            ' which is why Arrays of length greater than 1 are not supported. When using JSX it can be commong to combine text nodes and value nodes.' +
+            ' which is why Arrays of length greater than 1 are not supported. When using JSX it can be common to combine text nodes and value nodes.' +
             ' For example: <title>hello {nameOfUser}</title>. While not immediately apparent, `children` in this case is an Array with length 2. If your `children` prop' +
             ' is using this form try rewriting it using a template string: <title>{`hello ${nameOfUser}`}</title>.',
           children.length,

filename: packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
patch: @@ -5928,7 +5928,7 @@ describe('ReactDOMFizzServer', () => {
           pipe(writable);
         });
       }).toErrorDev([
-        'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an Array with length 2 instead. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert `children` of <title> tags to a single string value which is why Arrays of length greater than 1 are not supported. When using JSX it can be commong to combine text nodes and value nodes. For example: <title>hello {nameOfUser}</title>. While not immediately apparent, `children` in this case is an Array with length 2. If your `children` prop is using this form try rewriting it using a template string: <title>{`hello ${nameOfUser}`}</title>.',
+        'React expects the `children` prop of <title> tags to be a string, number, bigint, or object with a novel `toString` method but found an Array with length 2 instead. Browsers treat all child Nodes of <title> tags as Text content and React expects to be able to convert `children` of <title> tags to a single string value which is why Arrays of length greater than 1 are not supported. When using JSX it can be common to combine text nodes and value nodes. For example: <title>hello {nameOfUser}</title>. While not immediately apparent, `children` in this case is an Array with length 2. If your `children` prop is using this form try rewriting it using a template string: <title>{`hello ${nameOfUser}`}</title>.',
       ]);
 
       expect(getVisibleChildren(document.head)).toEqual(<title />);
Repository: vuejs/vue
Pull request: Prevent setting unchanged value of input on blur

Fix #3029
Force setting the value actually resets selectionStart and selectionEnd
No test is added because you cannot simulate the bug by using
input.blur()


Changed files:
filename: src/directives/public/model/text.js
patch: @@ -129,7 +129,10 @@ export default {
   },
 
   update (value) {
-    this.el.value = _toString(value)
+    // #3029 only update when the value changes. This prevent
+    // browsers from overwriting values like selectionStart
+    value = _toString(value)
+    if (value !== this.el.value) this.el.value = value
   },
 
   unbind () {
Repository: ollama/ollama
Pull request: server: only parse tool calls if tools are provided


Changed files:
filename: server/routes.go
patch: @@ -1385,9 +1385,12 @@ func (s *Server) ChatHandler(c *gin.Context) {
 		}
 
 		resp.Message.Content = sb.String()
-		if toolCalls, ok := m.parseToolCalls(sb.String()); ok {
-			resp.Message.ToolCalls = toolCalls
-			resp.Message.Content = ""
+
+		if len(req.Tools) > 0 {
+			if toolCalls, ok := m.parseToolCalls(sb.String()); ok {
+				resp.Message.ToolCalls = toolCalls
+				resp.Message.Content = ""
+			}
 		}
 
 		c.JSON(http.StatusOK, resp)
Repository: vuejs/vue
Pull request: Sorry, my name got cut off on my Pateron profile

:confused:


Changed files:
filename: backers.md
patch: @@ -109,7 +109,7 @@ It could be you!
 - Yegor Sytnyk
 - Guido H.
 - Joan Cejudo
-- Walter
+- Ian Walter
 - Nokola Trifunovic
 - Nicolas Mutis Mesa
 - Fahed Toumi
Repository: huggingface/transformers
Pull request: add xpu support in test_modeling_janus.py::JanusIntegrationTest::test…

…_model_generate_images

add xpu support in tests/models/janus/test_modeling_janus.py::JanusIntegrationTest::test_model_generate_images


Changed files:
filename: src/transformers/models/janus/modeling_janus.py
patch: @@ -1419,8 +1419,8 @@ def generate(
             model_inputs = self.prepare_inputs_for_generation(
                 inputs_embeds=inputs_embeds, input_ids=input_tokens, **model_kwargs
             )
-
-            model_inputs["attention_mask"] = model_inputs["attention_mask"].to(inputs_embeds.device)
+            if "attention_mask" in model_inputs:
+                model_inputs["attention_mask"] = model_inputs["attention_mask"].to(inputs_embeds.device)
             model_inputs["cache_position"] = model_inputs["cache_position"].to(inputs_embeds.device)
 
             outputs = self.model.language_model(

filename: src/transformers/models/janus/modular_janus.py
patch: @@ -1235,8 +1235,8 @@ def generate(
             model_inputs = self.prepare_inputs_for_generation(
                 inputs_embeds=inputs_embeds, input_ids=input_tokens, **model_kwargs
             )
-
-            model_inputs["attention_mask"] = model_inputs["attention_mask"].to(inputs_embeds.device)
+            if "attention_mask" in model_inputs:
+                model_inputs["attention_mask"] = model_inputs["attention_mask"].to(inputs_embeds.device)
             model_inputs["cache_position"] = model_inputs["cache_position"].to(inputs_embeds.device)
 
             outputs = self.model.language_model(

filename: tests/models/janus/test_modeling_janus.py
patch: @@ -514,6 +514,12 @@ def test_model_generate_images(self):
                     15617, 6169, 2706, 8006, 14893, 3855, 10188, 15652, 6297, 1097, 12108, 15038, 311, 14998, 15165,
                     897, 4044, 1762, 4676
                 ],
+                ("xpu", None): [
+                    4484, 4015, 15750, 506, 3758, 11651, 8597, 5739, 4861, 971, 14985, 14834, 15438, 7548, 1820, 1465,
+                    13529, 12761, 10503, 12761, 14303, 6155, 4015, 11766, 705, 15736, 14146, 10417, 1951, 7713, 14305,
+                    15617, 6169, 2706, 8006, 14893, 3855, 10188, 15652, 6297, 1097, 12108, 15038, 311, 14998, 15165,
+                    897, 4044, 1762, 4676
+                ],
             }
         )
         expected_tokens = torch.tensor(expected_tokens.get_expectation()).to(model.device)
Repository: nodejs/node
Pull request: doc: run license-builder

License is likely out of date. This is an automatically generated PR by the `license-builder.yml` GitHub Action, which runs `license-builder.sh` and submits a new PR or updates an existing PR.

Changed files:
filename: LICENSE
patch: @@ -2639,3 +2639,28 @@ The externally maintained libraries used by Node.js are:
     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     SOFTWARE.
   """
+
+- sonic-boom, located at lib/internal/streams/fast-utf8-stream.js, is licensed as follows:
+  """
+    MIT License
+
+    Copyright (c) 2017 Matteo Collina
+
+    Permission is hereby granted, free of charge, to any person obtaining a copy
+    of this software and associated documentation files (the "Software"), to deal
+    in the Software without restriction, including without limitation the rights
+    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+    copies of the Software, and to permit persons to whom the Software is
+    furnished to do so, subject to the following conditions:
+
+    The above copyright notice and this permission notice shall be included in all
+    copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+    SOFTWARE.
+  """
Repository: ollama/ollama
Pull request: stub response

for compatibility, `{{ .Response }}` cannot be in any template control flow structures. therefore any template execution should set an empty Response if one should not be rendered otherwise the output will contain `<no value>` in place of `{{ .Response }}`

Changed files:
filename: template/template.go
patch: @@ -217,6 +217,7 @@ func (t *Template) Execute(w io.Writer, v Values) error {
 			"System":   system,
 			"Messages": messages,
 			"Tools":    v.Tools,
+			"Response": "",
 		})
 	}
 
@@ -270,8 +271,9 @@ func (t *Template) Execute(w io.Writer, v Values) error {
 
 	tree := parse.Tree{Root: nodes.(*parse.ListNode)}
 	if err := template.Must(template.New("").AddParseTree("", &tree)).Execute(&b, map[string]any{
-		"System": system,
-		"Prompt": prompt,
+		"System":   system,
+		"Prompt":   prompt,
+		"Response": "",
 	}); err != nil {
 		return err
 	}
Repository: ggml-org/llama.cpp
Pull request: ggml : cleanup path_str()

- Remove pragmas as `std::codecvt_utf8` is not used.
- Avoid implicit `strlen()`.

Changed files:
filename: ggml/src/ggml-backend-reg.cpp
patch: @@ -77,39 +77,23 @@
 #include "ggml-zendnn.h"
 #endif
 
-// disable C++17 deprecation warning for std::codecvt_utf8
-#if defined(__clang__)
-#    pragma clang diagnostic push
-#    pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#elif defined(__GNUC__)
-#    pragma GCC diagnostic push
-#    pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
 namespace fs = std::filesystem;
 
 static std::string path_str(const fs::path & path) {
-    std::string u8path;
     try {
 #if defined(__cpp_lib_char8_t)
         // C++20 and later: u8string() returns std::u8string
-        std::u8string u8str = path.u8string();
-        u8path = std::string(reinterpret_cast<const char*>(u8str.c_str()));
+        const std::u8string u8str = path.u8string();
+        return std::string(reinterpret_cast<const char *>(u8str.data()), u8str.size());
 #else
         // C++17: u8string() returns std::string
-        u8path = path.u8string();
+        return path.u8string();
 #endif
     } catch (...) {
+        return std::string();
     }
-    return u8path;
 }
 
-#if defined(__clang__)
-#    pragma clang diagnostic pop
-#elif defined(__GNUC__)
-#    pragma GCC diagnostic pop
-#endif
-
 #ifdef _WIN32
 
 using dl_handle = std::remove_pointer_t<HMODULE>;
Repository: huggingface/transformers
Pull request: fix crash when using chat to send 2+ request to gptoss

without it， 2+ request in chat using gptoss will coredump，error like
Traceback (most recent call last):
  File "/mnt/disk0/wangyi/miniforge3/envs/transformers/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/mnt/disk0/wangyi/miniforge3/envs/transformers/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/home/wangyi/transformers/src/transformers/commands/serving.py", line 981, in generate_with_cache
    generate_output = model.generate(**kwargs)
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/disk0/wangyi/miniforge3/envs/transformers/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/wangyi/transformers/src/transformers/generation/utils.py", line 2539, in generate
    result = self._sample(
             ^^^^^^^^^^^^^
  File "/home/wangyi/transformers/src/transformers/generation/utils.py", line 2860, in _sample
    model_inputs = self.prepare_inputs_for_generation(input_ids, **model_kwargs)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wangyi/transformers/src/transformers/generation/utils.py", line 569, in prepare_inputs_for_generation
    inputs_embeds, input_ids = self._cache_dependant_input_preparation(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/wangyi/transformers/src/transformers/generation/utils.py", line 475, in _cache_dependant_input_preparation
    or (cache_position[-1] >= input_ids.shape[1])  # Exception 3
        ~~~~~~~~~~~~~~^^^^
IndexError: index -1 is out of bounds for dimension 0 with size 0


Changed files:
filename: src/transformers/commands/serving.py
patch: @@ -1026,7 +1026,9 @@ def generate_chat_completion(self, req: dict) -> Generator[str, None, None]:
 
         last_kv_cache = None
         if self.is_continuation(req) and not must_discard_cache:
-            last_kv_cache = self.last_kv_cache
+            seq_len = self.last_kv_cache.get_seq_length()
+            if inputs["input_ids"].shape[-1] > seq_len:
+                last_kv_cache = self.last_kv_cache
 
         generation_kwargs = {
             **inputs,
@@ -1213,7 +1215,9 @@ def generate_response(self, req: dict) -> Generator[str, None, None]:
 
         last_kv_cache = None
         if self.is_continuation(req) and not must_discard_cache:
-            last_kv_cache = self.last_kv_cache
+            seq_len = self.last_kv_cache.get_seq_length()
+            if inputs["input_ids"].shape[-1] > seq_len:
+                last_kv_cache = self.last_kv_cache
 
         generation_kwargs = {
             "inputs": inputs,