code: def stream(
      self,
      prompt: str,
      stop: Optional[List[str]] = None,
      run_manager: Optional[CallbackManagerForLLMRun] = None,
  ) -> str:
      config = self.config
      generator = self.generator
      beam_search = (
          self.beams
          and self.beams >= 1
          and self.beam_length
          and self.beam_length >= 1
      )
  
      ids = generator.tokenizer.encode(prompt)
      generator.gen_begin_reuse(ids)
  
      if beam_search:
          generator.begin_beam_search()
          token_getter = generator.beam_search
      else:
          generator.end_beam_search()
          token_getter = generator.gen_single_token
  
      last_newline_pos = 0
      seq_length = len(
          generator.tokenizer.decode(generator.sequence_actual[0])
      )
      response_start = seq_length
      cursor_head = response_start
  
      text_callback = None
      if run_manager:
          text_callback = partial(
              run_manager.on_llm_new_token, verbose=self.verbose
          )
      # No longer assume below, assume always just new text so various langchain things work
      ##### parent handler of streamer expects to see prompt first else output="" and lose if prompt=None in prompter
      #### text_callback:
      ####    text_callback(prompt)
      text = ""
      while generator.gen_num_tokens() <= (
          self.max_seq_len - 4
      ):  # Slight extra padding space as we seem to occassionally get a few more than 1-2 tokens
          # Fetch a token
          token = token_getter()
  
          # If it's the ending token replace it and end the generation.
          if token.item() == generator.tokenizer.eos_token_id:
              generator.replace_last_token(
                  generator.tokenizer.newline_token_id
              )
              if beam_search:
                  generator.end_beam_search()
              return
  
          # Tokenize the string from the last new line, we can't just decode the last token due to how sentencepiece decodes.
          stuff = generator.tokenizer.decode(
              generator.sequence_actual[0][last_newline_pos:]
          )
          cursor_tail = len(stuff)
          has_unicode_combined = cursor_tail < cursor_head
          text_chunk = stuff[cursor_head:cursor_tail]
          if has_unicode_combined:
              # replace the broken unicode character with combined one
              text = text[:-2]
              text_chunk = stuff[cursor_tail - 1 : cursor_tail]
  
          cursor_head = cursor_tail
  
          # Append the generated chunk to our stream buffer
          text += text_chunk
          text = self.prompter.get_response(
              prompt + text,
              prompt=prompt,
              sanitize_bot_response=self.sanitize_bot_response,
          )
  
          if token.item() == generator.tokenizer.newline_token_id:
              last_newline_pos = len(generator.sequence_actual[0])
              cursor_head = 0
              cursor_tail = 0
  
          # Check if the stream buffer is one of the stop sequences
          status = self.match_status(text, self.stop_sequences)
  
          if status == self.MatchStatus.EXACT_MATCH:
              # Encountered a stop, rewind our generator to before we hit the match and end generation.
              rewind_length = generator.tokenizer.encode(text).shape[-1]
              generator.gen_rewind(rewind_length)
              # gen = generator.tokenizer.decode(generator.sequence_actual[0][response_start:])
              if beam_search:
                  generator.end_beam_search()
              return
          elif status == self.MatchStatus.PARTIAL_MATCH:
              # Partially matched a stop, continue buffering but don't yield.
              continue
          elif status == self.MatchStatus.NO_MATCH:
              if text_callback and not (text_chunk == BROKEN_UNICODE):
                  text_callback(text_chunk)
              yield text  # Not a stop, yield the match buffer.
  
      return
  
imports: from functools import partial
  from langchain.llms.base import LLM
  from langchain.callbacks.manager import CallbackManagerForLLMRun
  from typing import Any, Dict, List, Optional
  from exllama.model import ExLlama, ExLlamaCache, ExLlamaConfig
  from exllama.tokenizer import ExLlamaTokenizer
  from exllama.generator import ExLlamaGenerator
  from exllama.lora import ExLlamaLora
  import os, glob
  from pydantic.v1 import root_validator
label_desc: Use image node_id 9 for calling the Exllama obj's underlying member method code with example usage: obj.stream(prompt, stop, run_manager) without return types