langfun 0.1.2.dev202509240805__tar.gz → 0.1.2.dev202509250804__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 (187) hide show
  1. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/PKG-INFO +1 -1
  2. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/__init__.py +1 -1
  3. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/base_environment.py +70 -39
  4. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/base_feature.py +25 -12
  5. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/base_sandbox.py +204 -74
  6. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/base_test.py +166 -399
  7. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/interface.py +167 -35
  8. langfun-0.1.2.dev202509250804/langfun/env/test_utils.py +473 -0
  9. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun.egg-info/PKG-INFO +1 -1
  10. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun.egg-info/SOURCES.txt +2 -1
  11. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/LICENSE +0 -0
  12. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/README.md +0 -0
  13. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/__init__.py +0 -0
  14. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/assistant/capabilities/gui/__init__.py +0 -0
  15. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/assistant/capabilities/gui/bounding_box_parser.py +0 -0
  16. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/assistant/capabilities/gui/bounding_box_parser_test.py +0 -0
  17. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/assistant/capabilities/gui/drawing.py +0 -0
  18. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/assistant/capabilities/gui/drawing_test.py +0 -0
  19. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/assistant/capabilities/gui/location.py +0 -0
  20. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/assistant/capabilities/gui/location_test.py +0 -0
  21. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/__init__.py +0 -0
  22. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/agentic/__init__.py +0 -0
  23. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/agentic/action.py +0 -0
  24. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/agentic/action_eval.py +0 -0
  25. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/agentic/action_eval_test.py +0 -0
  26. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/agentic/action_test.py +0 -0
  27. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/async_support.py +0 -0
  28. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/async_support_test.py +0 -0
  29. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/__init__.py +0 -0
  30. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/__init__.py +0 -0
  31. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/correction.py +0 -0
  32. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/correction_test.py +0 -0
  33. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/execution.py +0 -0
  34. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/execution_test.py +0 -0
  35. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/generation.py +0 -0
  36. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/generation_test.py +0 -0
  37. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/parsing.py +0 -0
  38. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/parsing_test.py +0 -0
  39. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/sandboxing.py +0 -0
  40. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/coding/python/sandboxing_test.py +0 -0
  41. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/component.py +0 -0
  42. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/component_test.py +0 -0
  43. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/concurrent.py +0 -0
  44. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/concurrent_test.py +0 -0
  45. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/console.py +0 -0
  46. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/console_test.py +0 -0
  47. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/data/__init__.py +0 -0
  48. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/data/conversion/__init__.py +0 -0
  49. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/data/conversion/anthropic.py +0 -0
  50. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/data/conversion/anthropic_test.py +0 -0
  51. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/data/conversion/gemini.py +0 -0
  52. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/data/conversion/gemini_test.py +0 -0
  53. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/data/conversion/openai.py +0 -0
  54. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/data/conversion/openai_test.py +0 -0
  55. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/__init__.py +0 -0
  56. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/base.py +0 -0
  57. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/base_test.py +0 -0
  58. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/matching.py +0 -0
  59. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/matching_test.py +0 -0
  60. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/patching.py +0 -0
  61. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/patching_test.py +0 -0
  62. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/scoring.py +0 -0
  63. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/scoring_test.py +0 -0
  64. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/__init__.py +0 -0
  65. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/checkpointing.py +0 -0
  66. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/checkpointing_test.py +0 -0
  67. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/eval_test_helper.py +0 -0
  68. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/evaluation.py +0 -0
  69. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/evaluation_test.py +0 -0
  70. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/example.py +0 -0
  71. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/example_test.py +0 -0
  72. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/experiment.py +0 -0
  73. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/experiment_test.py +0 -0
  74. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/metric_values.py +0 -0
  75. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/metric_values_test.py +0 -0
  76. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/metrics.py +0 -0
  77. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/metrics_test.py +0 -0
  78. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/progress.py +0 -0
  79. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/progress_test.py +0 -0
  80. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/progress_tracking.py +0 -0
  81. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/progress_tracking_test.py +0 -0
  82. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/reporting.py +0 -0
  83. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/reporting_test.py +0 -0
  84. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/runners.py +0 -0
  85. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/eval/v2/runners_test.py +0 -0
  86. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/langfunc.py +0 -0
  87. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/langfunc_test.py +0 -0
  88. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/language_model.py +0 -0
  89. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/language_model_test.py +0 -0
  90. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/__init__.py +0 -0
  91. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/anthropic.py +0 -0
  92. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/anthropic_test.py +0 -0
  93. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/azure_openai.py +0 -0
  94. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/azure_openai_test.py +0 -0
  95. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/cache/__init__.py +0 -0
  96. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/cache/base.py +0 -0
  97. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/cache/in_memory.py +0 -0
  98. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/cache/in_memory_test.py +0 -0
  99. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/compositional.py +0 -0
  100. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/compositional_test.py +0 -0
  101. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/deepseek.py +0 -0
  102. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/deepseek_test.py +0 -0
  103. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/fake.py +0 -0
  104. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/fake_test.py +0 -0
  105. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/gemini.py +0 -0
  106. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/gemini_test.py +0 -0
  107. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/google_genai.py +0 -0
  108. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/google_genai_test.py +0 -0
  109. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/groq.py +0 -0
  110. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/groq_test.py +0 -0
  111. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/llama_cpp.py +0 -0
  112. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/llama_cpp_test.py +0 -0
  113. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/openai.py +0 -0
  114. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/openai_compatible.py +0 -0
  115. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/openai_compatible_test.py +0 -0
  116. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/openai_test.py +0 -0
  117. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/rest.py +0 -0
  118. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/rest_test.py +0 -0
  119. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/vertexai.py +0 -0
  120. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/llms/vertexai_test.py +0 -0
  121. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/logging.py +0 -0
  122. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/logging_test.py +0 -0
  123. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/memories/__init__.py +0 -0
  124. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/memories/conversation_history.py +0 -0
  125. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/memories/conversation_history_test.py +0 -0
  126. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/memory.py +0 -0
  127. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/message.py +0 -0
  128. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/message_test.py +0 -0
  129. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/__init__.py +0 -0
  130. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/audio.py +0 -0
  131. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/audio_test.py +0 -0
  132. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/image.py +0 -0
  133. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/image_test.py +0 -0
  134. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/mime.py +0 -0
  135. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/mime_test.py +0 -0
  136. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/pdf.py +0 -0
  137. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/pdf_test.py +0 -0
  138. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/video.py +0 -0
  139. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modalities/video_test.py +0 -0
  140. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modality.py +0 -0
  141. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/modality_test.py +0 -0
  142. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/natural_language.py +0 -0
  143. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/natural_language_test.py +0 -0
  144. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/sampling.py +0 -0
  145. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/sampling_test.py +0 -0
  146. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/__init__.py +0 -0
  147. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/completion.py +0 -0
  148. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/completion_test.py +0 -0
  149. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/description.py +0 -0
  150. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/description_test.py +0 -0
  151. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/function_generation.py +0 -0
  152. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/function_generation_test.py +0 -0
  153. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/mapping.py +0 -0
  154. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/mapping_test.py +0 -0
  155. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/parsing.py +0 -0
  156. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/parsing_test.py +0 -0
  157. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/querying.py +0 -0
  158. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/querying_test.py +0 -0
  159. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/schema.py +0 -0
  160. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/schema_generation.py +0 -0
  161. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/schema_generation_test.py +0 -0
  162. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/schema_test.py +0 -0
  163. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/scoring.py +0 -0
  164. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/scoring_test.py +0 -0
  165. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/tokenization.py +0 -0
  166. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/structured/tokenization_test.py +0 -0
  167. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/subscription.py +0 -0
  168. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/subscription_test.py +0 -0
  169. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/template.py +0 -0
  170. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/template_test.py +0 -0
  171. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/__init__.py +0 -0
  172. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/completion.py +0 -0
  173. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/completion_test.py +0 -0
  174. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/conversation.py +0 -0
  175. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/conversation_test.py +0 -0
  176. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/demonstration.py +0 -0
  177. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/demonstration_test.py +0 -0
  178. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/selfplay.py +0 -0
  179. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/core/templates/selfplay_test.py +0 -0
  180. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/interface_test.py +0 -0
  181. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/load_balancers.py +0 -0
  182. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun/env/load_balancers_test.py +0 -0
  183. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun.egg-info/dependency_links.txt +0 -0
  184. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun.egg-info/requires.txt +0 -0
  185. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/langfun.egg-info/top_level.txt +0 -0
  186. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/setup.cfg +0 -0
  187. {langfun-0.1.2.dev202509240805 → langfun-0.1.2.dev202509250804}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202509240805
3
+ Version: 0.1.2.dev202509250804
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -22,7 +22,7 @@ from langfun.env.interface import EnvironmentOutageError
22
22
  from langfun.env.interface import EnvironmentOverloadError
23
23
  from langfun.env.interface import SandboxError
24
24
  from langfun.env.interface import SandboxStateError
25
- # from langfun.env.base import SandboxOverloadError
25
+ from langfun.env.interface import EnvironmentEventHandler
26
26
 
27
27
  from langfun.env.interface import Environment
28
28
  from langfun.env.interface import Sandbox
@@ -60,7 +60,7 @@ class BaseEnvironment(interface.Environment):
60
60
  'will be used as both min and max size. If 0, sandboxes will be '
61
61
  'created on demand and shutdown when user session ends.'
62
62
  )
63
- ] = 1
63
+ ] = (0, 256)
64
64
 
65
65
  load_balancer: Annotated[
66
66
  load_balancers.LoadBalancer,
@@ -132,7 +132,7 @@ class BaseEnvironment(interface.Environment):
132
132
  random if self.random_seed is None else random.Random(self.random_seed)
133
133
  )
134
134
 
135
- self._maintenance_thread = None
135
+ self._housekeep_thread = None
136
136
  self._offline_start_time = None
137
137
 
138
138
  #
@@ -170,6 +170,11 @@ class BaseEnvironment(interface.Environment):
170
170
  ).hex[:7]
171
171
  return f'session-{suffix}'
172
172
 
173
+ @property
174
+ def housekeep_counter(self) -> int:
175
+ """Returns the housekeeping counter."""
176
+ return self._housekeep_counter
177
+
173
178
  #
174
179
  # Subclasses can override:
175
180
  #
@@ -189,36 +194,36 @@ class BaseEnvironment(interface.Environment):
189
194
  def _start(self) -> None:
190
195
  """Implementation of starting the environment."""
191
196
  if self.min_pool_size > 0:
192
- self._sandbox_pool = [
193
- sandbox
194
- for _, sandbox, _ in lf.concurrent_map(
195
- lambda i: self._bring_up_sandbox_with_retry(
196
- sandbox_id=str(i), shutdown_env_upon_outage=False
197
- ),
198
- range(self.min_pool_size),
199
- silence_on_errors=None,
200
- max_workers=min(
201
- self.pool_operation_max_parallelism,
202
- self.min_pool_size
203
- ),
204
- )
205
- ]
197
+ self._sandbox_pool = [None] * self.min_pool_size
198
+ for i, sandbox, _ in lf.concurrent_map(
199
+ lambda i: self._bring_up_sandbox_with_retry(
200
+ sandbox_id=str(i), shutdown_env_upon_outage=False
201
+ ),
202
+ range(self.min_pool_size),
203
+ silence_on_errors=None,
204
+ max_workers=min(
205
+ self.pool_operation_max_parallelism,
206
+ self.min_pool_size
207
+ ),
208
+ ):
209
+ self._sandbox_pool[i] = sandbox
206
210
  self._next_sandbox_id = len(self._sandbox_pool)
207
- self._maintenance_thread = threading.Thread(
208
- target=self._maintenance_loop, daemon=True
211
+ self._housekeep_thread = threading.Thread(
212
+ target=self._housekeep_loop, daemon=True
209
213
  )
210
- self._maintenance_count = 0
211
- self._maintenance_thread.start()
214
+ self._housekeep_counter = 0
215
+ self._housekeep_thread.start()
212
216
 
213
217
  def _shutdown(self) -> None:
214
218
  """Implementation of shutting down the environment."""
215
- if (self._maintenance_thread is not None
216
- and threading.current_thread() is not self._maintenance_thread):
217
- self._maintenance_thread.join()
218
- self._maintenance_thread = None
219
+ if (self._housekeep_thread is not None
220
+ and threading.current_thread() is not self._housekeep_thread):
221
+ self._housekeep_thread.join()
222
+ self._housekeep_thread = None
219
223
 
220
224
  def _shutdown_sandbox(sandbox: base_sandbox.BaseSandbox) -> None:
221
- sandbox.shutdown()
225
+ if sandbox is not None:
226
+ sandbox.shutdown()
222
227
 
223
228
  if self._sandbox_pool:
224
229
  _ = list(
@@ -303,18 +308,19 @@ class BaseEnvironment(interface.Environment):
303
308
  f'it is in {self._status.value!r} status.'
304
309
  )
305
310
 
311
+ starting_time = time.time()
306
312
  try:
307
- with pg.timeit('env.start') as t:
308
- self._start()
309
- self._start_time = time.time()
313
+ self._start()
314
+ self._start_time = time.time()
315
+ self._set_status(self.Status.ONLINE)
316
+ self.on_start(duration=time.time() - starting_time)
317
+
310
318
  pg.logging.info(
311
319
  '[%s]: %s started in %.2f seconds.',
312
- self.id, self.__class__.__name__, t.elapse
320
+ self.id, self.__class__.__name__, time.time() - starting_time
313
321
  )
314
- self._set_status(self.Status.ONLINE)
315
- self.on_start()
316
322
  except BaseException as e:
317
- self.on_start(error=e)
323
+ self.on_start(duration=time.time() - starting_time, error=e)
318
324
  self.shutdown()
319
325
  raise e
320
326
 
@@ -474,13 +480,14 @@ class BaseEnvironment(interface.Environment):
474
480
  # Environment maintenance loop.
475
481
  #
476
482
 
477
- def _maintenance_loop(self) -> None:
478
- """Maintains the server pool."""
483
+ def _housekeep_loop(self) -> None:
484
+ """Housekeeping loop for the environment."""
479
485
  pg.logging.info(
480
486
  '[%s]: %s maintenance thread started.', self.id, self.__class__.__name__
481
487
  )
482
488
  stats_report_time = time.time()
483
489
  while self._status not in (self.Status.SHUTTING_DOWN, self.Status.OFFLINE):
490
+ housekeep_start_time = time.time()
484
491
  if time.time() - stats_report_time > self.stats_report_interval:
485
492
  pg.logging.info(
486
493
  '[%s] %s stats: %s.',
@@ -496,9 +503,17 @@ class BaseEnvironment(interface.Environment):
496
503
  dead_pool_indices
497
504
  ):
498
505
  self.shutdown()
499
- self._maintenance_count += 1
506
+ self._housekeep_counter += 1
507
+ self.on_housekeep(
508
+ time.time() - housekeep_start_time,
509
+ interface.EnvironmentOutageError(
510
+ environment=self,
511
+ offline_duration=self.offline_duration
512
+ )
513
+ )
500
514
  break
501
- self._maintenance_count += 1
515
+ self._housekeep_counter += 1
516
+ self.on_housekeep(time.time() - housekeep_start_time)
502
517
  time.sleep(1)
503
518
 
504
519
  def _replace_dead_sandboxes(self, dead_pool_indices: list[int]) -> bool:
@@ -526,6 +541,8 @@ class BaseEnvironment(interface.Environment):
526
541
  str(i), shutdown_env_upon_outage=False
527
542
  )
528
543
 
544
+ # TODO(daiyip): Consider to loose the condition to allow some dead
545
+ # sandboxes to be replaced successfully.
529
546
  return not any([
530
547
  error for _, _, error in lf.concurrent_map(
531
548
  _replace, dead_pool_indices,
@@ -540,12 +557,26 @@ class BaseEnvironment(interface.Environment):
540
557
  # Event handlers subclasses can override.
541
558
  #
542
559
 
543
- def on_start(self, error: BaseException | None = None) -> None:
560
+ def on_start(
561
+ self,
562
+ duration: float, error: BaseException | None = None
563
+ ) -> None:
544
564
  """Called when the environment is started."""
545
565
  for handler in self.event_handlers:
546
- handler.on_environment_start(self, error)
566
+ handler.on_environment_start(self, duration, error)
567
+
568
+ def on_housekeep(
569
+ self,
570
+ duration: float,
571
+ error: BaseException | None = None
572
+ ) -> None:
573
+ """Called when the environment finishes a round of housekeeping."""
574
+ housekeep_counter = self.housekeep_counter
575
+ for handler in self.event_handlers:
576
+ handler.on_environment_housekeep(self, housekeep_counter, duration, error)
547
577
 
548
578
  def on_shutdown(self, error: BaseException | None = None) -> None:
549
579
  """Called when the environment is shutdown."""
580
+ lifetime = (time.time() - self.start_time) if self.start_time else 0.0
550
581
  for handler in self.event_handlers:
551
- handler.on_environment_shutdown(self, error)
582
+ handler.on_environment_shutdown(self, lifetime, error)
@@ -23,6 +23,7 @@ the `Environment` and `Sandbox` interfaces directly.
23
23
  """
24
24
 
25
25
  import functools
26
+ import time
26
27
  from typing import Annotated, Callable
27
28
 
28
29
  from langfun.env import interface
@@ -82,6 +83,7 @@ class BaseFeature(interface.Feature):
82
83
  """Called when the feature is bound."""
83
84
  super()._on_bound()
84
85
  self._sandbox = None
86
+ self._housekeep_counter = 0
85
87
 
86
88
  @functools.cached_property
87
89
  def name(self) -> str:
@@ -115,13 +117,14 @@ class BaseFeature(interface.Feature):
115
117
  ) -> None:
116
118
  """Triggers an event handler."""
117
119
  error = None
120
+ start_time = time.time()
118
121
  try:
119
122
  action()
120
123
  except BaseException as e: # pylint: disable=broad-except
121
124
  error = e
122
125
  raise
123
126
  finally:
124
- event_handler(error=error)
127
+ event_handler(duration=time.time() - start_time, error=error)
125
128
 
126
129
  def setup(self, sandbox: interface.Sandbox) -> None:
127
130
  """Sets up the feature."""
@@ -146,7 +149,10 @@ class BaseFeature(interface.Feature):
146
149
 
147
150
  def housekeep(self) -> None:
148
151
  """Performs housekeeping for the feature."""
149
- self._do(self._housekeep, self.on_housekeep)
152
+ try:
153
+ self._do(self._housekeep, self.on_housekeep)
154
+ finally:
155
+ self._housekeep_counter += 1
150
156
 
151
157
  #
152
158
  # Event handlers subclasses can override.
@@ -154,51 +160,58 @@ class BaseFeature(interface.Feature):
154
160
 
155
161
  def on_setup(
156
162
  self,
163
+ duration: float,
157
164
  error: BaseException | None = None
158
165
  ) -> None:
159
166
  """Called when the feature is setup."""
160
- self.sandbox.on_feature_setup(self, error)
167
+ self.sandbox.on_feature_setup(self, duration, error)
161
168
 
162
169
  def on_teardown(
163
170
  self,
171
+ duration: float,
164
172
  error: BaseException | None = None
165
173
  ) -> None:
166
174
  """Called when the feature is teardown."""
167
- self.sandbox.on_feature_teardown(self, error)
175
+ self.sandbox.on_feature_teardown(self, duration, error)
168
176
 
169
177
  def on_housekeep(
170
178
  self,
179
+ duration: float,
171
180
  error: BaseException | None = None
172
181
  ) -> None:
173
182
  """Called when the feature has done housekeeping."""
174
- self.sandbox.on_feature_housekeep(self, error)
183
+ self.sandbox.on_feature_housekeep(
184
+ self, self._housekeep_counter, duration, error
185
+ )
175
186
 
176
187
  def on_setup_session(
177
188
  self,
189
+ duration: float,
178
190
  error: BaseException | None = None,
179
191
  ) -> None:
180
192
  """Called when the feature is setup for a user session."""
181
- self.sandbox.on_feature_setup_session(self, error)
193
+ self.sandbox.on_feature_setup_session(self, duration, error)
182
194
 
183
195
  def on_teardown_session(
184
196
  self,
197
+ duration: float,
185
198
  error: BaseException | None = None,
186
199
  ) -> None:
187
200
  """Called when the feature is teardown for a user session."""
188
- self.sandbox.on_feature_teardown_session(self, error)
201
+ self.sandbox.on_feature_teardown_session(self, duration, error)
189
202
 
190
- def on_session_activity(
203
+ def on_activity(
191
204
  self,
192
- session_id: str,
193
205
  name: str,
206
+ duration: float,
194
207
  error: BaseException | None,
195
208
  **kwargs
196
209
  ) -> None:
197
210
  """Called when a sandbox activity is performed."""
198
- self.sandbox.on_session_activity(
199
- session_id=session_id,
200
- name=name,
211
+ self.sandbox.on_activity(
212
+ name=f'{self.name}.{name}',
201
213
  feature=self,
202
214
  error=error,
215
+ duration=duration,
203
216
  **kwargs
204
217
  )