File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -271,14 +271,24 @@ def parse_conversation(messages):
271271 role = message ['role' ]
272272 content = message ['content' ]
273273
274+ # Handle content that could be a list or string
275+ if isinstance (content , list ):
276+ # Extract text content from the list
277+ text_content = ' ' .join (
278+ item ['text' ] for item in content
279+ if isinstance (item , dict ) and item .get ('type' ) == 'text'
280+ )
281+ else :
282+ text_content = content
283+
274284 if role == 'system' :
275- system_prompt , optillm_approach = extract_optillm_approach (content )
285+ system_prompt , optillm_approach = extract_optillm_approach (text_content )
276286 elif role == 'user' :
277287 if not optillm_approach :
278- content , optillm_approach = extract_optillm_approach (content )
279- conversation .append (f"User: { content } " )
288+ text_content , optillm_approach = extract_optillm_approach (text_content )
289+ conversation .append (f"User: { text_content } " )
280290 elif role == 'assistant' :
281- conversation .append (f"Assistant: { content } " )
291+ conversation .append (f"Assistant: { text_content } " )
282292
283293 initial_query = "\n " .join (conversation )
284294 return system_prompt , initial_query , optillm_approach
You can’t perform that action at this time.
0 commit comments