Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
coderai
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexlab
coderai
Commits
576a6cfe
Commit
576a6cfe
authored
Mar 07, 2026
by
Stefy Lanza (nextime / spora )
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Jinja2 template error - properly handle multipart content arrays and tool_calls format
parent
08eee40c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
1 deletion
+24
-1
coderai
coderai
+24
-1
No files found.
coderai
View file @
576a6cfe
...
...
@@ -1724,8 +1724,26 @@ async def chat_completions(request: ChatCompletionRequest):
for
msg
in
messages
:
msg_dict
=
{
"role"
:
msg
.
role
}
#
Always
include
content
key
-
llama_cpp
template
expects
it
msg_dict
[
"content"
]
=
msg
.
content
if
msg
.
content
is
not
None
else
""
#
Convert
content
to
string
if
it
's a list (multipart content)
content = msg.content
if content is None:
content = ""
elif isinstance(content, list):
# Handle multipart content array format: [{"type": "text", "text": "..."}]
parts = []
for item in content:
if isinstance(item, dict):
if item.get('
type
') == '
text
' and '
text
' in item:
parts.append(item['
text
'])
else:
parts.append(f"[{item.get('
type
', '
unknown
')} content]")
else:
parts.append(str(item))
content = '
\
n
'.join(parts)
msg_dict["content"] = content
# Handle tool_calls - convert to proper format if present
if msg.tool_calls:
# tool_calls should be a list of dicts with '
id
', '
type
', '
function
' keys
msg_dict["tool_calls"] = msg.tool_calls
if msg.name:
msg_dict["name"] = msg.name
...
...
@@ -1733,6 +1751,11 @@ async def chat_completions(request: ChatCompletionRequest):
msg_dict["tool_call_id"] = msg.tool_call_id
messages_dict.append(msg_dict)
# Debug: print first few messages to see their structure
print(f"DEBUG: messages_dict[0] keys: {list(messages_dict[0].keys()) if messages_dict else '
empty
'}")
if len(messages_dict) > 1:
print(f"DEBUG: messages_dict[1] keys: {list(messages_dict[1].keys()) if len(messages_dict) > 1 else '
empty
'}")
# Convert tools to dict format if present
tools_dict = None
if request.tools:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment