|
8 | 8 | MessageDeltaTextContent,
|
9 | 9 | MessageDeltaTextFileCitationAnnotation,
|
10 | 10 | MessageDeltaTextFilePathAnnotation,
|
| 11 | + MessageDeltaTextUrlCitationAnnotation, |
11 | 12 | MessageImageFileContent,
|
12 | 13 | MessageTextContent,
|
13 | 14 | MessageTextFileCitationAnnotation,
|
14 | 15 | MessageTextFilePathAnnotation,
|
| 16 | + MessageTextUrlCitationAnnotation, |
15 | 17 | RunStep,
|
16 | 18 | RunStepDeltaCodeInterpreterDetailItemObject,
|
17 | 19 | RunStepDeltaCodeInterpreterImageOutput,
|
|
44 | 46 | RunStepDeltaToolCallObject,
|
45 | 47 | )
|
46 | 48 |
|
47 |
| -################################################################### |
48 |
| -# The methods in this file are used with Azure AI Agent # |
49 |
| -# related code. They are used to invoke, create chat messages, # |
50 |
| -# or generate message content. # |
51 |
| -################################################################### |
| 49 | +""" |
| 50 | +The methods in this file are used with Azure AI Agent |
| 51 | +related code. They are used to invoke, create chat messages, |
| 52 | +or generate message content. |
| 53 | +""" |
52 | 54 |
|
53 | 55 |
|
54 | 56 | @experimental
|
@@ -109,7 +111,7 @@ def generate_message_content(
|
109 | 111 | "step_id": completed_step.id,
|
110 | 112 | "run_id": completed_step.run_id,
|
111 | 113 | "thread_id": completed_step.thread_id,
|
112 |
| - "assistant_id": completed_step.assistant_id, |
| 114 | + "agent_id": completed_step.agent_id, |
113 | 115 | "usage": completed_step.usage,
|
114 | 116 | }
|
115 | 117 | if completed_step is not None
|
@@ -173,6 +175,7 @@ def generate_streaming_message_content(
|
173 | 175 | (
|
174 | 176 | MessageDeltaTextFileCitationAnnotation,
|
175 | 177 | MessageDeltaTextFilePathAnnotation,
|
| 178 | + MessageDeltaTextUrlCitationAnnotation, |
176 | 179 | ),
|
177 | 180 | ):
|
178 | 181 | items.append(generate_streaming_annotation_content(annotation))
|
@@ -399,37 +402,51 @@ def generate_streaming_code_interpreter_content(
|
399 | 402 |
|
400 | 403 | @experimental
|
401 | 404 | def generate_annotation_content(
|
402 |
| - annotation: MessageTextFilePathAnnotation | MessageTextFileCitationAnnotation, |
| 405 | + annotation: MessageTextFilePathAnnotation | MessageTextFileCitationAnnotation | MessageTextUrlCitationAnnotation, |
403 | 406 | ) -> AnnotationContent:
|
404 | 407 | """Generate annotation content."""
|
405 | 408 | file_id = None
|
| 409 | + url = None |
406 | 410 | if isinstance(annotation, MessageTextFilePathAnnotation) and annotation.file_path is not None:
|
407 | 411 | file_id = annotation.file_path.file_id
|
408 | 412 | elif isinstance(annotation, MessageTextFileCitationAnnotation) and annotation.file_citation is not None:
|
409 | 413 | file_id = annotation.file_citation.file_id
|
| 414 | + elif isinstance(annotation, MessageTextUrlCitationAnnotation) and annotation.url_citation is not None: |
| 415 | + url = annotation.url_citation.url if annotation.url_citation.url else None |
410 | 416 |
|
411 | 417 | return AnnotationContent(
|
412 | 418 | file_id=file_id,
|
413 | 419 | quote=annotation.text,
|
414 | 420 | start_index=annotation.start_index if annotation.start_index is not None else None,
|
415 | 421 | end_index=annotation.end_index if annotation.end_index is not None else None,
|
| 422 | + url=url, |
416 | 423 | )
|
417 | 424 |
|
418 | 425 |
|
419 | 426 | @experimental
|
420 | 427 | def generate_streaming_annotation_content(
|
421 |
| - annotation: MessageDeltaTextFilePathAnnotation | MessageDeltaTextFileCitationAnnotation, |
| 428 | + annotation: MessageDeltaTextFilePathAnnotation |
| 429 | + | MessageDeltaTextFileCitationAnnotation |
| 430 | + | MessageDeltaTextUrlCitationAnnotation, |
422 | 431 | ) -> StreamingAnnotationContent:
|
423 | 432 | """Generate streaming annotation content."""
|
424 | 433 | file_id = None
|
| 434 | + url = None |
| 435 | + quote = None |
425 | 436 | if isinstance(annotation, MessageDeltaTextFilePathAnnotation) and annotation.file_path:
|
426 | 437 | file_id = annotation.file_path.file_id if annotation.file_path.file_id else None
|
| 438 | + quote = annotation.text if annotation.text else None |
427 | 439 | elif isinstance(annotation, MessageDeltaTextFileCitationAnnotation) and annotation.file_citation:
|
428 | 440 | file_id = annotation.file_citation.file_id if annotation.file_citation.file_id else None
|
| 441 | + quote = annotation.text if annotation.text else None |
| 442 | + elif isinstance(annotation, MessageDeltaTextUrlCitationAnnotation) and annotation.url_citation: |
| 443 | + url = annotation.url_citation.url if annotation.url_citation.url else None |
| 444 | + quote = annotation.url_citation.title if annotation.url_citation.title else None |
429 | 445 |
|
430 | 446 | return StreamingAnnotationContent(
|
431 | 447 | file_id=file_id,
|
432 |
| - quote=annotation.text, |
| 448 | + quote=quote, |
433 | 449 | start_index=annotation.start_index if annotation.start_index is not None else None,
|
434 | 450 | end_index=annotation.end_index if annotation.end_index is not None else None,
|
| 451 | + url=url, |
435 | 452 | )
|
0 commit comments