|
52 | 52 | CompletionChunk as MistralCompletionChunk,
|
53 | 53 | Content as MistralContent,
|
54 | 54 | ContentChunk as MistralContentChunk,
|
| 55 | + DocumentURLChunk as MistralDocumentURLChunk, |
55 | 56 | FunctionCall as MistralFunctionCall,
|
56 | 57 | ImageURL as MistralImageURL,
|
57 | 58 | ImageURLChunk as MistralImageURLChunk,
|
@@ -539,10 +540,19 @@ def _map_user_prompt(self, part: UserPromptPart) -> MistralUserMessage:
|
539 | 540 | if item.is_image:
|
540 | 541 | image_url = MistralImageURL(url=f'data:{item.media_type};base64,{base64_encoded}')
|
541 | 542 | content.append(MistralImageURLChunk(image_url=image_url, type='image_url'))
|
| 543 | + elif item.media_type == 'application/pdf': |
| 544 | + content.append( |
| 545 | + MistralDocumentURLChunk( |
| 546 | + document_url=f'data:application/pdf;base64,{base64_encoded}', type='document_url' |
| 547 | + ) |
| 548 | + ) |
542 | 549 | else:
|
543 |
| - raise RuntimeError('Only image binary content is supported for Mistral.') |
| 550 | + raise RuntimeError('BinaryContent other than image or PDF is not supported in Mistral.') |
544 | 551 | elif isinstance(item, DocumentUrl):
|
545 |
| - raise RuntimeError('DocumentUrl is not supported in Mistral.') # pragma: no cover |
| 552 | + if item.media_type == 'application/pdf': |
| 553 | + content.append(MistralDocumentURLChunk(document_url=item.url, type='document_url')) |
| 554 | + else: |
| 555 | + raise RuntimeError('DocumentUrl other than PDF is not supported in Mistral.') |
546 | 556 | elif isinstance(item, VideoUrl):
|
547 | 557 | raise RuntimeError('VideoUrl is not supported in Mistral.')
|
548 | 558 | else: # pragma: no cover
|
|
0 commit comments