rodrigomasini commited on
Commit
b5fc8ee
·
verified ·
1 Parent(s): ccfb364

Update helper.py

Browse files
Files changed (1) hide show
  1. helper.py +7 -2
helper.py CHANGED
@@ -41,8 +41,13 @@ def get_fn(model_name: str, **model_kwargs):
41
  stream=True,
42
  response_format={"type": "text"},
43
  )
44
- assistant_message = response.choices[0].message.content
45
- yield assistant_message.strip()
 
 
 
 
 
46
  except Exception as e:
47
  print(f"Error during generation: {str(e)}")
48
  yield f"An error occurred: {str(e)}"
 
41
  stream=True,
42
  response_format={"type": "text"},
43
  )
44
+
45
+ response_text = ""
46
+ for chunk in response:
47
+ chunk_message = chunk.choices[0].delta.content
48
+ if chunk_message:
49
+ response_text += chunk_message
50
+ yield assistant_message.strip()
51
  except Exception as e:
52
  print(f"Error during generation: {str(e)}")
53
  yield f"An error occurred: {str(e)}"