File size: 44,130 Bytes
213da36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
[
  {
    "question_id": "q001",
    "question": "How do you define a path parameter in FastAPI?",
    "category": "retrieval",
    "difficulty": "easy",
    "retrieval_precision": 0.4,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 0.75,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 10965.568943065591,
    "tokens_used": {
      "input_tokens": 1319,
      "output_tokens": 164,
      "estimated_cost_usd": 0.00029624999999999996
    },
    "answer": "In FastAPI, path parameters are defined by capturing variable segments of a URL path and passing them directly to your route handler function. They are declared using curly braces `{}` in the route path string and must have a corresponding parameter in the function signature. \n\nHere is an example of defining a path parameter:\n\n```python\nfrom fastapi import FastAPI\n\napp = FastAPI()\n\n@app.get(\"/users/{user_id}\")\nasync def read_user(user_id: int):\n    return {\"user_id\": user_id}\n```\n\nIn this example, `user_id` is a path parameter that is captured from the URL and passed to the `read_user` function as an integer [source: fastapi_path_params.md].",
    "retrieved_sources": [
      "fastapi_path_params.md",
      "fastapi_request_body.md",
      "fastapi_query_params.md",
      "fastapi_path_params.md",
      "fastapi_query_params.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q002",
    "question": "What is the default page size for pagination in FastAPI and what is the maximum allowed?",
    "category": "retrieval",
    "difficulty": "easy",
    "retrieval_precision": 0.6,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 5247.50796193257,
    "tokens_used": {
      "input_tokens": 1430,
      "output_tokens": 55,
      "estimated_cost_usd": 0.0002475
    },
    "answer": "The default page size for pagination in FastAPI is 20 items, and the maximum allowed page size is 100 items per page [source: fastapi_pagination.md].",
    "retrieved_sources": [
      "fastapi_pagination.md",
      "fastapi_pagination.md",
      "fastapi_path_params.md",
      "fastapi_websockets.md",
      "fastapi_pagination.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q003",
    "question": "How does FastAPI handle CORS and what is the default max_age for preflight caching?",
    "category": "retrieval",
    "difficulty": "easy",
    "retrieval_precision": 0.8,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 5985.220503993332,
    "tokens_used": {
      "input_tokens": 1401,
      "output_tokens": 104,
      "estimated_cost_usd": 0.00027255
    },
    "answer": "FastAPI handles CORS (Cross-Origin Resource Sharing) using the `CORSMiddleware`. You can configure it by specifying parameters such as `allow_origins`, `allow_methods`, and `max_age`. The default value for `max_age` is set to 600 seconds, which determines the duration for which the results of a preflight request can be cached by the browser [source: fastapi_middleware.md].",
    "retrieved_sources": [
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_websockets.md",
      "fastapi_middleware.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q004",
    "question": "What algorithm and expiry time does the FastAPI security example use for JWT tokens?",
    "category": "retrieval",
    "difficulty": "medium",
    "retrieval_precision": 1.0,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 4853.062176029198,
    "tokens_used": {
      "input_tokens": 1398,
      "output_tokens": 58,
      "estimated_cost_usd": 0.0002445
    },
    "answer": "The FastAPI security example uses the \"HS256\" algorithm for JWT tokens and sets the expiry time for access tokens to 30 minutes [source: fastapi_security.md].",
    "retrieved_sources": [
      "fastapi_security.md",
      "fastapi_security.md",
      "fastapi_security.md",
      "fastapi_security.md",
      "fastapi_security.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q005",
    "question": "What is the recommended formula for calculating the number of Gunicorn workers for a FastAPI deployment?",
    "category": "retrieval",
    "difficulty": "medium",
    "retrieval_precision": 0.6,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 0.5,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 13312.960384995677,
    "tokens_used": {
      "input_tokens": 2993,
      "output_tokens": 217,
      "estimated_cost_usd": 0.00057915
    },
    "answer": "The FastAPI documentation does not provide a specific formula for calculating the number of Gunicorn workers for a deployment. However, it does mention a common configuration example where 4 workers are used with Gunicorn and Uvicorn workers:\n\n```bash\ngunicorn main:app \\\n    --workers 4 \\\n    --worker-class uvicorn.workers.UvicornWorker \\\n    --bind 0.0.0.0:8000 \\\n    --timeout 120 \\\n    --graceful-timeout 30 \\\n    --keep-alive 5 \\\n    --max-requests 1000 \\\n    --max-requests-jitter 50 \\\n    --access-logfile -\n```\n\nThis example suggests using 4 workers, but it does not specify a calculation method for determining the optimal number of workers based on system resources or expected load [source: fastapi_deployment.md].",
    "retrieved_sources": [
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_intro.md",
      "fastapi_intro.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q006",
    "question": "How does dependency caching work in FastAPI, and how can you disable it?",
    "category": "retrieval",
    "difficulty": "medium",
    "retrieval_precision": 1.0,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 10240.45393196866,
    "tokens_used": {
      "input_tokens": 2950,
      "output_tokens": 181,
      "estimated_cost_usd": 0.0005510999999999999
    },
    "answer": "In FastAPI, dependency caching works by default such that if the same dependency is used multiple times within a single request, FastAPI caches the result and calls the dependency only once. This means that if a dependency is invoked more than once in a request, it will not be executed again; instead, the cached result will be used.\n\nTo disable this caching behavior and force a fresh call to the dependency each time it is used, you can set the `use_cache` parameter to `False` when declaring the dependency. For example:\n\n```python\nDepends(get_db, use_cache=False)\n```\n\nThis will ensure that the dependency is called anew every time it is needed within that request [source: fastapi_dependencies.md].",
    "retrieved_sources": [
      "fastapi_dependencies.md",
      "fastapi_dependencies.md",
      "fastapi_dependencies.md",
      "fastapi_dependencies.md",
      "fastapi_dependencies.md",
      "fastapi_dependencies.md",
      "fastapi_dependencies.md",
      "fastapi_openapi.md",
      "fastapi_dependencies.md",
      "fastapi_security.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q007",
    "question": "If a paginated endpoint returns 20 items per page and there are 10,000 items total, how many total pages are there? And if the page size is changed to 30, how many pages would there be?",
    "category": "calculation",
    "difficulty": "medium",
    "retrieval_precision": 0.0,
    "retrieval_recall": 0.0,
    "keyword_hit_rate": 0.75,
    "has_source_citation": false,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 2763.5150860296562,
    "tokens_used": {
      "input_tokens": 898,
      "output_tokens": 108,
      "estimated_cost_usd": 0.0001995
    },
    "answer": "If a paginated endpoint returns 20 items per page, there would be a total of 500 pages. If the page size is changed to 30, there would be approximately 334 pages (since you cannot have a fraction of a page, you would round up).",
    "retrieved_sources": [],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q008",
    "question": "Does FastAPI support automatic Kubernetes deployment?",
    "category": "out_of_scope",
    "difficulty": "easy",
    "retrieval_precision": 0.0,
    "retrieval_recall": 0.0,
    "keyword_hit_rate": 0.3333333333333333,
    "has_source_citation": true,
    "grounded_refusal": false,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 7065.396980033256,
    "tokens_used": {
      "input_tokens": 3140,
      "output_tokens": 84,
      "estimated_cost_usd": 0.0005214
    },
    "answer": "The FastAPI documentation does not explicitly mention support for automatic Kubernetes deployment. It covers deployment using ASGI servers and Docker, but there is no specific information regarding Kubernetes deployment capabilities or limitations. Therefore, the answer is not in the FastAPI Docs documentation.",
    "retrieved_sources": [
      "fastapi_configuration.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_configuration.md",
      "fastapi_background_tasks.md",
      "fastapi_background_tasks.md",
      "fastapi_deployment.md",
      "fastapi_path_params.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q009",
    "question": "How does FastAPI integrate with Apache Kafka for event streaming?",
    "category": "out_of_scope",
    "difficulty": "easy",
    "retrieval_precision": 0.0,
    "retrieval_recall": 0.0,
    "keyword_hit_rate": 0.3333333333333333,
    "has_source_citation": true,
    "grounded_refusal": false,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 8296.601740992628,
    "tokens_used": {
      "input_tokens": 2659,
      "output_tokens": 70,
      "estimated_cost_usd": 0.00044085
    },
    "answer": "The FastAPI documentation does not provide specific information on how FastAPI integrates with Apache Kafka for event streaming. Therefore, I cannot answer your question based on the available documentation.",
    "retrieved_sources": [
      "fastapi_security.md",
      "fastapi_intro.md",
      "fastapi_intro.md",
      "fastapi_websockets.md",
      "fastapi_intro.md",
      "fastapi_path_params.md",
      "fastapi_pagination.md",
      "fastapi_intro.md",
      "fastapi_dependencies.md",
      "fastapi_dependencies.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q010",
    "question": "Can FastAPI generate GraphQL schemas natively?",
    "category": "out_of_scope",
    "difficulty": "easy",
    "retrieval_precision": 0.0,
    "retrieval_recall": 0.0,
    "keyword_hit_rate": 0.3333333333333333,
    "has_source_citation": true,
    "grounded_refusal": false,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 5988.564670085907,
    "tokens_used": {
      "input_tokens": 2857,
      "output_tokens": 82,
      "estimated_cost_usd": 0.00047774999999999993
    },
    "answer": "FastAPI does not natively support the generation of GraphQL schemas. The documentation does not mention any built-in functionality for GraphQL, indicating that this capability is not included in FastAPI's features [source: fastapi_openapi.md].",
    "retrieved_sources": [
      "fastapi_openapi.md",
      "fastapi_openapi.md",
      "fastapi_openapi.md",
      "fastapi_response_model.md",
      "fastapi_openapi.md",
      "fastapi_websockets.md",
      "fastapi_query_params.md",
      "fastapi_background_tasks.md",
      "fastapi_configuration.md",
      "fastapi_response_model.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q011",
    "question": "What is the default Swagger UI endpoint in FastAPI?",
    "category": "retrieval",
    "difficulty": "easy",
    "retrieval_precision": 0.6,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 0.6666666666666666,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 3414.396518957801,
    "tokens_used": {
      "input_tokens": 1322,
      "output_tokens": 41,
      "estimated_cost_usd": 0.0002229
    },
    "answer": "The default Swagger UI endpoint in FastAPI is `/docs` [source: fastapi_openapi.md].",
    "retrieved_sources": [
      "fastapi_openapi.md",
      "fastapi_openapi.md",
      "fastapi_intro.md",
      "fastapi_intro.md",
      "fastapi_openapi.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q012",
    "question": "How do you raise an HTTP error in a FastAPI route handler?",
    "category": "retrieval",
    "difficulty": "easy",
    "retrieval_precision": 0.8,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 6832.770353066735,
    "tokens_used": {
      "input_tokens": 1385,
      "output_tokens": 176,
      "estimated_cost_usd": 0.00031335
    },
    "answer": "To raise an HTTP error in a FastAPI route handler, you can use the `HTTPException` class. Here is an example of how to do this:\n\n```python\nfrom fastapi import FastAPI, HTTPException\n\napp = FastAPI()\n\n@app.get(\"/items/{item_id}\")\nasync def read_item(item_id: str):\n    if item_id not in items:\n        raise HTTPException(status_code=404, detail=\"Item not found\")\n    return items[item_id]\n```\n\nWhen you raise `HTTPException`, it immediately terminates request processing and returns the specified status code and detail message. The `detail` parameter can be a string, list, or dictionary, and FastAPI will serialize it to JSON automatically [source: fastapi_error_handling.md].",
    "retrieved_sources": [
      "fastapi_error_handling.md",
      "fastapi_error_handling.md",
      "fastapi_error_handling.md",
      "fastapi_dependencies.md",
      "fastapi_error_handling.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q013",
    "question": "How do you define a request body in FastAPI?",
    "category": "retrieval",
    "difficulty": "easy",
    "retrieval_precision": 0.6,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 6783.527110004798,
    "tokens_used": {
      "input_tokens": 1455,
      "output_tokens": 213,
      "estimated_cost_usd": 0.00034605000000000004
    },
    "answer": "In FastAPI, you define a request body using Pydantic models. A request body is typically sent as JSON in POST, PUT, or PATCH requests. Here\u2019s how you can define a request body:\n\n1. Import FastAPI and Pydantic's `BaseModel`.\n2. Create a Pydantic model that represents the structure of the request body.\n3. Use this model as a parameter in your endpoint function.\n\nHere is an example:\n\n```python\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\nclass Item(BaseModel):\n    name: str\n    description: str | None = None\n    price: float\n    tax: float = 0.0\n```\n\nIn this example, the `Item` model defines the expected fields in the request body, and FastAPI will automatically validate the incoming JSON against this model when a request is made [source: fastapi_request_body.md].",
    "retrieved_sources": [
      "fastapi_request_body.md",
      "fastapi_request_body.md",
      "fastapi_error_handling.md",
      "fastapi_request_body.md",
      "fastapi_error_handling.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q014",
    "question": "What testing tools does FastAPI use, and what class provides the test client?",
    "category": "retrieval",
    "difficulty": "easy",
    "retrieval_precision": 0.8,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 0.3333333333333333,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 5719.725794973783,
    "tokens_used": {
      "input_tokens": 1423,
      "output_tokens": 70,
      "estimated_cost_usd": 0.00025544999999999995
    },
    "answer": "FastAPI uses the `TestClient` class for testing applications, which provides a synchronous interface for sending requests without running an actual server. For asynchronous testing, `httpx.AsyncClient` can be used instead [source: fastapi_testing.md].",
    "retrieved_sources": [
      "fastapi_testing.md",
      "fastapi_testing.md",
      "fastapi_testing.md",
      "fastapi_openapi.md",
      "fastapi_testing.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q015",
    "question": "How does FastAPI manage application configuration and environment variables?",
    "category": "retrieval",
    "difficulty": "medium",
    "retrieval_precision": 0.8,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 8019.172917003743,
    "tokens_used": {
      "input_tokens": 1366,
      "output_tokens": 188,
      "estimated_cost_usd": 0.00031769999999999997
    },
    "answer": "FastAPI manages application configuration and environment variables using Pydantic's `BaseSettings` class. This allows for type-safe configuration with validation, default values, and automatic reading of environment variables and `.env` files. The priority order for reading configuration values is as follows:\n\n1. Constructor arguments passed directly to `Settings()`\n2. Environment variables\n3. Variables from the `.env` file\n4. Default values defined in the model\n\nAdditionally, FastAPI supports secrets management, where if `secrets_dir` is set, Pydantic looks for files named after each field, and the contents of these files become the field values. The priority order for secrets is:\n\n1. Constructor arguments\n2. Environment variables\n3. Secret files\n4. `.env` file\n5. Default values [source: fastapi_configuration.md].",
    "retrieved_sources": [
      "fastapi_configuration.md",
      "fastapi_configuration.md",
      "fastapi_configuration.md",
      "fastapi_configuration.md",
      "fastapi_intro.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q016",
    "question": "What is the minimum response size for GZip compression middleware in FastAPI, and how do you enable it?",
    "category": "retrieval",
    "difficulty": "medium",
    "retrieval_precision": 1.0,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 5878.701361943968,
    "tokens_used": {
      "input_tokens": 1385,
      "output_tokens": 118,
      "estimated_cost_usd": 0.00027854999999999997
    },
    "answer": "The minimum response size for GZip compression middleware in FastAPI is set to 500 bytes by default. You can enable GZip compression by adding the `GZipMiddleware` to your FastAPI application like this:\n\n```python\nfrom fastapi.middleware.gzip import GZipMiddleware\n\napp.add_middleware(GZipMiddleware, minimum_size=500)\n```\n\nResponses smaller than the specified `minimum_size` will be sent uncompressed [source: fastapi_middleware.md].",
    "retrieved_sources": [
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_middleware.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q017",
    "question": "How do yield dependencies work in FastAPI and what is the maximum number supported per request?",
    "category": "retrieval",
    "difficulty": "medium",
    "retrieval_precision": 0.8,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 0.75,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 6614.5300309872255,
    "tokens_used": {
      "input_tokens": 1434,
      "output_tokens": 139,
      "estimated_cost_usd": 0.0002985
    },
    "answer": "In FastAPI, yield dependencies are used to manage resource setup and cleanup. You can use `yield` in a dependency function to run setup code before the route handler executes and cleanup code after the response is sent. This is particularly useful for managing resources like database sessions or file handles. The code before `yield` runs before the handler, the yielded value is injected as the dependency, and the code after `yield` runs afterward, ensuring cleanup even if an exception occurs [source: fastapi_dependencies.md].\n\nFastAPI supports up to 32 yield dependencies per request by default [source: fastapi_dependencies.md].",
    "retrieved_sources": [
      "fastapi_dependencies.md",
      "fastapi_dependencies.md",
      "fastapi_dependencies.md",
      "fastapi_testing.md",
      "fastapi_dependencies.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q018",
    "question": "What are the three documentation endpoints FastAPI exposes by default and what OpenAPI version does it use?",
    "category": "retrieval",
    "difficulty": "medium",
    "retrieval_precision": 0.8,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 5938.157216063701,
    "tokens_used": {
      "input_tokens": 1363,
      "output_tokens": 102,
      "estimated_cost_usd": 0.00026565
    },
    "answer": "FastAPI exposes three documentation-related endpoints by default:\n\n1. `/docs` - Swagger UI -- interactive API explorer\n2. `/redoc` - ReDoc -- alternative documentation viewer\n3. `/openapi.json` - Raw OpenAPI schema in JSON format\n\nFastAPI uses OpenAPI version 3.1.0 for its schema generation [source: fastapi_openapi.md].",
    "retrieved_sources": [
      "fastapi_openapi.md",
      "fastapi_openapi.md",
      "fastapi_openapi.md",
      "fastapi_intro.md",
      "fastapi_openapi.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q019",
    "question": "How does FastAPI handle WebSocket connections, and what must be called before sending data?",
    "category": "retrieval",
    "difficulty": "medium",
    "retrieval_precision": 0.8,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 6348.878717981279,
    "tokens_used": {
      "input_tokens": 1361,
      "output_tokens": 100,
      "estimated_cost_usd": 0.00026415
    },
    "answer": "FastAPI handles WebSocket connections using Starlette's WebSocket implementation, which allows for full-duplex, bidirectional communication. To send or receive data through a WebSocket, you must first accept the connection by calling `await ws.accept()`. This method sends the HTTP 101 Switching Protocols response to the client, enabling the WebSocket communication to begin [source: fastapi_websockets.md].",
    "retrieved_sources": [
      "fastapi_websockets.md",
      "fastapi_websockets.md",
      "fastapi_websockets.md",
      "fastapi_intro.md",
      "fastapi_websockets.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q020",
    "question": "For a server with 4 CPU cores, how many Gunicorn workers should be configured using the recommended formula?",
    "category": "calculation",
    "difficulty": "medium",
    "retrieval_precision": 1.0,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": false,
    "tool_calls_made": 1,
    "latency_ms": 5323.60450795386,
    "tokens_used": {
      "input_tokens": 1393,
      "output_tokens": 66,
      "estimated_cost_usd": 0.00024854999999999994
    },
    "answer": "The recommended number of Gunicorn workers is calculated using the formula `(2 * CPU_CORES) + 1`. For a server with 4 CPU cores, this results in 9 workers [source: fastapi_deployment.md].",
    "retrieved_sources": [
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q021",
    "question": "If the CORS max_age is 600 seconds, how many minutes does the browser cache preflight results?",
    "category": "calculation",
    "difficulty": "easy",
    "retrieval_precision": 0.0,
    "retrieval_recall": 0.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": false,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 1,
    "latency_ms": 1747.607033001259,
    "tokens_used": {
      "input_tokens": 801,
      "output_tokens": 40,
      "estimated_cost_usd": 0.00014415
    },
    "answer": "If the CORS max_age is 600 seconds, the browser caches preflight results for 10 minutes.",
    "retrieved_sources": [],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q022",
    "question": "How do route ordering and dependency injection interact when building a secure FastAPI application with scoped endpoints?",
    "category": "retrieval",
    "difficulty": "hard",
    "retrieval_precision": 0.4,
    "retrieval_recall": 0.3333333333333333,
    "keyword_hit_rate": 0.5,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 8902.494193986058,
    "tokens_used": {
      "input_tokens": 2915,
      "output_tokens": 202,
      "estimated_cost_usd": 0.0005584499999999999
    },
    "answer": "FastAPI evaluates routes in the order they are defined, which is critical when you have routes that could match the same URL pattern. This means that the order of route definitions can affect which route is executed for a given request [source: fastapi_path_params.md].\n\nAdditionally, FastAPI includes a built-in dependency injection system that allows you to share logic, enforce authentication, manage database connections, and more. Dependencies are declared using `Depends()` and are resolved automatically for each request [source: fastapi_dependencies.md]. \n\nHowever, there are no specific documented limitations or interactions between route ordering and dependency injection in the context of scoped endpoints in FastAPI. Therefore, the answer to your question about how these two features interact in building a secure application is not explicitly covered in the FastAPI documentation.",
    "retrieved_sources": [
      "fastapi_dependencies.md",
      "fastapi_websockets.md",
      "fastapi_dependencies.md",
      "fastapi_configuration.md",
      "fastapi_intro.md",
      "fastapi_dependencies.md",
      "fastapi_path_params.md",
      "fastapi_dependencies.md",
      "fastapi_configuration.md",
      "fastapi_middleware.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q023",
    "question": "How would you set up a FastAPI application with custom error handling, CORS middleware, and structured testing including dependency overrides?",
    "category": "retrieval",
    "difficulty": "hard",
    "retrieval_precision": 1.0,
    "retrieval_recall": 0.3333333333333333,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 3,
    "latency_ms": 22737.167728948407,
    "tokens_used": {
      "input_tokens": 2828,
      "output_tokens": 810,
      "estimated_cost_usd": 0.0009101999999999999
    },
    "answer": "To set up a FastAPI application with custom error handling, CORS middleware, and structured testing including dependency overrides, you can follow these guidelines:\n\n### Custom Error Handling\nFastAPI allows you to handle errors using the `HTTPException` class and custom exception handlers. Here\u2019s how you can implement it:\n\n1. **Using `HTTPException`:**\n   You can raise an `HTTPException` in your route handlers to return error responses.\n   ```python\n   from fastapi import FastAPI, HTTPException\n\n   app = FastAPI()\n\n   @app.get(\"/items/{item_id}\")\n   async def read_item(item_id: int):\n       if item_id not in items:\n           raise HTTPException(status_code=404, detail=\"Item not found\")\n       return items[item_id]\n   ```\n\n2. **Custom Exception Handlers:**\n   You can register custom handlers for specific exceptions.\n   ```python\n   from fastapi import FastAPI, Request\n   from fastapi.responses import JSONResponse\n\n   class ItemNotFoundException(Exception):\n       def __init__(self, item_id: str):\n           self.item_id = item_id\n\n   @app.exception_handler(ItemNotFoundException)\n   async def item_not_found_exception_handler(request: Request, exc: ItemNotFoundException):\n       return JSONResponse(\n           status_code=404,\n           content={\"detail\": f\"Item {exc.item_id} not found\"},\n       )\n   ``` \n   [source: fastapi_error_handling.md]\n\n### CORS Middleware\nTo enable CORS in your FastAPI application, you can use the `CORSMiddleware` as follows:\n```python\nfrom fastapi import FastAPI\nfrom fastapi.middleware.cors import CORSMiddleware\n\napp = FastAPI()\n\napp.add_middleware(\n    CORSMiddleware,\n    allow_origins=[\"https://example.com\", \"https://app.example.com\"],\n    allow_credentials=True,\n    allow_methods=[\"GET\", \"POST\", \"PUT\", \"DELETE\"],\n    allow_headers=[\"Authorization\", \"Content-Type\"],\n    expose_headers=[\"X-Custom-Header\"],\n    max_age=600,\n)\n```\nThis configuration allows specified origins to access your API and sets up the necessary CORS headers. [source: fastapi_middleware.md]\n\n### Structured Testing with Dependency Overrides\nFor testing, you can override dependencies to inject mock services or test databases. Here\u2019s an example:\n\n1. **Define your dependency:**\n   ```python\n   from fastapi import FastAPI, Depends\n\n   app = FastAPI()\n\n   async def get_db():\n       db = ProductionDatabase()\n       try:\n           yield db\n       finally:\n           db.close()\n\n   @app.get(\"/items/\")\n   async def read_items(db=Depends(get_db)):\n       return db.query_all_items()\n   ```\n\n2. **Override the dependency in your tests:**\n   ```python\n   from fastapi.testclient import TestClient\n\n   def get_test_db():\n       db = TestDatabase()\n       try:\n           yield db\n       finally:\n           db.close()\n\n   app.dependency_overrides[get_db] = get_test_db\n\n   client = TestClient(app)\n\n   def test_read_items():\n       response = client.get(\"/items/\")\n       assert response.status_code == 200\n   ```\n   After your tests, you should clear the overrides to prevent them from leaking into other tests:\n   ```python\n   app.dependency_overrides.clear()\n   ```\n   [source: fastapi_testing.md] \n\nBy following these steps, you can effectively set up a FastAPI application with custom error handling, CORS middleware, and structured testing with dependency overrides.",
    "retrieved_sources": [
      "fastapi_error_handling.md",
      "fastapi_error_handling.md",
      "fastapi_error_handling.md",
      "fastapi_error_handling.md",
      "fastapi_error_handling.md",
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_middleware.md",
      "fastapi_testing.md",
      "fastapi_testing.md",
      "fastapi_configuration.md",
      "fastapi_testing.md",
      "fastapi_dependencies.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q024",
    "question": "Explain how to deploy a FastAPI app with Docker using Gunicorn workers, health checks, and environment-based configuration via Pydantic Settings.",
    "category": "retrieval",
    "difficulty": "hard",
    "retrieval_precision": 0.8,
    "retrieval_recall": 1.0,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 3,
    "latency_ms": 26342.817361000925,
    "tokens_used": {
      "input_tokens": 3788,
      "output_tokens": 751,
      "estimated_cost_usd": 0.0010187999999999998
    },
    "answer": "To deploy a FastAPI app with Docker using Gunicorn workers, health checks, and environment-based configuration via Pydantic Settings, follow these steps:\n\n### 1. Dockerfile Setup\nCreate a `Dockerfile` for your FastAPI application. Here\u2019s an example:\n\n```dockerfile\nFROM python:3.9\n\n# Set the working directory\nWORKDIR /app\n\n# Copy the requirements file and install dependencies\nCOPY requirements.txt .\nRUN pip install --no-cache-dir -r requirements.txt\n\n# Copy the application code\nCOPY . .\n\n# Expose the port the app runs on\nEXPOSE 8000\n\n# Health check configuration\nHEALTHCHECK --interval=30s --timeout=10s --retries=3 --start-period=10s \\\n    CMD curl -f http://localhost:8000/health || exit 1\n\n# Command to run the application\nCMD [\"gunicorn\", \"main:app\", \"--workers\", \"4\", \"--worker-class\", \"uvicorn.workers.UvicornWorker\", \"--bind\", \"0.0.0.0:8000\", \"--timeout\", \"120\", \"--graceful-timeout\", \"30\", \"--keep-alive\", \"5\", \"--max-requests\", \"1000\", \"--max-requests-jitter\", \"50\", \"--access-logfile\", \"-\"]\n```\nThis configuration uses Gunicorn with Uvicorn workers to serve the FastAPI application, allowing for multiple worker processes [source: fastapi_deployment.md].\n\n### 2. Health Check Endpoint\nAdd a health check endpoint in your FastAPI application:\n\n```python\nfrom fastapi import FastAPI\n\napp = FastAPI()\n\n@app.get(\"/health\", status_code=200)\nasync def health_check():\n    return {\"status\": \"healthy\"}\n```\nThis endpoint will be used by Docker to check the health of the application [source: fastapi_deployment.md].\n\n### 3. Environment-Based Configuration with Pydantic Settings\nUse Pydantic's `BaseSettings` to manage your application configuration through environment variables. First, install the necessary package:\n\n```bash\npip install pydantic-settings\n```\n\nThen, define your settings as follows:\n\n```python\nfrom pydantic_settings import BaseSettings, SettingsConfigDict\n\nclass Settings(BaseSettings):\n    model_config = SettingsConfigDict(\n        env_file=\".env\",\n        env_file_encoding=\"utf-8\",\n        case_sensitive=False,\n    )\n    \n    database_url: str\n    api_key: str\n```\nCreate a `.env` file in your project root to store your environment variables:\n\n```\nDATABASE_URL=your_database_url\nAPI_KEY=your_api_key\n```\nPydantic Settings will read values from the environment variables, `.env` file, and provide type-safe configuration with validation [source: fastapi_configuration.md].\n\n### 4. Build and Run the Docker Container\nFinally, build and run your Docker container:\n\n```bash\ndocker build -t myfastapiapp .\ndocker run -d -p 8000:8000 myfastapiapp\n```\n\nThis setup will allow you to deploy your FastAPI application with Docker, utilizing Gunicorn for handling multiple requests, health checks for monitoring, and Pydantic for configuration management.",
    "retrieved_sources": [
      "fastapi_deployment.md",
      "fastapi_configuration.md",
      "fastapi_configuration.md",
      "fastapi_request_body.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_deployment.md",
      "fastapi_intro.md",
      "fastapi_deployment.md",
      "fastapi_intro.md",
      "fastapi_configuration.md",
      "fastapi_intro.md",
      "fastapi_configuration.md",
      "fastapi_configuration.md",
      "fastapi_configuration.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q025",
    "question": "How would you build a paginated API with cursor-based navigation, response model validation, and background task processing for analytics logging?",
    "category": "retrieval",
    "difficulty": "hard",
    "retrieval_precision": 1.0,
    "retrieval_recall": 0.6666666666666666,
    "keyword_hit_rate": 1.0,
    "has_source_citation": true,
    "grounded_refusal": true,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 3,
    "latency_ms": 26899.34883604292,
    "tokens_used": {
      "input_tokens": 3893,
      "output_tokens": 663,
      "estimated_cost_usd": 0.00098175
    },
    "answer": "To build a paginated API with cursor-based navigation, response model validation, and background task processing for analytics logging in FastAPI, you can follow these guidelines:\n\n1. **Cursor-Based Pagination**: Use an opaque token (cursor) that points to the last item in the previous page. This method avoids performance degradation associated with large offsets. Here\u2019s a basic example of how to implement cursor-based pagination:\n\n   ```python\n   from fastapi import FastAPI, Query\n   from typing import List\n\n   app = FastAPI()\n\n   @app.get(\"/items/\", response_model=PaginatedResponse[Item])\n   async def list_items(cursor: str = None, limit: int = Query(default=20, ge=1, le=100)):\n       # Logic to retrieve items based on cursor\n       return PaginatedResponse(items=items, has_more=has_more)\n   ```\n\n   Cursor-based pagination is recommended for large datasets or real-time feeds where items may be inserted or deleted between requests [source: fastapi_pagination.md].\n\n2. **Response Model Validation**: Use the `response_model` parameter in your route decorators to declare the shape of the data your endpoint returns. FastAPI will validate, serialize, and document the response, filtering out any fields not defined in the model. Here\u2019s an example:\n\n   ```python\n   from pydantic import BaseModel\n\n   class Item(BaseModel):\n       id: int\n       name: str\n\n   @app.get(\"/items/\", response_model=List[Item])\n   async def get_items():\n       return [{\"id\": 1, \"name\": \"Item 1\"}, {\"id\": 2, \"name\": \"Item 2\"}]\n   ```\n\n   This ensures that the response adheres to the defined model, providing automatic validation and serialization [source: fastapi_response_model.md].\n\n3. **Background Task Processing**: Use FastAPI's background tasks to log analytics after the response has been sent. You can define a background task function and add it to your route handler. Here\u2019s an example:\n\n   ```python\n   from fastapi import FastAPI, BackgroundTasks\n\n   app = FastAPI()\n\n   def log_analytics(item_id: int):\n       with open(\"analytics.log\", \"a\") as f:\n           f.write(f\"Item {item_id} accessed\\n\")\n\n   @app.get(\"/items/{item_id}\")\n   async def read_item(item_id: int, background_tasks: BackgroundTasks):\n       background_tasks.add_task(log_analytics, item_id)\n       return {\"item_id\": item_id}\n   ```\n\n   This allows the logging to occur in the background, ensuring that the client receives a response immediately [source: fastapi_background_tasks.md].\n\nBy combining these elements, you can create a robust API that efficiently handles large datasets, validates responses, and processes background tasks for logging or analytics.",
    "retrieved_sources": [
      "fastapi_pagination.md",
      "fastapi_pagination.md",
      "fastapi_background_tasks.md",
      "fastapi_pagination.md",
      "fastapi_pagination.md",
      "fastapi_response_model.md",
      "fastapi_intro.md",
      "fastapi_error_handling.md",
      "fastapi_request_body.md",
      "fastapi_response_model.md",
      "fastapi_background_tasks.md",
      "fastapi_background_tasks.md",
      "fastapi_intro.md",
      "fastapi_background_tasks.md",
      "fastapi_background_tasks.md"
    ],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q026",
    "question": "Does FastAPI have built-in support for database migrations like Alembic?",
    "category": "out_of_scope",
    "difficulty": "easy",
    "retrieval_precision": 0.0,
    "retrieval_recall": 0.0,
    "keyword_hit_rate": 0.3333333333333333,
    "has_source_citation": false,
    "grounded_refusal": false,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 7060.65729400143,
    "tokens_used": {
      "input_tokens": 1241,
      "output_tokens": 47,
      "estimated_cost_usd": 0.00021434999999999998
    },
    "answer": "The answer is not in the FastAPI Docs documentation.",
    "retrieved_sources": [],
    "faithfulness": null,
    "correctness": null
  },
  {
    "question_id": "q027",
    "question": "How does FastAPI handle automatic load balancing across multiple servers?",
    "category": "out_of_scope",
    "difficulty": "easy",
    "retrieval_precision": 0.0,
    "retrieval_recall": 0.0,
    "keyword_hit_rate": 0.3333333333333333,
    "has_source_citation": true,
    "grounded_refusal": false,
    "citation_accuracy": 1.0,
    "calculator_used_correctly": true,
    "tool_calls_made": 2,
    "latency_ms": 9740.152830956504,
    "tokens_used": {
      "input_tokens": 1822,
      "output_tokens": 94,
      "estimated_cost_usd": 0.0003297
    },
    "answer": "The FastAPI documentation does not provide information on how FastAPI handles automatic load balancing across multiple servers. Additionally, there are no specific limitations or capabilities mentioned regarding load balancing in the context of FastAPI. Therefore, I cannot provide an answer to your question based on the FastAPI Docs documentation.",
    "retrieved_sources": [
      "fastapi_background_tasks.md",
      "fastapi_path_params.md",
      "fastapi_background_tasks.md",
      "fastapi_background_tasks.md",
      "fastapi_background_tasks.md"
    ],
    "faithfulness": null,
    "correctness": null
  }
]