From 62c774bf24d35a1ebdcdb9927f8a6c6ae3949c82 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Tue, 13 May 2025 06:42:25 -0700 Subject: [PATCH] Revert "New attempt" This reverts commit e7ac06c1694024594450437f3b899e32ab2ce6e4. --- modules/llama_cpp_server.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/llama_cpp_server.py b/modules/llama_cpp_server.py index 615f29ad..1046969a 100644 --- a/modules/llama_cpp_server.py +++ b/modules/llama_cpp_server.py @@ -146,9 +146,8 @@ class LlamaServer: pprint.PrettyPrinter(indent=4, sort_dicts=False).pprint(printable_payload) print() - # Make a request with streaming enabled - response = self.session.post(url, json=payload, stream=True) - try: + # Make a direct request with streaming enabled using a context manager + with self.session.post(url, json=payload, stream=True) as response: response.raise_for_status() # Raise an exception for HTTP errors full_text = "" @@ -186,9 +185,6 @@ class LlamaServer: print(f"Problematic line: {line}") continue - finally: - response.close() - def generate(self, prompt, state): output = "" for output in self.generate_with_streaming(prompt, state):