judgeval 0.0.11__tar.gz → 0.0.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. {judgeval-0.0.11 → judgeval-0.0.13}/PKG-INFO +1 -1
  2. {judgeval-0.0.11 → judgeval-0.0.13}/docs/api_reference/trace.mdx +11 -4
  3. {judgeval-0.0.11 → judgeval-0.0.13}/docs/getting_started.mdx +43 -20
  4. {judgeval-0.0.11 → judgeval-0.0.13}/docs/monitoring/tracing.mdx +87 -62
  5. {judgeval-0.0.11 → judgeval-0.0.13}/pyproject.toml +1 -1
  6. judgeval-0.0.13/src/demo/cookbooks/new_bot/basic_bot.py +106 -0
  7. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/openai_travel_agent/agent.py +27 -11
  8. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/openai_travel_agent/tools.py +1 -1
  9. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/customer_use/cstone/faithfulness_testing.py +4 -4
  10. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/common/tracer.py +87 -28
  11. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/constants.py +2 -0
  12. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/datasets/dataset.py +2 -1
  13. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/datasets/eval_dataset_client.py +106 -9
  14. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/example.py +13 -5
  15. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/judgment_client.py +29 -6
  16. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/run_evaluation.py +16 -5
  17. {judgeval-0.0.11 → judgeval-0.0.13}/.github/workflows/ci.yaml +0 -0
  18. {judgeval-0.0.11 → judgeval-0.0.13}/.gitignore +0 -0
  19. {judgeval-0.0.11 → judgeval-0.0.13}/LICENSE.md +0 -0
  20. {judgeval-0.0.11 → judgeval-0.0.13}/Pipfile +0 -0
  21. {judgeval-0.0.11 → judgeval-0.0.13}/Pipfile.lock +0 -0
  22. {judgeval-0.0.11 → judgeval-0.0.13}/README.md +0 -0
  23. {judgeval-0.0.11 → judgeval-0.0.13}/docs/README.md +0 -0
  24. {judgeval-0.0.11 → judgeval-0.0.13}/docs/api_reference/judgment_client.mdx +0 -0
  25. {judgeval-0.0.11 → judgeval-0.0.13}/docs/development.mdx +0 -0
  26. {judgeval-0.0.11 → judgeval-0.0.13}/docs/essentials/code.mdx +0 -0
  27. {judgeval-0.0.11 → judgeval-0.0.13}/docs/essentials/images.mdx +0 -0
  28. {judgeval-0.0.11 → judgeval-0.0.13}/docs/essentials/markdown.mdx +0 -0
  29. {judgeval-0.0.11 → judgeval-0.0.13}/docs/essentials/navigation.mdx +0 -0
  30. {judgeval-0.0.11 → judgeval-0.0.13}/docs/essentials/reusable-snippets.mdx +0 -0
  31. {judgeval-0.0.11 → judgeval-0.0.13}/docs/essentials/settings.mdx +0 -0
  32. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/data_datasets.mdx +0 -0
  33. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/data_examples.mdx +0 -0
  34. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/introduction.mdx +0 -0
  35. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/judges.mdx +0 -0
  36. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/answer_correctness.mdx +0 -0
  37. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/answer_relevancy.mdx +0 -0
  38. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/classifier_scorer.mdx +0 -0
  39. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/contextual_precision.mdx +0 -0
  40. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/contextual_recall.mdx +0 -0
  41. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/contextual_relevancy.mdx +0 -0
  42. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/custom_scorers.mdx +0 -0
  43. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/faithfulness.mdx +0 -0
  44. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/hallucination.mdx +0 -0
  45. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/introduction.mdx +0 -0
  46. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/json_correctness.mdx +0 -0
  47. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/summarization.mdx +0 -0
  48. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/scorers/tool_correctness.mdx +0 -0
  49. {judgeval-0.0.11 → judgeval-0.0.13}/docs/evaluation/unit_testing.mdx +0 -0
  50. {judgeval-0.0.11 → judgeval-0.0.13}/docs/favicon.svg +0 -0
  51. {judgeval-0.0.11 → judgeval-0.0.13}/docs/images/basic_trace_example.png +0 -0
  52. {judgeval-0.0.11 → judgeval-0.0.13}/docs/images/checks-passed.png +0 -0
  53. {judgeval-0.0.11 → judgeval-0.0.13}/docs/images/create_aggressive_scorer.png +0 -0
  54. {judgeval-0.0.11 → judgeval-0.0.13}/docs/images/create_scorer.png +0 -0
  55. {judgeval-0.0.11 → judgeval-0.0.13}/docs/images/evaluation_diagram.png +0 -0
  56. {judgeval-0.0.11 → judgeval-0.0.13}/docs/images/hero-dark.svg +0 -0
  57. {judgeval-0.0.11 → judgeval-0.0.13}/docs/images/hero-light.svg +0 -0
  58. {judgeval-0.0.11 → judgeval-0.0.13}/docs/images/trace_screenshot.png +0 -0
  59. {judgeval-0.0.11 → judgeval-0.0.13}/docs/introduction.mdx +0 -0
  60. {judgeval-0.0.11 → judgeval-0.0.13}/docs/judgment/introduction.mdx +0 -0
  61. {judgeval-0.0.11 → judgeval-0.0.13}/docs/logo/dark.svg +0 -0
  62. {judgeval-0.0.11 → judgeval-0.0.13}/docs/logo/light.svg +0 -0
  63. {judgeval-0.0.11 → judgeval-0.0.13}/docs/mint.json +0 -0
  64. {judgeval-0.0.11 → judgeval-0.0.13}/docs/monitoring/introduction.mdx +0 -0
  65. {judgeval-0.0.11 → judgeval-0.0.13}/docs/monitoring/production_insights.mdx +0 -0
  66. {judgeval-0.0.11 → judgeval-0.0.13}/docs/notebooks/create_dataset.ipynb +0 -0
  67. {judgeval-0.0.11 → judgeval-0.0.13}/docs/notebooks/create_scorer.ipynb +0 -0
  68. {judgeval-0.0.11 → judgeval-0.0.13}/docs/notebooks/demo.ipynb +0 -0
  69. {judgeval-0.0.11 → judgeval-0.0.13}/docs/notebooks/prompt_scorer.ipynb +0 -0
  70. {judgeval-0.0.11 → judgeval-0.0.13}/docs/notebooks/quickstart.ipynb +0 -0
  71. {judgeval-0.0.11 → judgeval-0.0.13}/docs/quickstart.mdx +0 -0
  72. {judgeval-0.0.11 → judgeval-0.0.13}/docs/snippets/snippet-intro.mdx +0 -0
  73. {judgeval-0.0.11 → judgeval-0.0.13}/pytest.ini +0 -0
  74. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/ci_testing/ci_testing.py +0 -0
  75. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/ci_testing/travel_response.txt +0 -0
  76. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/custom_scorers/competitor_mentions.py +0 -0
  77. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/custom_scorers/text2sql.py +0 -0
  78. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/langchain_basic_rag/basic_agentic_rag.ipynb +0 -0
  79. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/langchain_basic_rag/tesla_q3.pdf +0 -0
  80. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/langchain_sales/example_product_price_id_mapping.json +0 -0
  81. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/langchain_sales/sales_agent_with_context.ipynb +0 -0
  82. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/langchain_sales/sample_product_catalog.txt +0 -0
  83. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/cookbooks/openai_travel_agent/populate_db.py +0 -0
  84. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/customer_use/cstone/basic_test.py +0 -0
  85. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/customer_use/cstone/cstone_data.csv +0 -0
  86. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/customer_use/cstone/data.csv +0 -0
  87. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/customer_use/cstone/galen_data.csv +0 -0
  88. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/customer_use/cstone/playground.py +0 -0
  89. {judgeval-0.0.11 → judgeval-0.0.13}/src/demo/customer_use/cstone/results.csv +0 -0
  90. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/__init__.py +0 -0
  91. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/clients.py +0 -0
  92. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/common/__init__.py +0 -0
  93. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/common/exceptions.py +0 -0
  94. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/common/logger.py +0 -0
  95. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/common/utils.py +0 -0
  96. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/__init__.py +0 -0
  97. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/api_example.py +0 -0
  98. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/datasets/__init__.py +0 -0
  99. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/datasets/ground_truth.py +0 -0
  100. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/datasets/utils.py +0 -0
  101. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/result.py +0 -0
  102. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/data/scorer_data.py +0 -0
  103. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/evaluation_run.py +0 -0
  104. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/judges/__init__.py +0 -0
  105. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/judges/base_judge.py +0 -0
  106. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/judges/litellm_judge.py +0 -0
  107. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/judges/mixture_of_judges.py +0 -0
  108. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/judges/together_judge.py +0 -0
  109. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/judges/utils.py +0 -0
  110. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/__init__.py +0 -0
  111. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/api_scorer.py +0 -0
  112. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/base_scorer.py +0 -0
  113. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/exceptions.py +0 -0
  114. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorer.py +0 -0
  115. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/__init__.py +0 -0
  116. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/__init__.py +0 -0
  117. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/answer_correctness.py +0 -0
  118. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/answer_relevancy.py +0 -0
  119. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/contextual_precision.py +0 -0
  120. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/contextual_recall.py +0 -0
  121. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/contextual_relevancy.py +0 -0
  122. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/faithfulness.py +0 -0
  123. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/hallucination.py +0 -0
  124. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/json_correctness.py +0 -0
  125. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/summarization.py +0 -0
  126. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/api_scorers/tool_correctness.py +0 -0
  127. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/classifiers/__init__.py +0 -0
  128. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/classifiers/text2sql/__init__.py +0 -0
  129. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/classifiers/text2sql/text2sql_scorer.py +0 -0
  130. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/__init__.py +0 -0
  131. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/answer_correctness/__init__.py +0 -0
  132. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/answer_correctness/answer_correctness_scorer.py +0 -0
  133. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/answer_correctness/prompts.py +0 -0
  134. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/answer_relevancy/__init__.py +0 -0
  135. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/answer_relevancy/answer_relevancy_scorer.py +0 -0
  136. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/answer_relevancy/prompts.py +0 -0
  137. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_precision/__init__.py +0 -0
  138. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_precision/contextual_precision_scorer.py +0 -0
  139. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_precision/prompts.py +0 -0
  140. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_recall/__init__.py +0 -0
  141. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_recall/contextual_recall_scorer.py +0 -0
  142. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_recall/prompts.py +0 -0
  143. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_relevancy/__init__.py +0 -0
  144. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_relevancy/contextual_relevancy_scorer.py +0 -0
  145. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/contextual_relevancy/prompts.py +0 -0
  146. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/faithfulness/__init__.py +0 -0
  147. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/faithfulness/faithfulness_scorer.py +0 -0
  148. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/faithfulness/prompts.py +0 -0
  149. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/hallucination/__init__.py +0 -0
  150. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/hallucination/hallucination_scorer.py +0 -0
  151. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/hallucination/prompts.py +0 -0
  152. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/json_correctness/__init__.py +0 -0
  153. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/json_correctness/json_correctness_scorer.py +0 -0
  154. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/summarization/__init__.py +0 -0
  155. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/summarization/prompts.py +0 -0
  156. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/summarization/summarization_scorer.py +0 -0
  157. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/tool_correctness/__init__.py +0 -0
  158. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/judgeval_scorers/local_implementations/tool_correctness/tool_correctness_scorer.py +0 -0
  159. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/prompt_scorer.py +0 -0
  160. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/score.py +0 -0
  161. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/scorers/utils.py +0 -0
  162. {judgeval-0.0.11 → judgeval-0.0.13}/src/judgeval/tracer/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: judgeval
3
- Version: 0.0.11
3
+ Version: 0.0.13
4
4
  Summary: Judgeval Package
5
5
  Project-URL: Homepage, https://github.com/JudgmentLabs/judgeval
6
6
  Project-URL: Issues, https://github.com/JudgmentLabs/judgeval/issues
@@ -12,27 +12,34 @@ The `Tracer` class is used to trace the execution of your LLM system.
12
12
  ```python
13
13
  from judgeval.common.tracer import Tracer
14
14
 
15
- tracer = Tracer()
15
+ tracer = Tracer(project_name="my_project")
16
16
  ```
17
17
 
18
18
  <Note>
19
- The `Tracer` class is a singleton, so you only need to initialize it once in your application.
19
+ The `Tracer` class is a singleton, so you only need to initialize it once in your application.
20
+ The `project_name` enables you to group traces by workflow, keeping all your evaluations and
21
+ observability tooling in one place.
20
22
  </Note>
21
23
 
22
- ## Exporting traces
24
+ ## Explicitly exporting traces
23
25
 
24
26
  When using the `.trace()` context manager, you can control how your traces are exported to the Judgment platform by
25
27
  providing the `project_name` argument. This allows you to group traces by workflow, keeping all your evaluations and
26
28
  observability tooling in one place.
27
29
 
28
30
  ```python
29
- with tracer.trace("my_workflow", project_name="my_project"):
31
+ with tracer.trace(
32
+ name="my_workflow",
33
+ project_name="my_project",
34
+ overwrite=True
35
+ ) as trace:
30
36
  ...
31
37
  ```
32
38
 
33
39
  `.trace()` has the following args:
34
40
  - `name`: The name of the trace. Can be make unique to each workflow run by using a timestamp or other unique identifier.
35
41
  - `project_name`: The name of the project to use for the trace. Used to group traces by workflow.
42
+ - `overwrite`: Whether to overwrite the trace with the same `name` if it already exists.
36
43
 
37
44
  The `trace()` context manager yields a `TraceClient` object.
38
45
 
@@ -32,7 +32,7 @@ large-scale evaluations. [Contact us](mailto:contact@judgmentlabs.ai) if you're
32
32
  sensitive data that has to reside in your private VPCs.
33
33
  </Note>
34
34
 
35
- # Create your first evaluation
35
+ # Create Your First Evaluation
36
36
 
37
37
  ```python sample_eval.py
38
38
  from judgeval import JudgmentClient
@@ -68,6 +68,48 @@ is a scorer that checks if the output is hallucinated relative to the retrieved
68
68
  To learn more about using the Judgment Client to run evaluations, click [here](/api_reference/judgment_client).
69
69
  </Tip>
70
70
 
71
+ # Create Your First Trace
72
+
73
+ Beyond experimentation, `judgeval` supports monitoring your LLM systems in **production**.
74
+ Using our `tracing` module, you can **track your LLM system outputs from end to end**, allowing you to visualize the flow of your LLM system.
75
+ Additionally, you can **enable evaluations to run in real-time** using Judgment's state-of-the-art judge models.
76
+
77
+ ```python trace_example.py
78
+ from judgeval.common.tracer import Tracer, wrap
79
+ from openai import OpenAI
80
+
81
+ client = wrap(OpenAI())
82
+ judgment = Tracer(project_name="my_project")
83
+
84
+ @judgment.observe(span_type="tool")
85
+ def my_tool():
86
+ return "Hello world!"
87
+
88
+ @judgment.observe(span_type="function")
89
+ def main():
90
+ res = client.chat.completions.create(
91
+ model="gpt-4o",
92
+ messages=[{"role": "user", "content": f"{my_tool()}"}]
93
+ )
94
+ return res.choices[0].message.content
95
+ ```
96
+
97
+
98
+ <div style={{display: 'flex', justifyContent: 'center'}}>
99
+ ![Alt text](/images/trace_screenshot.png "Image of a RAG pipeline trace")
100
+ </div>
101
+
102
+ There are many benefits of monitoring your LLM systems in production with `judgeval`, including:
103
+ - Detecting hallucinations and other quality issues **before they reach your customers**
104
+ - Automatically creating experimental datasets from your **real-world production cases** for future improvement/optimization
105
+ - Track and create alerts on **any metric** (e.g. latency, cost, hallucination, etc.)
106
+
107
+ <Tip>
108
+ To learn more about `judgeval`'s tracing module, click [here](/tracing/introduction).
109
+ </Tip>
110
+
111
+
112
+
71
113
  # Create Your First Scorer
72
114
  `judgeval` offers three kinds of LLM scorers for your evaluation needs: ready-made, classifier scorers, and custom scorers.
73
115
 
@@ -264,22 +306,3 @@ A `Project` keeps track of `Evaluation Run`s in your project. Each `Evaluation R
264
306
  You can try different models (e.g. `gpt-4o`, `claude-3-5-sonnet`, etc.) and prompt templates in each `Evaluation Run` to find the
265
307
  optimal setup for your LLM system.
266
308
  </Tip>
267
-
268
- ## Monitoring LLM Systems in Production
269
-
270
- Beyond experimenting and measuring historical performance, `judgeval` supports monitoring your LLM systems in **production**.
271
- Using our `tracing` module, you can **track your LLM system outputs from end to end**, allowing you to visualize the flow of your LLM system.
272
- Additionally, you can **enable evaluations to run in real-time** using Judgment's state-of-the-art judge models.
273
-
274
- <div style={{display: 'flex', justifyContent: 'center'}}>
275
- ![Alt text](/images/trace_screenshot.png "Image of a RAG pipeline trace")
276
- </div>
277
-
278
- There are many benefits of monitoring your LLM systems in production with `judgeval`, including:
279
- - Detecting hallucinations and other quality issues **before they reach your customers**
280
- - Automatically creating experimental datasets from your **real-world production cases** for future improvement/optimization
281
- - Track and create alerts on **any metric** (e.g. latency, cost, hallucination, etc.)
282
-
283
- <Tip>
284
- To learn more about `judgeval`'s tracing module, click [here](/tracing/introduction).
285
- </Tip>
@@ -18,24 +18,25 @@ Using tracing, you can:
18
18
 
19
19
  ## Tracing Your Workflow ##
20
20
 
21
- Setting up tracing with `judgeval` takes three simple steps:
21
+ Setting up tracing with `judgeval` takes two simple steps:
22
22
 
23
- ### 1. Initialize a tracer with your API key
23
+ ### 1. Initialize a tracer with your API key and project name
24
24
 
25
25
  ```python
26
26
  from judgeval.common.tracer import Tracer
27
27
 
28
- judgment = Tracer() # loads from JUDGMENT_API_KEY env var
28
+ judgment = Tracer(project_name="my_project") # loads from JUDGMENT_API_KEY env var
29
29
  ```
30
30
 
31
31
  <Note>
32
- The [Judgment tracer](/api_reference/trace) is a singleton object that should be shared across your application.
32
+ The [Judgment tracer](/api_reference/trace) is a singleton object that should be shared across your application.
33
+ Your project name will be used to organize your traces in one place on the Judgment platform.
33
34
  </Note>
34
35
 
35
36
 
36
37
  ### 2. Wrap your workflow components
37
38
 
38
- `judgeval` provides three wrapping mechanisms for your workflow components:
39
+ `judgeval` provides wrapping mechanisms for your workflow components:
39
40
 
40
41
  #### `wrap()` ####
41
42
  The `wrap()` function goes over your LLM client (e.g. OpenAI, Anthropic, etc.) and captures metadata surrounding your LLM calls, such as:
@@ -44,6 +45,14 @@ The `wrap()` function goes over your LLM client (e.g. OpenAI, Anthropic, etc.) a
44
45
  - Prompt/Completion
45
46
  - Model name
46
47
 
48
+ Here's an example of using `wrap()` on an OpenAI client:
49
+ ```python
50
+ from openai import OpenAI
51
+ from judgeval.common.tracer import wrap
52
+
53
+ client = wrap(OpenAI())
54
+ ```
55
+
47
56
  #### `@observe` ####
48
57
  The `@observe` decorator wraps your functions/tools and captures metadata surrounding your function calls, such as:
49
58
  - Latency
@@ -63,30 +72,20 @@ def my_tool():
63
72
  ```
64
73
 
65
74
  <Note>
66
- The `@observe` decorator is used on top of helper functions that you write, but is not designed to be used
67
- on your "main" function. For more information, see the `context manager` section below.
75
+ `span_type` is a string that you can use to categorize and organize your trace spans.
76
+ Span types are displayed on the trace UI to easily nagivate a visualization of your workflow.
77
+ Common span types include `tool`, `function`, `retriever`, `database`, `web search`, etc.
68
78
  </Note>
69
79
 
70
- #### `context manager` ####
71
-
72
- In your main function (e.g. the one that executes the primary workflow logic), you can use the `with judgment.trace()` context manager to trace the entire workflow.
73
-
74
- The context manager can **save/print the state of the trace at any point in the workflow**.
75
- This is useful for debugging or exporting any state of your workflow to run an evaluation from!
76
-
77
- <Tip>
78
- The `with judgment.trace()` context manager detects any `@observe` decorated functions or wrapped LLM calls within the context and automatically captures their metadata.
79
- </Tip>
80
-
81
80
 
82
81
  #### Putting it all Together
83
- Here's a complete example of using the `with judgment.trace()` context manager with the other tracing mechanisms:
82
+ Here's a complete example of using judgeval's tracing mechanisms:
84
83
  ```python
85
84
  from judgeval.common.tracer import Tracer, wrap
86
85
  from openai import OpenAI
87
86
 
88
87
  openai_client = wrap(OpenAI())
89
- judgment = Tracer() # loads from JUDGMENT_API_KEY env var
88
+ judgment = Tracer(project_name="my_project") # loads from JUDGMENT_API_KEY env var
90
89
 
91
90
  @judgment.observe(span_type="tool")
92
91
  def my_tool():
@@ -101,28 +100,10 @@ def my_llm_call():
101
100
  )
102
101
  return res.choices[0].message.content
103
102
 
103
+ @judgment.observe(span_type="function")
104
104
  def main():
105
- with judgment.trace(
106
- "main_workflow",
107
- project_name="my_project"
108
- ) as trace:
109
- res = my_llm_call()
110
- trace.save()
111
- trace.print()
112
- return res
113
- ```
114
-
115
- The printed trace appears as follows on the terminal:
116
- ```
117
- → main_workflow (trace: main_workflow)
118
- → my_llm_call (trace: my_llm_call)
119
- Input: {'args': [], 'kwargs': {}}
120
- → my_tool (trace: my_tool)
121
- Input: {'args': [], 'kwargs': {}}
122
- Output: Hello world!
123
- ← my_tool (0.000s)
124
- Output: Hello! How can I assist you today?
125
- ← my_llm_call (0.789s)
105
+ res = my_llm_call()
106
+ return res
126
107
  ```
127
108
 
128
109
  And the trace will appear on the Judgment platform as follows:
@@ -142,32 +123,27 @@ To execute an asynchronous evaluation, you can use the `trace.async_evaluate()`
142
123
 
143
124
  ```python
144
125
  from judgeval.common.tracer import Tracer
145
- from judgeval.scorers import FaithfulnessScorer
126
+ from judgeval.scorers import AnswerRelevancyScorer
146
127
 
147
- judgment = Tracer()
128
+ judgment = Tracer(project_name="my_project")
148
129
 
130
+ @judgment.observe(span_type="function")
149
131
  def main():
150
- with judgment.trace(
151
- "main_workflow",
152
- project_name="my_project"
153
- ) as trace:
154
- retrieved_info = ... # from knowledge base
155
- res = ... # your main workflow logic
156
-
157
- judgment.get_current_trace().async_evaluate(
158
- scorers=[FaithfulnesssScorer(threshold=0.5)],
159
- input="",
160
- actual_output=res,
161
- retrieval_context=[retrieved_info],
162
- model="gpt-4o-mini",
163
- )
164
- return res
132
+ query = "What is the capital of France?"
133
+ res = ... # Your workflow logic
134
+
135
+ judgment.get_current_trace().async_evaluate(
136
+ scorers=[AnswerRelevancyScorer(threshold=0.5)],
137
+ input="",
138
+ actual_output=res,
139
+ model="gpt-4o",
140
+ )
141
+ return res
165
142
  ```
166
143
 
167
144
  <Tip>
168
- You can organize how your async evaluation runs are logged to the Judgment platform by using the
169
- `project_name` argument in the `trace` context manager. See our [API documentation](/api_reference/trace)
170
- for more information.
145
+ Your async evaluations will be logged to the Judgment platform as part of the original trace and
146
+ a new evaluation will be created on the Judgment platform.
171
147
  </Tip>
172
148
 
173
149
  ## Example: OpenAI Travel Agent
@@ -183,4 +159,53 @@ In this video, we'll walk through all of the topics covered in this guide by tra
183
159
  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
184
160
  referrerpolicy="strict-origin-when-cross-origin"
185
161
  allowfullscreen
186
- ></iframe>
162
+ ></iframe>
163
+
164
+
165
+ ## Advanced: Customizing Traces Using the Context Manager ##
166
+
167
+ If you need to customize your tracing context, you can use the `with judgment.trace()` context manager.
168
+
169
+ The context manager can **save/print the state of the trace at any point in the workflow**.
170
+ This is useful for debugging or exporting any state of your workflow to run an evaluation from!
171
+
172
+ <Tip>
173
+ The `with judgment.trace()` context manager detects any `@observe` decorated functions or wrapped LLM calls within the context and automatically captures their metadata.
174
+ </Tip>
175
+
176
+ Here's an example of using the context manager to trace a workflow:
177
+ ```python
178
+ from judgeval.common.tracer import Tracer, wrap
179
+ from openai import OpenAI
180
+
181
+ judgment = Tracer(project_name="my_project")
182
+ client = wrap(OpenAI())
183
+
184
+ @judgment.observe(span_type="tool")
185
+ def my_tool():
186
+ return "Hello world!"
187
+
188
+ def main():
189
+ with judgment.trace(name="my_workflow") as trace:
190
+ res = client.chat.completions.create(
191
+ model="gpt-4o",
192
+ messages=[{"role": "user", "content": f"{my_tool()}"}]
193
+ )
194
+
195
+ trace.print() # prints the state of the trace to console
196
+ trace.save() # saves the current state of the trace to the Judgment platform
197
+
198
+ return res.choices[0].message.content
199
+ ```
200
+
201
+ <Warning>
202
+ The `with judgment.trace()` context manager should only be used if you need to customize the context
203
+ over which you're tracing. In most cases, you should trace using the `@observe` decorator.
204
+ </Warning>
205
+
206
+
207
+
208
+
209
+
210
+
211
+
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "judgeval"
3
- version = "0.0.11"
3
+ version = "0.0.13"
4
4
  authors = [
5
5
  { name="Andrew Li", email="andrew@judgmentlabs.ai" },
6
6
  { name="Alex Shan", email="alex@judgmentlabs.ai" },
@@ -0,0 +1,106 @@
1
+ import os
2
+ import asyncio
3
+ from typing import Dict, List
4
+ from openai import OpenAI
5
+ from uuid import uuid4
6
+ from dotenv import load_dotenv
7
+
8
+ from judgeval.tracer import Tracer, wrap
9
+ from judgeval.scorers import AnswerRelevancyScorer, FaithfulnessScorer
10
+
11
+ # Initialize clients
12
+ load_dotenv()
13
+ judgment = Tracer(api_key=os.getenv("JUDGMENT_API_KEY"), project_name="restaurant_bot")
14
+ client = wrap(OpenAI())
15
+
16
+ @judgment.observe(span_type="Research")
17
+ async def search_restaurants(cuisine: str, location: str = "nearby") -> List[Dict]:
18
+ """Search for restaurants matching the cuisine type."""
19
+ # Simulate API call to restaurant database
20
+ prompt = f"Find 3 popular {cuisine} restaurants {location}. Return ONLY a JSON array of objects with 'name', 'rating', and 'price_range' fields. No other text."
21
+
22
+ response = client.chat.completions.create(
23
+ model="gpt-4",
24
+ messages=[
25
+ {"role": "system", "content": """You are a restaurant search expert.
26
+ Return ONLY valid JSON arrays containing restaurant objects.
27
+ Example format: [{"name": "Restaurant Name", "rating": 4.5, "price_range": "$$"}]
28
+ Do not include any other text or explanations."""},
29
+ {"role": "user", "content": prompt}
30
+ ]
31
+ )
32
+
33
+ try:
34
+ import json
35
+ return json.loads(response.choices[0].message.content)
36
+ except json.JSONDecodeError as e:
37
+ print(f"Error parsing JSON response: {response.choices[0].message.content}")
38
+ return [{"name": "Error fetching restaurants", "rating": 0, "price_range": "N/A"}]
39
+
40
+ @judgment.observe(span_type="Research")
41
+ async def get_menu_highlights(restaurant_name: str) -> List[str]:
42
+ """Get popular menu items for a restaurant."""
43
+ prompt = f"What are 3 must-try dishes at {restaurant_name}?"
44
+
45
+ response = client.chat.completions.create(
46
+ model="gpt-4",
47
+ messages=[
48
+ {"role": "system", "content": "You are a food critic. List only the dish names."},
49
+ {"role": "user", "content": prompt}
50
+ ]
51
+ )
52
+
53
+ judgment.get_current_trace().async_evaluate(
54
+ scorers=[AnswerRelevancyScorer(threshold=0.5)],
55
+ input=prompt,
56
+ actual_output=response.choices[0].message.content,
57
+ model="gpt-4",
58
+ )
59
+
60
+ return response.choices[0].message.content.split("\n")
61
+
62
+ @judgment.observe(span_type="function")
63
+ async def generate_recommendation(cuisine: str, restaurants: List[Dict], menu_items: Dict[str, List[str]]) -> str:
64
+ """Generate a natural language recommendation."""
65
+ context = f"""
66
+ Cuisine: {cuisine}
67
+ Restaurants: {restaurants}
68
+ Popular Items: {menu_items}
69
+ """
70
+
71
+ response = client.chat.completions.create(
72
+ model="gpt-4",
73
+ messages=[
74
+ {"role": "system", "content": "You are a helpful food recommendation bot. Provide a natural recommendation based on the data."},
75
+ {"role": "user", "content": context}
76
+ ]
77
+ )
78
+ return response.choices[0].message.content
79
+
80
+ @judgment.observe(span_type="Research")
81
+ async def get_food_recommendations(cuisine: str) -> str:
82
+ """Main function to get restaurant recommendations."""
83
+ # Search for restaurants
84
+ restaurants = await search_restaurants(cuisine)
85
+
86
+ # Get menu highlights for each restaurant
87
+ menu_items = {}
88
+ for restaurant in restaurants:
89
+ menu_items[restaurant['name']] = await get_menu_highlights(restaurant['name'])
90
+
91
+ # Generate final recommendation
92
+ recommendation = await generate_recommendation(cuisine, restaurants, menu_items)
93
+ judgment.get_current_trace().async_evaluate(
94
+ scorers=[AnswerRelevancyScorer(threshold=0.5), FaithfulnessScorer(threshold=1.0)],
95
+ input=f"Create a recommendation for a restaurant and dishes based on the desired cuisine: {cuisine}",
96
+ actual_output=recommendation,
97
+ retrieval_context=[str(restaurants), str(menu_items)],
98
+ model="gpt-4",
99
+ )
100
+ return recommendation
101
+
102
+ if __name__ == "__main__":
103
+ cuisine = input("What kind of food would you like to eat? ")
104
+ recommendation = asyncio.run(get_food_recommendations(cuisine))
105
+ print("\nHere are my recommendations:\n")
106
+ print(recommendation)
@@ -10,9 +10,11 @@ from chromadb.utils import embedding_functions
10
10
  from judgeval.common.tracer import Tracer, wrap
11
11
  from demo.cookbooks.openai_travel_agent.populate_db import destinations_data
12
12
  from demo.cookbooks.openai_travel_agent.tools import search_tavily
13
+ from judgeval.scorers import AnswerRelevancyScorer, FaithfulnessScorer
14
+
13
15
 
14
16
  client = wrap(openai.Client(api_key=os.getenv("OPENAI_API_KEY")))
15
- judgment = Tracer()
17
+ judgment = Tracer(api_key=os.getenv("JUDGMENT_API_KEY"), project_name="travel_agent_demo")
16
18
 
17
19
  def populate_vector_db(collection, destinations_data):
18
20
  """
@@ -45,6 +47,12 @@ async def get_flights(destination):
45
47
  """Search for flights to the destination."""
46
48
  prompt = f"Flights to {destination} from major cities"
47
49
  flights_search = search_tavily(prompt)
50
+ judgment.get_current_trace().async_evaluate(
51
+ scorers=[AnswerRelevancyScorer(threshold=0.5)],
52
+ input=prompt,
53
+ actual_output=flights_search,
54
+ model="gpt-4",
55
+ )
48
56
  return flights_search
49
57
 
50
58
  @judgment.observe(span_type="tool")
@@ -52,6 +60,12 @@ async def get_weather(destination, start_date, end_date):
52
60
  """Search for weather information."""
53
61
  prompt = f"Weather forecast for {destination} from {start_date} to {end_date}"
54
62
  weather_search = search_tavily(prompt)
63
+ judgment.get_current_trace().async_evaluate(
64
+ scorers=[AnswerRelevancyScorer(threshold=0.5)],
65
+ input=prompt,
66
+ actual_output=weather_search,
67
+ model="gpt-4",
68
+ )
55
69
  return weather_search
56
70
 
57
71
  def initialize_vector_db():
@@ -125,21 +139,23 @@ async def create_travel_plan(destination, start_date, end_date, research_data):
125
139
  {"role": "user", "content": prompt}
126
140
  ]
127
141
  ).choices[0].message.content
142
+
143
+ judgment.get_current_trace().async_evaluate(
144
+ scorers=[FaithfulnessScorer(threshold=0.5)],
145
+ input=prompt,
146
+ actual_output=response,
147
+ retrieval_context=[str(vector_db_context), str(research_data)],
148
+ model="gpt-4",
149
+ )
128
150
 
129
151
  return response
130
152
 
131
-
153
+ @judgment.observe(span_type="Main Function", overwrite=True)
132
154
  async def generate_itinerary(destination, start_date, end_date):
133
155
  """Main function to generate a travel itinerary."""
134
-
135
- with judgment.trace(
136
- f"generate_itinerary_demo_{uuid4()}",
137
- project_name="travel_agent_demo"
138
- ) as trace:
139
- research_data = await research_destination(destination, start_date, end_date)
140
- res = await create_travel_plan(destination, start_date, end_date, research_data)
141
- trace.save()
142
- return res
156
+ research_data = await research_destination(destination, start_date, end_date)
157
+ res = await create_travel_plan(destination, start_date, end_date, research_data)
158
+ return res
143
159
 
144
160
 
145
161
  if __name__ == "__main__":
@@ -5,7 +5,7 @@ from tavily import TavilyClient
5
5
 
6
6
  from judgeval.common.tracer import Tracer
7
7
 
8
- judgment = Tracer()
8
+ judgment = Tracer(project_name="travel_agent_demo")
9
9
 
10
10
  @judgment.observe(span_type="search_tool")
11
11
  def search_tavily(query):
@@ -53,10 +53,10 @@ def run_judgment_evaluation(examples: List[Example]):
53
53
  scorer = FaithfulnessScorer(threshold=1.0)
54
54
 
55
55
  output = client.run_evaluation(
56
- model="osiris-mini",
56
+ model="osiris-large",
57
57
  examples=examples,
58
58
  scorers=[scorer],
59
- eval_run_name="cstone-basic-test-osiris-mini-2",
59
+ eval_run_name="cstone-basic-test-osiris-large-1",
60
60
  project_name="cstone_faithfulness_testing",
61
61
  override=True,
62
62
  )
@@ -66,7 +66,7 @@ def run_judgment_evaluation(examples: List[Example]):
66
66
  score = result.scorers_data[0].score
67
67
  scores.append(score)
68
68
 
69
- return [score < 0.95 for score in scores]
69
+ return [score < 1 for score in scores]
70
70
 
71
71
  def run_patronus_evaluation(examples: List[Example]):
72
72
  """
@@ -94,7 +94,7 @@ def run_patronus_evaluation(examples: List[Example]):
94
94
 
95
95
  print(f"patronus scores: {scores}")
96
96
 
97
- return [score < 0.95 for score in scores]
97
+ return [score < 0.9 for score in scores]
98
98
 
99
99
  def evaluate_predictions(predictions):
100
100
  """Calculate metrics comparing predictions to gold labels"""