Commit 8eb1c07
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 68a7803 commit 8eb1c07
2 files changed
Lines changed: 29 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
922 | 922 | | |
923 | 923 | | |
924 | 924 | | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
925 | 931 | | |
926 | 932 | | |
927 | | - | |
| 933 | + | |
928 | 934 | | |
929 | 935 | | |
930 | 936 | | |
| |||
965 | 971 | | |
966 | 972 | | |
967 | 973 | | |
968 | | - | |
| 974 | + | |
969 | 975 | | |
970 | 976 | | |
971 | 977 | | |
| |||
974 | 980 | | |
975 | 981 | | |
976 | 982 | | |
977 | | - | |
| 983 | + | |
978 | 984 | | |
979 | 985 | | |
980 | 986 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1928 | 1928 | | |
1929 | 1929 | | |
1930 | 1930 | | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
1931 | 1951 | | |
1932 | 1952 | | |
1933 | 1953 | | |
| |||
0 commit comments