Commit b7422c5
committed
Use user-facing index names from LCORE config instead of llama-stack IDs
Model changes:
- RAGChunk: Change source field to contain the index name from config
instead of the llama-stack filename/UUID. Add attributes field
(Optional[dict[str, Any]]) to preserve document metadata from the
RAG provider (filename, file_id, and all provider-supplied attributes).
- ReferencedDocument: Add source field (Optional[str]) containing the
index name for consistency with RAGChunk.
- ResponseGeneratorContext: Add vector_store_ids and rag_id_mapping
fields for passing index identification context through streaming.
Configuration:
- AppConfig: Add rag_id_mapping property that builds a
{vector_db_id: rag_id} mapping from BYOK RAG configuration.
Add resolve_index_name helper for mapping vector store IDs to
user-facing names with passthrough for unmapped IDs.
Extraction logic (query_v2.py):
- Add _resolve_source_for_result() to determine index name per result:
checks result attributes for vector_store_id, falls back to single
queried store, returns None when ambiguous (multiple stores).
- Add _build_chunk_attributes() to merge provider attributes with
original filename and file_id for debugging.
- Update extract_rag_chunks_from_file_search_item(),
parse_rag_chunks_from_responses_api(), _build_tool_call_summary(),
and parse_referenced_documents_from_responses_api() to accept and
forward vector_store_ids and rag_id_mapping parameters.
- Update prepare_tools_for_responses_api() to also return the resolved
vector_store_ids alongside tool configurations.
/v1/rags endpoint:
- List endpoint now maps llama-stack vector_store_ids to user-facing
rag_ids from BYOK config. Unmapped IDs pass through unchanged.
- Detail endpoint accepts both rag_id (from config) and raw
vector_store_id, resolving rag_id to vector_db_id for the
llama-stack lookup. Response displays the user-facing ID.
Streaming support:
- Update streaming_query_v2.py retrieve_response to return
vector_store_ids and rag_id_mapping.
- Update streaming_query.py to unpack and populate
ResponseGeneratorContext with index identification data.
- Update a2a.py to handle the expanded return tuple.
Transcript storage:
- create_rag_chunks_dict() now includes the attributes field in
serialized RAG chunk dictionaries.
Tests:
- Add TestResolveSourceForResult: 7 tests covering attribute-based
resolution, single store, multi-store, empty inputs, precedence.
- Add TestBuildChunkAttributes: 3 tests for attribute merging.
- Add TestExtractRagChunksWithIndexMapping: 3 tests for end-to-end
chunk extraction with index mapping.
- Add TestParseReferencedDocumentsWithSource: 2 tests for referenced
document source population.
- Add BYOK RAG mapping tests for /v1/rags: list with mapping, detail
with rag_id resolution, _resolve_rag_id_to_vector_db_id.
- Add configuration tests: rag_id_mapping property, resolve_index_name,
error when config not loaded.
- Update existing tests for new field defaults and return types.1 parent 15754b4 commit b7422c5
15 files changed
Lines changed: 661 additions & 43 deletions
File tree
- src
- app/endpoints
- models
- utils
- tests/unit
- app/endpoints
- cache
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
330 | | - | |
| 330 | + | |
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
| 89 | + | |
88 | 90 | | |
89 | 91 | | |
90 | 92 | | |
| |||
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
125 | 129 | | |
126 | 130 | | |
127 | 131 | | |
128 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
| |||
365 | 371 | | |
366 | 372 | | |
367 | 373 | | |
368 | | - | |
| 374 | + | |
369 | 375 | | |
370 | 376 | | |
| 377 | + | |
371 | 378 | | |
372 | 379 | | |
373 | 380 | | |
| |||
450 | 457 | | |
451 | 458 | | |
452 | 459 | | |
453 | | - | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
454 | 463 | | |
455 | 464 | | |
456 | 465 | | |
| |||
470 | 479 | | |
471 | 480 | | |
472 | 481 | | |
473 | | - | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
474 | 485 | | |
475 | 486 | | |
476 | 487 | | |
| |||
490 | 501 | | |
491 | 502 | | |
492 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
493 | 564 | | |
494 | 565 | | |
495 | 566 | | |
| 567 | + | |
| 568 | + | |
496 | 569 | | |
497 | 570 | | |
498 | 571 | | |
499 | 572 | | |
500 | 573 | | |
501 | 574 | | |
| 575 | + | |
| 576 | + | |
502 | 577 | | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
509 | 594 | | |
510 | 595 | | |
511 | 596 | | |
512 | 597 | | |
| 598 | + | |
| 599 | + | |
513 | 600 | | |
514 | 601 | | |
515 | 602 | | |
516 | 603 | | |
517 | 604 | | |
518 | 605 | | |
| 606 | + | |
| 607 | + | |
519 | 608 | | |
520 | 609 | | |
521 | | - | |
| 610 | + | |
522 | 611 | | |
523 | 612 | | |
524 | 613 | | |
525 | 614 | | |
526 | 615 | | |
527 | 616 | | |
528 | 617 | | |
529 | | - | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
530 | 621 | | |
531 | 622 | | |
532 | 623 | | |
533 | 624 | | |
534 | 625 | | |
535 | 626 | | |
| 627 | + | |
| 628 | + | |
536 | 629 | | |
537 | 630 | | |
538 | 631 | | |
539 | 632 | | |
540 | 633 | | |
541 | 634 | | |
| 635 | + | |
| 636 | + | |
542 | 637 | | |
543 | 638 | | |
544 | | - | |
| 639 | + | |
545 | 640 | | |
546 | 641 | | |
547 | 642 | | |
548 | 643 | | |
549 | 644 | | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
550 | 648 | | |
551 | 649 | | |
552 | 650 | | |
| |||
574 | 672 | | |
575 | 673 | | |
576 | 674 | | |
| 675 | + | |
| 676 | + | |
577 | 677 | | |
578 | 678 | | |
579 | 679 | | |
580 | 680 | | |
581 | 681 | | |
582 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
583 | 687 | | |
584 | 688 | | |
585 | 689 | | |
| |||
809 | 913 | | |
810 | 914 | | |
811 | 915 | | |
812 | | - | |
| 916 | + | |
813 | 917 | | |
814 | 918 | | |
815 | 919 | | |
| |||
824 | 928 | | |
825 | 929 | | |
826 | 930 | | |
827 | | - | |
828 | | - | |
| 931 | + | |
| 932 | + | |
829 | 933 | | |
830 | 934 | | |
831 | | - | |
| 935 | + | |
832 | 936 | | |
833 | 937 | | |
834 | 938 | | |
| |||
855 | 959 | | |
856 | 960 | | |
857 | 961 | | |
858 | | - | |
| 962 | + | |
859 | 963 | | |
860 | | - | |
| 964 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
92 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
98 | 104 | | |
99 | 105 | | |
100 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
101 | 131 | | |
102 | 132 | | |
103 | 133 | | |
| |||
107 | 137 | | |
108 | 138 | | |
109 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
110 | 144 | | |
111 | 145 | | |
112 | 146 | | |
| |||
129 | 163 | | |
130 | 164 | | |
131 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
132 | 169 | | |
133 | 170 | | |
134 | 171 | | |
135 | 172 | | |
136 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
137 | 180 | | |
138 | | - | |
| 181 | + | |
139 | 182 | | |
140 | 183 | | |
141 | 184 | | |
| |||
0 commit comments