Skip to content

Instantly share code, notes, and snippets.

@neelabalan
Created November 20, 2023 13:32
Show Gist options
  • Save neelabalan/572d11798e3fe87618a3b07dda8881bf to your computer and use it in GitHub Desktop.
Save neelabalan/572d11798e3fe87618a3b07dda8881bf to your computer and use it in GitHub Desktop.
Stitch the response (to be used with ollama)
import requests
def stitch_response(response: requests.Response) -> str:
if not response.status_code == 200:
return ""
actual_response = ""
for res_chunk in response.text.split("\n")[:-1]:
actual_response += json.loads(res_chunk)["response"]
return actual_response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment