wop commited on
Commit
5d92c93
·
verified ·
1 Parent(s): 122d511

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -74,10 +74,12 @@ for message in st.session_state.messages:
74
  def generate_chat_responses(chat_completion) -> Generator[str, None, None]:
75
  """Yield chat response content from the Groq API response."""
76
  for chunk in chat_completion:
77
- if chunk.choices[0].delta.content:
78
- yield chunk.choices[0].delta.content
79
- if chunk.choices[0].message.tool_calls:
80
- for tool_call in chunk.choices[0].message.tool_calls:
 
 
81
  function_name = tool_call.function.name
82
  if function_name == "time_date":
83
  owner_info = get_tool_owner_info()
@@ -162,7 +164,6 @@ if prompt := st.chat_input("Enter your prompt here..."):
162
  st.markdown(prompt)
163
 
164
  chat_responses_generator = None
165
- full_response = None
166
 
167
  try:
168
  chat_completion = client.chat.completions.create(
 
74
  def generate_chat_responses(chat_completion) -> Generator[str, None, None]:
75
  """Yield chat response content from the Groq API response."""
76
  for chunk in chat_completion:
77
+ if chunk.choices:
78
+ for choice in chunk.choices:
79
+ if choice.delta.content:
80
+ yield choice.delta.content
81
+ if chunk.message.tool_calls:
82
+ for tool_call in chunk.message.tool_calls:
83
  function_name = tool_call.function.name
84
  if function_name == "time_date":
85
  owner_info = get_tool_owner_info()
 
164
  st.markdown(prompt)
165
 
166
  chat_responses_generator = None
 
167
 
168
  try:
169
  chat_completion = client.chat.completions.create(