langfun 0.1.2.dev202504290805__tar.gz → 0.1.2.dev202504300804__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.

Potentially problematic release.


This version of langfun might be problematic. Click here for more details.

Files changed (168) hide show
  1. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/PKG-INFO +1 -1
  2. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/__init__.py +3 -0
  3. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/agentic/action_eval.py +6 -1
  4. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/base_test.py +4 -4
  5. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/evaluation.py +78 -12
  6. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/evaluation_test.py +2 -0
  7. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/__init__.py +3 -0
  8. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/mapping.py +5 -2
  9. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/parsing_test.py +1 -1
  10. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/querying.py +205 -18
  11. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/querying_test.py +286 -47
  12. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun.egg-info/PKG-INFO +1 -1
  13. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/LICENSE +0 -0
  14. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/README.md +0 -0
  15. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/__init__.py +0 -0
  16. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/agentic/__init__.py +0 -0
  17. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/agentic/action.py +0 -0
  18. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/agentic/action_eval_test.py +0 -0
  19. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/agentic/action_test.py +0 -0
  20. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/__init__.py +0 -0
  21. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/__init__.py +0 -0
  22. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/correction.py +0 -0
  23. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/correction_test.py +0 -0
  24. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/execution.py +0 -0
  25. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/execution_test.py +0 -0
  26. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/generation.py +0 -0
  27. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/generation_test.py +0 -0
  28. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/parsing.py +0 -0
  29. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/parsing_test.py +0 -0
  30. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/sandboxing.py +0 -0
  31. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/coding/python/sandboxing_test.py +0 -0
  32. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/component.py +0 -0
  33. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/component_test.py +0 -0
  34. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/concurrent.py +0 -0
  35. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/concurrent_test.py +0 -0
  36. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/console.py +0 -0
  37. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/console_test.py +0 -0
  38. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/data/__init__.py +0 -0
  39. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/data/conversion/__init__.py +0 -0
  40. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/data/conversion/anthropic.py +0 -0
  41. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/data/conversion/anthropic_test.py +0 -0
  42. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/data/conversion/gemini.py +0 -0
  43. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/data/conversion/gemini_test.py +0 -0
  44. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/data/conversion/openai.py +0 -0
  45. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/data/conversion/openai_test.py +0 -0
  46. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/__init__.py +0 -0
  47. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/base.py +0 -0
  48. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/matching.py +0 -0
  49. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/matching_test.py +0 -0
  50. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/patching.py +0 -0
  51. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/patching_test.py +0 -0
  52. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/scoring.py +0 -0
  53. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/scoring_test.py +0 -0
  54. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/__init__.py +0 -0
  55. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/checkpointing.py +0 -0
  56. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/checkpointing_test.py +0 -0
  57. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/eval_test_helper.py +0 -0
  58. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/example.py +0 -0
  59. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/example_test.py +0 -0
  60. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/experiment.py +0 -0
  61. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/experiment_test.py +0 -0
  62. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/metric_values.py +0 -0
  63. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/metric_values_test.py +0 -0
  64. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/metrics.py +0 -0
  65. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/metrics_test.py +0 -0
  66. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/progress.py +0 -0
  67. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/progress_test.py +0 -0
  68. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/progress_tracking.py +0 -0
  69. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/progress_tracking_test.py +0 -0
  70. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/reporting.py +0 -0
  71. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/reporting_test.py +0 -0
  72. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/runners.py +0 -0
  73. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/eval/v2/runners_test.py +0 -0
  74. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/langfunc.py +0 -0
  75. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/langfunc_test.py +0 -0
  76. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/language_model.py +0 -0
  77. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/language_model_test.py +0 -0
  78. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/__init__.py +0 -0
  79. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/anthropic.py +0 -0
  80. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/anthropic_test.py +0 -0
  81. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/azure_openai.py +0 -0
  82. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/azure_openai_test.py +0 -0
  83. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/cache/__init__.py +0 -0
  84. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/cache/base.py +0 -0
  85. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/cache/in_memory.py +0 -0
  86. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/cache/in_memory_test.py +0 -0
  87. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/compositional.py +0 -0
  88. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/compositional_test.py +0 -0
  89. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/deepseek.py +0 -0
  90. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/deepseek_test.py +0 -0
  91. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/fake.py +0 -0
  92. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/fake_test.py +0 -0
  93. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/gemini.py +0 -0
  94. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/gemini_test.py +0 -0
  95. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/google_genai.py +0 -0
  96. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/google_genai_test.py +0 -0
  97. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/groq.py +0 -0
  98. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/groq_test.py +0 -0
  99. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/llama_cpp.py +0 -0
  100. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/llama_cpp_test.py +0 -0
  101. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/openai.py +0 -0
  102. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/openai_compatible.py +0 -0
  103. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/openai_compatible_test.py +0 -0
  104. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/openai_test.py +0 -0
  105. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/rest.py +0 -0
  106. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/rest_test.py +0 -0
  107. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/vertexai.py +0 -0
  108. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/llms/vertexai_test.py +0 -0
  109. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/logging.py +0 -0
  110. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/logging_test.py +0 -0
  111. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/memories/__init__.py +0 -0
  112. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/memories/conversation_history.py +0 -0
  113. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/memories/conversation_history_test.py +0 -0
  114. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/memory.py +0 -0
  115. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/message.py +0 -0
  116. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/message_test.py +0 -0
  117. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/__init__.py +0 -0
  118. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/audio.py +0 -0
  119. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/audio_test.py +0 -0
  120. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/image.py +0 -0
  121. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/image_test.py +0 -0
  122. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/mime.py +0 -0
  123. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/mime_test.py +0 -0
  124. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/pdf.py +0 -0
  125. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/pdf_test.py +0 -0
  126. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/video.py +0 -0
  127. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modalities/video_test.py +0 -0
  128. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modality.py +0 -0
  129. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/modality_test.py +0 -0
  130. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/natural_language.py +0 -0
  131. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/natural_language_test.py +0 -0
  132. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/sampling.py +0 -0
  133. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/sampling_test.py +0 -0
  134. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/completion.py +0 -0
  135. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/completion_test.py +0 -0
  136. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/description.py +0 -0
  137. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/description_test.py +0 -0
  138. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/function_generation.py +0 -0
  139. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/function_generation_test.py +0 -0
  140. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/mapping_test.py +0 -0
  141. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/parsing.py +0 -0
  142. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/schema.py +0 -0
  143. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/schema_generation.py +0 -0
  144. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/schema_generation_test.py +0 -0
  145. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/schema_test.py +0 -0
  146. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/scoring.py +0 -0
  147. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/scoring_test.py +0 -0
  148. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/tokenization.py +0 -0
  149. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/structured/tokenization_test.py +0 -0
  150. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/subscription.py +0 -0
  151. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/subscription_test.py +0 -0
  152. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/template.py +0 -0
  153. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/template_test.py +0 -0
  154. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/__init__.py +0 -0
  155. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/completion.py +0 -0
  156. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/completion_test.py +0 -0
  157. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/conversation.py +0 -0
  158. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/conversation_test.py +0 -0
  159. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/demonstration.py +0 -0
  160. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/demonstration_test.py +0 -0
  161. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/selfplay.py +0 -0
  162. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun/core/templates/selfplay_test.py +0 -0
  163. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun.egg-info/SOURCES.txt +0 -0
  164. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun.egg-info/dependency_links.txt +0 -0
  165. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun.egg-info/requires.txt +0 -0
  166. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/langfun.egg-info/top_level.txt +0 -0
  167. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/setup.cfg +0 -0
  168. {langfun-0.1.2.dev202504290805 → langfun-0.1.2.dev202504300804}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202504290805
3
+ Version: 0.1.2.dev202504300804
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -37,6 +37,9 @@ generate_class = structured.generate_class
37
37
 
38
38
  track_queries = structured.track_queries
39
39
 
40
+ # Context manager for setting the query protocol for the scope.
41
+ query_protocol = structured.query_protocol
42
+
40
43
  # Helper function for map-reduce style querying.
41
44
  query_and_reduce = structured.query_and_reduce
42
45
 
@@ -35,13 +35,18 @@ class ActionEval(lf.eval.v2.Evaluation):
35
35
  example_input = example.input
36
36
  action = example_input.action
37
37
  session = action_lib.Session(id=f'{self.id}#example-{example.id}')
38
+
39
+ # NOTE(daiyip): Setting session as metadata before action execution, so we
40
+ # could use `Evaluation.state.in_progress_examples` to access the session
41
+ # for status reporting from other threads.
42
+ example.metadata['session'] = session
43
+
38
44
  with lf.logging.use_log_level('fatal'):
39
45
  kwargs = self.action_args.copy()
40
46
  kwargs.update(verbose=True)
41
47
  action(session=session, **kwargs)
42
48
  return session.final_result, dict(session=session)
43
49
 
44
-
45
50
  #
46
51
  # TODO(daiyip): Remove V1 once V2 is fully launched.
47
52
  #
@@ -195,7 +195,7 @@ class EvaluationTest(unittest.TestCase):
195
195
  score=1.0,
196
196
  logprobs=None,
197
197
  is_cached=False,
198
- usage=lf.LMSamplingUsage(387, 24, 411),
198
+ usage=lf.LMSamplingUsage(428, 24, 452),
199
199
  tags=['lm-response', 'lm-output', 'transformed'],
200
200
  ),
201
201
  )
@@ -234,12 +234,12 @@ class EvaluationTest(unittest.TestCase):
234
234
  }
235
235
  ),
236
236
  usage=dict(
237
- total_prompt_tokens=774,
237
+ total_prompt_tokens=856,
238
238
  total_completion_tokens=25,
239
239
  num_usages=2,
240
- average_prompt_tokens=387,
240
+ average_prompt_tokens=428,
241
241
  average_completion_tokens=12,
242
- average_total_tokens=399,
242
+ average_total_tokens=440,
243
243
  ),
244
244
  ),
245
245
  )
@@ -167,6 +167,8 @@ class Evaluation(experiment_lib.Experiment):
167
167
  example.input = self.example_input_by_id(example.id)
168
168
 
169
169
  checkpointed = self._state.ckpt_example(example.id)
170
+ self._state.update(example, in_progress=True)
171
+
170
172
  with pg.timeit('evaluate') as timeit, lf.track_usages() as usage_summary:
171
173
  if checkpointed is None or checkpointed.has_error:
172
174
  if checkpointed is None:
@@ -221,7 +223,7 @@ class Evaluation(experiment_lib.Experiment):
221
223
  if example.newly_processed:
222
224
  example.end_time = time.time()
223
225
 
224
- self._state.update(example)
226
+ self._state.update(example, in_progress=False)
225
227
  return example
226
228
 
227
229
  def _process(
@@ -501,6 +503,21 @@ class Evaluation(experiment_lib.Experiment):
501
503
  )
502
504
  )
503
505
 
506
+ def _in_progress_tab() -> pg.views.html.controls.Tab | None:
507
+ """Renders a tab for the in progress examples."""
508
+ if not self.state.in_progress_examples:
509
+ return None
510
+ return pg.views.html.controls.Tab(
511
+ label='In Progress',
512
+ content=pg.Html.element(
513
+ 'div', [
514
+ self._in_progress_view(
515
+ list(self.state.in_progress_examples.values())
516
+ )
517
+ ]
518
+ )
519
+ )
520
+
504
521
  def _metric_tab(metric: metrics_lib.Metric) -> pg.views.html.controls.Tab:
505
522
  """Renders a tab for a metric (group)."""
506
523
  return pg.views.html.controls.Tab(
@@ -571,10 +588,9 @@ class Evaluation(experiment_lib.Experiment):
571
588
  pg.views.html.controls.TabControl(
572
589
  [
573
590
  _definition_tab(),
574
- ] + [
575
- _metric_tab(m) for m in self.metrics
576
- ] + [
577
- _logs_tab()
591
+ [_metric_tab(m) for m in self.metrics],
592
+ _in_progress_tab(),
593
+ _logs_tab(),
578
594
  ],
579
595
  selected=1,
580
596
  )
@@ -598,6 +614,27 @@ class Evaluation(experiment_lib.Experiment):
598
614
  css_classes=['eval-details'],
599
615
  )
600
616
 
617
+ def _in_progress_view(
618
+ self, in_progress_examples: list[example_lib.Example]
619
+ ) -> pg.Html:
620
+ """Renders a HTML view for the in-progress examples."""
621
+ current_time = time.time()
622
+ logs = [f'(Total {len(in_progress_examples)} examples in progress)']
623
+ for example in in_progress_examples:
624
+ if example.newly_processed:
625
+ logs.append(
626
+ f'Example {example.id}: In progress for '
627
+ f'{current_time - example.start_time:.2f} seconds.'
628
+ )
629
+ else:
630
+ logs.append(f'Example {example.id}: Recomputing metrics...')
631
+ return pg.Html.element(
632
+ 'textarea',
633
+ [pg.Html.escape('\n'.join(logs))],
634
+ readonly=True,
635
+ css_classes=['logs-textarea'],
636
+ )
637
+
601
638
  def _html_tree_view_config(self) -> dict[str, Any]:
602
639
  return dict(
603
640
  css_classes=['eval-card'] if self.is_leaf else None
@@ -716,14 +753,27 @@ class EvaluationState:
716
753
  'Whether the example is evaluated.'
717
754
  ] = False
718
755
 
756
+ in_progress: Annotated[
757
+ bool,
758
+ (
759
+ 'Whether the example is in progress. '
760
+ )
761
+ ] = False
762
+
719
763
  newly_processed: Annotated[
720
764
  bool,
721
- 'Whether the example is newly processed.'
765
+ (
766
+ 'Whether the example is newly processed. '
767
+ 'Applicable only when evaluated is True.'
768
+ )
722
769
  ] = False
723
770
 
724
771
  has_error: Annotated[
725
772
  bool,
726
- 'Whether the example has error.'
773
+ (
774
+ 'Whether the example has error. '
775
+ 'Applicable only when evaluated is True.'
776
+ )
727
777
  ] = False
728
778
 
729
779
  def __init__(self):
@@ -732,6 +782,7 @@ class EvaluationState:
732
782
  self._evaluation_status: dict[
733
783
  int, EvaluationState.ExampleStatus
734
784
  ] = {}
785
+ self._in_progress_examples: dict[int, example_lib.Example] = {}
735
786
 
736
787
  def load(
737
788
  self,
@@ -758,6 +809,11 @@ class EvaluationState:
758
809
  """Returns the evaluation status of the examples."""
759
810
  return self._evaluation_status
760
811
 
812
+ @property
813
+ def in_progress_examples(self) -> dict[int, example_lib.Example]:
814
+ """Returns the in-progress examples."""
815
+ return self._in_progress_examples
816
+
761
817
  @property
762
818
  def ckpt_examples(self) -> dict[int, example_lib.Example]:
763
819
  """Returns the unevaluated examples from checkpoints."""
@@ -773,17 +829,27 @@ class EvaluationState:
773
829
  example_id, EvaluationState.ExampleStatus()
774
830
  )
775
831
 
776
- def update(self, example: example_lib.Example) -> None:
832
+ def update(self, example: example_lib.Example, in_progress: bool) -> None:
777
833
  """Updates the state with the given example."""
778
- self._update_status(example)
779
- # Processed examples will be removed once it's done.
780
- self._ckpt_examples.pop(example.id, None)
834
+ self._update_status(example, in_progress)
835
+
836
+ if in_progress:
837
+ self._in_progress_examples[example.id] = example
838
+ else:
839
+ self._in_progress_examples.pop(example.id, None)
840
+ # Processed examples will be removed once it's done.
841
+ self._ckpt_examples.pop(example.id, None)
781
842
 
782
- def _update_status(self, example: example_lib.Example) -> None:
843
+ def _update_status(
844
+ self,
845
+ example: example_lib.Example,
846
+ in_progress: bool
847
+ ) -> None:
783
848
  """Updates the evaluation status of the example."""
784
849
  self._evaluation_status[example.id] = (
785
850
  EvaluationState.ExampleStatus(
786
851
  evaluated=example.output != pg.MISSING_VALUE,
852
+ in_progress=in_progress,
787
853
  newly_processed=example.newly_processed,
788
854
  has_error=example.has_error,
789
855
  )
@@ -79,8 +79,10 @@ class EvaluationTest(unittest.TestCase):
79
79
  exp = eval_test_helper.TestEvaluation()
80
80
  example = exp.evaluate(Example(id=3))
81
81
  self.assertTrue(exp.state.get_status(3).evaluated)
82
+ self.assertFalse(exp.state.get_status(3).in_progress)
82
83
  self.assertTrue(exp.state.get_status(3).newly_processed)
83
84
  self.assertFalse(exp.state.get_status(3).has_error)
85
+ self.assertEqual(exp.state.in_progress_examples, {})
84
86
  self.assertTrue(example.newly_processed)
85
87
  self.assertEqual(example.input, pg.Dict(x=2, y=4, groundtruth=6))
86
88
  self.assertEqual(example.output, 6)
@@ -55,8 +55,11 @@ from langfun.core.structured.parsing import call
55
55
 
56
56
  from langfun.core.structured.querying import track_queries
57
57
  from langfun.core.structured.querying import QueryInvocation
58
+
59
+ from langfun.core.structured.querying import LfQuery
58
60
  from langfun.core.structured.querying import query
59
61
  from langfun.core.structured.querying import query_and_reduce
62
+ from langfun.core.structured.querying import query_protocol
60
63
 
61
64
  from langfun.core.structured.querying import query_prompt
62
65
  from langfun.core.structured.querying import query_output
@@ -340,8 +340,11 @@ class Mapping(lf.LangFunc):
340
340
  schema_title: Annotated[str, 'The section title for schema.'] = 'SCHEMA'
341
341
 
342
342
  protocol: Annotated[
343
- schema_lib.SchemaProtocol,
344
- 'The protocol for representing the schema and value.',
343
+ str,
344
+ (
345
+ 'A string representing the protocol for formatting the prompt. '
346
+ 'Built-in Langfun protocols are: `python` and `json`.'
347
+ ),
345
348
  ] = 'python'
346
349
 
347
350
  #
@@ -646,7 +646,7 @@ class CallTest(unittest.TestCase):
646
646
  score=1.0,
647
647
  logprobs=None,
648
648
  is_cached=False,
649
- usage=lf.LMSamplingUsage(315, 1, 316),
649
+ usage=lf.LMSamplingUsage(356, 1, 357),
650
650
  tags=['lm-response', 'lm-output', 'transformed']
651
651
  ),
652
652
  )
@@ -15,8 +15,9 @@
15
15
 
16
16
  import contextlib
17
17
  import functools
18
+ import inspect
18
19
  import time
19
- from typing import Annotated, Any, Callable, Iterator, Type, Union
20
+ from typing import Annotated, Any, Callable, ClassVar, Iterator, Type, Union
20
21
  import uuid
21
22
 
22
23
  import langfun.core as lf
@@ -26,8 +27,35 @@ import pyglove as pg
26
27
 
27
28
 
28
29
  @lf.use_init_args(['schema', 'default', 'examples'])
29
- class _QueryStructure(mapping.Mapping):
30
- """Query an object out from a natural language text."""
30
+ class LfQuery(mapping.Mapping):
31
+ """Base class for different implementations of `lf.query`.
32
+
33
+ By subclassing this class, users could create variations of prompts for
34
+ `lf.query` and associated them with specific protocols and versions.
35
+
36
+ For example:
37
+
38
+ ```
39
+ class _MyLfQuery(LFQuery):
40
+ protocol = 'my_format'
41
+ version = '1.0'
42
+
43
+ template_str = inspect.cleandoc(
44
+ '''
45
+ ...
46
+ '''
47
+ )
48
+ mapping_template = lf.Template(
49
+ '''
50
+ ...
51
+ '''
52
+ )
53
+
54
+ lf.query(..., protocol='my_format:1.0')
55
+ ```
56
+
57
+ (THIS IS NOT A TEMPLATE)
58
+ """
31
59
 
32
60
  context_title = 'CONTEXT'
33
61
  input_title = 'INPUT_OBJECT'
@@ -37,8 +65,81 @@ class _QueryStructure(mapping.Mapping):
37
65
  schema_lib.schema_spec(), 'Required schema for parsing.'
38
66
  ]
39
67
 
68
+ # A map from (protocol, version) to the query structure class.
69
+ # This is used to map different protocols/versions to different templates.
70
+ # So users can use `lf.query(..., protocol='<protocol>:<version>')` to use
71
+ # a specific version of the prompt. We use this feature to support variations
72
+ # of prompts and maintain backward compatibility.
73
+ _OOP_PROMPT_MAP: ClassVar[
74
+ dict[
75
+ str, # protocol.
76
+ dict[
77
+ str, # version.
78
+ Type['LfQuery']
79
+ ]
80
+ ]
81
+ ] = {}
82
+
83
+ # This the flag to update default protocol version.
84
+ _DEFAULT_PROTOCOL_VERSIONS: ClassVar[dict[str, str]] = {
85
+ 'python': '2.0',
86
+ 'json': '1.0',
87
+ }
88
+
89
+ def __init_subclass__(cls) -> Any:
90
+ super().__init_subclass__()
91
+ if not inspect.isabstract(cls):
92
+ protocol = cls.__schema__['protocol'].default_value
93
+ version_dict = cls._OOP_PROMPT_MAP.get(protocol)
94
+ if version_dict is None:
95
+ version_dict = {}
96
+ cls._OOP_PROMPT_MAP[protocol] = version_dict
97
+ dest_cls = version_dict.get(cls.version)
98
+ if dest_cls is not None and dest_cls.__type_name__ != cls.__type_name__:
99
+ raise ValueError(
100
+ f'Version {cls.version} is already registered for {dest_cls!r} '
101
+ f'under protocol {protocol!r}. Please use a different version.'
102
+ )
103
+ version_dict[cls.version] = cls
104
+
105
+ @classmethod
106
+ def from_protocol(cls, protocol: str) -> Type['LfQuery']:
107
+ """Returns a query structure from the given protocol and version."""
108
+ if ':' in protocol:
109
+ protocol, version = protocol.split(':')
110
+ else:
111
+ version = cls._DEFAULT_PROTOCOL_VERSIONS.get(protocol)
112
+ if version is None:
113
+ version_dict = cls._OOP_PROMPT_MAP.get(protocol)
114
+ if version_dict is None:
115
+ raise ValueError(
116
+ f'Protocol {protocol!r} is not supported. Available protocols: '
117
+ f'{sorted(cls._OOP_PROMPT_MAP.keys())}.'
118
+ )
119
+ elif len(version_dict) == 1:
120
+ version = list(version_dict.keys())[0]
121
+ else:
122
+ raise ValueError(
123
+ f'Multiple versions found for protocol {protocol!r}, please '
124
+ f'specify a version with "{protocol}:<version>".'
125
+ )
126
+
127
+ version_dict = cls._OOP_PROMPT_MAP.get(protocol)
128
+ if version_dict is None:
129
+ raise ValueError(
130
+ f'Protocol {protocol!r} is not supported. Available protocols: '
131
+ f'{sorted(cls._OOP_PROMPT_MAP.keys())}.'
132
+ )
133
+ dest_cls = version_dict.get(version)
134
+ if dest_cls is None:
135
+ raise ValueError(
136
+ f'Version {version!r} is not supported for protocol {protocol!r}. '
137
+ f'Available versions: {sorted(version_dict.keys())}.'
138
+ )
139
+ return dest_cls
40
140
 
41
- class _QueryStructureJson(_QueryStructure):
141
+
142
+ class _LfQueryJsonV1(LfQuery):
42
143
  """Query a structured value using JSON as the protocol."""
43
144
 
44
145
  preamble = """
@@ -58,12 +159,13 @@ class _QueryStructureJson(_QueryStructure):
58
159
  {"result": {"_type": "langfun.core.structured.query.Answer", "final_answer": 2}}
59
160
  """
60
161
 
162
+ version = '1.0'
61
163
  protocol = 'json'
62
164
  schema_title = 'SCHEMA'
63
165
  output_title = 'JSON'
64
166
 
65
167
 
66
- class _QueryStructurePython(_QueryStructure):
168
+ class _LfQueryPythonV1(LfQuery):
67
169
  """Query a structured value using Python as the protocol."""
68
170
 
69
171
  preamble = """
@@ -87,20 +189,87 @@ class _QueryStructurePython(_QueryStructure):
87
189
  )
88
190
  ```
89
191
  """
192
+ version = '1.0'
90
193
  protocol = 'python'
91
194
  schema_title = 'OUTPUT_TYPE'
92
195
  output_title = 'OUTPUT_OBJECT'
196
+ mapping_template = lf.Template(
197
+ """
198
+ {%- if example.context -%}
199
+ {{ context_title}}:
200
+ {{ example.context | indent(2, True)}}
93
201
 
202
+ {% endif -%}
94
203
 
95
- def _query_structure_cls(
96
- protocol: schema_lib.SchemaProtocol,
97
- ) -> Type[_QueryStructure]:
98
- if protocol == 'json':
99
- return _QueryStructureJson
100
- elif protocol == 'python':
101
- return _QueryStructurePython
102
- else:
103
- raise ValueError(f'Unknown protocol: {protocol!r}.')
204
+ {{ input_title }}:
205
+ {{ example.input_repr(protocol, compact=False) | indent(2, True) }}
206
+
207
+ {% if example.schema -%}
208
+ {{ schema_title }}:
209
+ {{ example.schema_repr(protocol) | indent(2, True) }}
210
+
211
+ {% endif -%}
212
+
213
+ {{ output_title }}:
214
+ {%- if example.has_output %}
215
+ {{ example.output_repr(protocol, compact=False) | indent(2, True) }}
216
+ {% endif -%}
217
+ """
218
+ )
219
+
220
+
221
+ class _LfQueryPythonV2(LfQuery):
222
+ """Query a structured value using Python as the protocol."""
223
+
224
+ preamble = """
225
+ Please respond to the last {{ input_title }} with {{ output_title }} only according to {{ schema_title }}.
226
+
227
+ {{ input_title }}:
228
+ 1 + 1 =
229
+
230
+ {{ schema_title }}:
231
+ Answer
232
+
233
+ ```python
234
+ class Answer:
235
+ final_answer: int
236
+ ```
237
+
238
+ {{ output_title }}:
239
+ ```python
240
+ output = Answer(
241
+ final_answer=2
242
+ )
243
+ ```
244
+ """
245
+ version = '2.0'
246
+ protocol = 'python'
247
+ input_title = 'REQUEST'
248
+ schema_title = 'OUTPUT PYTHON TYPE'
249
+ output_title = 'OUTPUT PYTHON OBJECT'
250
+ mapping_template = lf.Template(
251
+ """
252
+ {%- if example.context -%}
253
+ {{ context_title}}:
254
+ {{ example.context | indent(2, True)}}
255
+
256
+ {% endif -%}
257
+
258
+ {{ input_title }}:
259
+ {{ example.input_repr(protocol, compact=False) | indent(2, True) }}
260
+
261
+ {% if example.schema -%}
262
+ {{ schema_title }}:
263
+ {{ example.schema_repr(protocol) | indent(2, True) }}
264
+
265
+ {% endif -%}
266
+
267
+ {{ output_title }}:
268
+ {%- if example.has_output %}
269
+ {{ example.output_repr(protocol, compact=False, assign_to_var='output') | indent(2, True) }}
270
+ {% endif -%}
271
+ """
272
+ )
104
273
 
105
274
 
106
275
  def query(
@@ -116,7 +285,7 @@ def query(
116
285
  response_postprocess: Callable[[str], str] | None = None,
117
286
  autofix: int = 0,
118
287
  autofix_lm: lf.LanguageModel | None = None,
119
- protocol: schema_lib.SchemaProtocol = 'python',
288
+ protocol: str | None = None,
120
289
  returns_message: bool = False,
121
290
  skip_lm: bool = False,
122
291
  invocation_id: str | None = None,
@@ -259,8 +428,14 @@ def query(
259
428
  disable auto-fixing. Not supported with the `'json'` protocol.
260
429
  autofix_lm: The LM to use for auto-fixing. Defaults to the `autofix_lm`
261
430
  from `lf.context` or the main `lm`.
262
- protocol: Format for schema representation. Choices are `'json'` or
263
- `'python'`. Default is `'python'`.
431
+ protocol: Format for schema representation. Builtin choices are `'json'` or
432
+ `'python'`, users could extend with their own protocols by subclassing
433
+ `lf.structured.LfQuery'. Also protocol could be specified with a version
434
+ in the format of 'protocol:version', e.g., 'python:1.0', so users could
435
+ use a specific version of the prompt based on the protocol. Please see the
436
+ documentation of `LfQuery` for more details. If None, the protocol from
437
+ context manager `lf.query_protocol` will be used, or 'python' if not
438
+ specified.
264
439
  returns_message: If `True`, returns an `lf.Message` object instead of
265
440
  the final parsed result.
266
441
  skip_lm: If `True`, skips the LLM call and returns the rendered
@@ -280,6 +455,9 @@ def query(
280
455
  """
281
456
  # Internal usage logging.
282
457
 
458
+ if protocol is None:
459
+ protocol = lf.context_value('__query_protocol__', 'python')
460
+
283
461
  invocation_id = invocation_id or f'query@{uuid.uuid4().hex[-7:]}'
284
462
  # Multiple quries will be issued when `lm` is a list or `num_samples` is
285
463
  # greater than 1.
@@ -382,7 +560,7 @@ def query(
382
560
  output_message = lf.AIMessage(processed_text, source=output_message)
383
561
  else:
384
562
  # Query with structured output.
385
- output_message = _query_structure_cls(protocol)(
563
+ output_message = LfQuery.from_protocol(protocol)(
386
564
  input=(
387
565
  query_input.render(lm=lm)
388
566
  if isinstance(query_input, lf.Template)
@@ -436,6 +614,15 @@ def query(
436
614
  return output_message if returns_message else _result(output_message)
437
615
 
438
616
 
617
+ @contextlib.contextmanager
618
+ def query_protocol(protocol: str) -> Iterator[None]:
619
+ """Context manager for setting the query protocol for the scope."""
620
+ with lf.context(__query_protocol__=protocol):
621
+ try:
622
+ yield
623
+ finally:
624
+ pass
625
+
439
626
  #
440
627
  # Helper function for map-reduce style querying.
441
628
  #