(conversations)
| 55 | |
| 56 | |
| 57 | def compute_context_length(conversations): |
| 58 | length = 0 |
| 59 | for message in conversations: |
| 60 | content = message.get("content") |
| 61 | if isinstance(content, str): |
| 62 | length += len(content.split()) |
| 63 | elif isinstance(content, list): |
| 64 | for part in content: |
| 65 | if isinstance(part, dict) and isinstance(part.get("text"), str): |
| 66 | length += len(part["text"].split()) |
| 67 | return length |
| 68 | |
| 69 | |
| 70 | def build_query_kwargs(args, messages, max_tokens=None): |
no test coverage detected