acecalisto3 commited on
Commit
d1bc600
·
verified ·
1 Parent(s): d379502

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -359,13 +359,13 @@ def generate(
359
  formatted_prompt = format_prompt(formatted_prompt, history, max_history_turns=5) # Truncated history
360
  logging.info(f"Formatted Prompt: {formatted_prompt}")
361
  stream = client.text_generation(formatted_prompt, temperature=temperature, max_new_tokens=max_new_tokens, top_p=top_p, repetition_penalty=repetition_penalty, stream=True, details=True, return_full_text=False)
362
- resp = ""
363
  for response in stream:
364
  resp += response.token.text
 
365
 
366
  if VERBOSE:
367
- logging.info(LOG_RESPONSE.format("")) # Log the response
368
- return formatted_prompt # Return resp here
369
 
370
  def generate_text_chunked(input_text, model, generation_parameters, max_tokens_to_generate):
371
  """Generates text in chunks to avoid token limit errors."""
 
359
  formatted_prompt = format_prompt(formatted_prompt, history, max_history_turns=5) # Truncated history
360
  logging.info(f"Formatted Prompt: {formatted_prompt}")
361
  stream = client.text_generation(formatted_prompt, temperature=temperature, max_new_tokens=max_new_tokens, top_p=top_p, repetition_penalty=repetition_penalty, stream=True, details=True, return_full_text=False)
362
+ resp = ""
363
  for response in stream:
364
  resp += response.token.text
365
+ yield resp # This allows for streaming the response
366
 
367
  if VERBOSE:
368
+ logging.info(LOG_RESPONSE.format(resp)) # Pass resp to format
 
369
 
370
  def generate_text_chunked(input_text, model, generation_parameters, max_tokens_to_generate):
371
  """Generates text in chunks to avoid token limit errors."""