Commit 9b4dbc8
committed
fix(litellm): guard against Content with no parts in _content_to_message_param
types.Content(role="user") defaults parts to None, and the fallback path can
produce an empty user turn, so iterating content.parts in _content_to_message_param
raised TypeError: 'NoneType' object is not iterable during LiteLLM request
assembly, before any model call.
Normalize parts to content.parts or [] once (matching the existing idiom in this
module and the google_llm adapter, which skips contents without parts) and iterate
the normalized list in all three branches. A content with no parts now yields a
message with empty content instead of crashing.
Add regression tests covering user and assistant roles for both parts=None and
parts=[].1 parent e5fdb51 commit 9b4dbc8
2 files changed
Lines changed: 29 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
983 | 983 | | |
984 | 984 | | |
985 | 985 | | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
986 | 992 | | |
987 | 993 | | |
988 | | - | |
| 994 | + | |
989 | 995 | | |
990 | 996 | | |
991 | 997 | | |
| |||
1026 | 1032 | | |
1027 | 1033 | | |
1028 | 1034 | | |
1029 | | - | |
| 1035 | + | |
1030 | 1036 | | |
1031 | 1037 | | |
1032 | 1038 | | |
| |||
1035 | 1041 | | |
1036 | 1042 | | |
1037 | 1043 | | |
1038 | | - | |
| 1044 | + | |
1039 | 1045 | | |
1040 | 1046 | | |
1041 | 1047 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1930 | 1930 | | |
1931 | 1931 | | |
1932 | 1932 | | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
1933 | 1953 | | |
1934 | 1954 | | |
1935 | 1955 | | |
| |||
0 commit comments