langfun 0.1.2.dev202507140805__tar.gz → 0.1.2.dev202507160024__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 (168) hide show
  1. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/PKG-INFO +11 -36
  2. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/README.md +1 -24
  3. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/concurrent_test.py +3 -0
  4. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/checkpointing_test.py +11 -11
  5. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/evaluation_test.py +1 -1
  6. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/experiment_test.py +7 -7
  7. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/progress_tracking_test.py +3 -3
  8. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/reporting_test.py +5 -5
  9. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/runners_test.py +11 -11
  10. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/language_model.py +5 -5
  11. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/language_model_test.py +12 -14
  12. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/compositional.py +1 -1
  13. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/message.py +2 -4
  14. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/message_test.py +5 -5
  15. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/audio_test.py +4 -4
  16. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/mime.py +16 -12
  17. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/mapping.py +11 -1
  18. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/querying_test.py +15 -0
  19. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/schema.py +10 -0
  20. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun.egg-info/PKG-INFO +11 -36
  21. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun.egg-info/requires.txt +6 -9
  22. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/LICENSE +0 -0
  23. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/__init__.py +0 -0
  24. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/__init__.py +0 -0
  25. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/agentic/__init__.py +0 -0
  26. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/agentic/action.py +0 -0
  27. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/agentic/action_eval.py +0 -0
  28. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/agentic/action_eval_test.py +0 -0
  29. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/agentic/action_test.py +0 -0
  30. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/__init__.py +0 -0
  31. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/__init__.py +0 -0
  32. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/correction.py +0 -0
  33. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/correction_test.py +0 -0
  34. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/execution.py +0 -0
  35. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/execution_test.py +0 -0
  36. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/generation.py +0 -0
  37. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/generation_test.py +0 -0
  38. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/parsing.py +0 -0
  39. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/parsing_test.py +0 -0
  40. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/sandboxing.py +0 -0
  41. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/coding/python/sandboxing_test.py +0 -0
  42. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/component.py +0 -0
  43. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/component_test.py +0 -0
  44. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/concurrent.py +0 -0
  45. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/console.py +0 -0
  46. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/console_test.py +0 -0
  47. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/data/__init__.py +0 -0
  48. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/data/conversion/__init__.py +0 -0
  49. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/data/conversion/anthropic.py +0 -0
  50. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/data/conversion/anthropic_test.py +0 -0
  51. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/data/conversion/gemini.py +0 -0
  52. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/data/conversion/gemini_test.py +0 -0
  53. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/data/conversion/openai.py +0 -0
  54. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/data/conversion/openai_test.py +0 -0
  55. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/__init__.py +0 -0
  56. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/base.py +0 -0
  57. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/base_test.py +0 -0
  58. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/matching.py +0 -0
  59. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/matching_test.py +0 -0
  60. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/patching.py +0 -0
  61. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/patching_test.py +0 -0
  62. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/scoring.py +0 -0
  63. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/scoring_test.py +0 -0
  64. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/__init__.py +0 -0
  65. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/checkpointing.py +0 -0
  66. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/eval_test_helper.py +0 -0
  67. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/evaluation.py +0 -0
  68. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/example.py +0 -0
  69. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/example_test.py +0 -0
  70. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/experiment.py +0 -0
  71. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/metric_values.py +0 -0
  72. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/metric_values_test.py +0 -0
  73. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/metrics.py +0 -0
  74. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/metrics_test.py +0 -0
  75. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/progress.py +0 -0
  76. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/progress_test.py +0 -0
  77. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/progress_tracking.py +0 -0
  78. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/reporting.py +0 -0
  79. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/eval/v2/runners.py +0 -0
  80. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/langfunc.py +0 -0
  81. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/langfunc_test.py +0 -0
  82. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/__init__.py +0 -0
  83. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/anthropic.py +0 -0
  84. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/anthropic_test.py +0 -0
  85. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/azure_openai.py +0 -0
  86. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/azure_openai_test.py +0 -0
  87. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/cache/__init__.py +0 -0
  88. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/cache/base.py +0 -0
  89. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/cache/in_memory.py +0 -0
  90. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/cache/in_memory_test.py +0 -0
  91. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/compositional_test.py +0 -0
  92. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/deepseek.py +0 -0
  93. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/deepseek_test.py +0 -0
  94. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/fake.py +0 -0
  95. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/fake_test.py +0 -0
  96. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/gemini.py +0 -0
  97. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/gemini_test.py +0 -0
  98. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/google_genai.py +0 -0
  99. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/google_genai_test.py +0 -0
  100. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/groq.py +0 -0
  101. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/groq_test.py +0 -0
  102. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/llama_cpp.py +0 -0
  103. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/llama_cpp_test.py +0 -0
  104. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/openai.py +0 -0
  105. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/openai_compatible.py +0 -0
  106. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/openai_compatible_test.py +0 -0
  107. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/openai_test.py +0 -0
  108. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/rest.py +0 -0
  109. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/rest_test.py +0 -0
  110. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/vertexai.py +0 -0
  111. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/llms/vertexai_test.py +0 -0
  112. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/logging.py +0 -0
  113. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/logging_test.py +0 -0
  114. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/memories/__init__.py +0 -0
  115. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/memories/conversation_history.py +0 -0
  116. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/memories/conversation_history_test.py +0 -0
  117. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/memory.py +0 -0
  118. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/__init__.py +0 -0
  119. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/audio.py +0 -0
  120. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/image.py +0 -0
  121. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/image_test.py +0 -0
  122. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/mime_test.py +0 -0
  123. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/pdf.py +0 -0
  124. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/pdf_test.py +0 -0
  125. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/video.py +0 -0
  126. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modalities/video_test.py +0 -0
  127. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modality.py +0 -0
  128. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/modality_test.py +0 -0
  129. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/natural_language.py +0 -0
  130. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/natural_language_test.py +0 -0
  131. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/sampling.py +0 -0
  132. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/sampling_test.py +0 -0
  133. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/__init__.py +0 -0
  134. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/completion.py +0 -0
  135. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/completion_test.py +0 -0
  136. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/description.py +0 -0
  137. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/description_test.py +0 -0
  138. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/function_generation.py +0 -0
  139. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/function_generation_test.py +0 -0
  140. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/mapping_test.py +0 -0
  141. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/parsing.py +0 -0
  142. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/parsing_test.py +0 -0
  143. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/querying.py +0 -0
  144. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/schema_generation.py +0 -0
  145. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/schema_generation_test.py +0 -0
  146. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/schema_test.py +0 -0
  147. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/scoring.py +0 -0
  148. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/scoring_test.py +0 -0
  149. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/tokenization.py +0 -0
  150. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/structured/tokenization_test.py +0 -0
  151. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/subscription.py +0 -0
  152. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/subscription_test.py +0 -0
  153. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/template.py +0 -0
  154. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/template_test.py +0 -0
  155. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/__init__.py +0 -0
  156. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/completion.py +0 -0
  157. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/completion_test.py +0 -0
  158. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/conversation.py +0 -0
  159. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/conversation_test.py +0 -0
  160. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/demonstration.py +0 -0
  161. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/demonstration_test.py +0 -0
  162. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/selfplay.py +0 -0
  163. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun/core/templates/selfplay_test.py +0 -0
  164. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun.egg-info/SOURCES.txt +0 -0
  165. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun.egg-info/dependency_links.txt +0 -0
  166. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/langfun.egg-info/top_level.txt +0 -0
  167. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/setup.cfg +0 -0
  168. {langfun-0.1.2.dev202507140805 → langfun-0.1.2.dev202507160024}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202507140805
3
+ Version: 0.1.2.dev202507160024
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -21,30 +21,28 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
21
  Classifier: Topic :: Software Development :: Libraries
22
22
  Description-Content-Type: text/markdown
23
23
  License-File: LICENSE
24
- Requires-Dist: pyglove>=0.4.5.dev202409110000
25
24
  Requires-Dist: jinja2>=3.1.2
25
+ Requires-Dist: puremagic>=1.20
26
+ Requires-Dist: pyglove>=0.4.5.dev202507140812
26
27
  Requires-Dist: requests>=2.31.0
27
28
  Provides-Extra: all
28
- Requires-Dist: pyglove>=0.4.5.dev202409110000; extra == "all"
29
29
  Requires-Dist: jinja2>=3.1.2; extra == "all"
30
+ Requires-Dist: puremagic>=1.20; extra == "all"
31
+ Requires-Dist: pyglove>=0.4.5.dev202507140812; extra == "all"
30
32
  Requires-Dist: requests>=2.31.0; extra == "all"
31
- Requires-Dist: termcolor==1.1.0; extra == "all"
32
- Requires-Dist: tqdm>=4.64.1; extra == "all"
33
33
  Requires-Dist: google-auth>=2.16.0; extra == "all"
34
- Requires-Dist: python-magic>=0.4.27; extra == "all"
35
34
  Requires-Dist: pillow>=10.0.0; extra == "all"
36
- Provides-Extra: ui
37
- Requires-Dist: termcolor==1.1.0; extra == "ui"
38
- Requires-Dist: tqdm>=4.64.1; extra == "ui"
35
+ Requires-Dist: termcolor==1.1.0; extra == "all"
36
+ Requires-Dist: tqdm>=4.64.1; extra == "all"
39
37
  Provides-Extra: vertexai
40
38
  Requires-Dist: google-auth>=2.16.0; extra == "vertexai"
41
39
  Provides-Extra: mime
42
- Requires-Dist: python-magic>=0.4.27; extra == "mime"
43
40
  Requires-Dist: pillow>=10.0.0; extra == "mime"
44
- Provides-Extra: mime-auto
45
- Requires-Dist: python-magic>=0.4.27; extra == "mime-auto"
46
41
  Provides-Extra: mime-pil
47
42
  Requires-Dist: pillow>=10.0.0; extra == "mime-pil"
43
+ Provides-Extra: ui
44
+ Requires-Dist: termcolor==1.1.0; extra == "ui"
45
+ Requires-Dist: tqdm>=4.64.1; extra == "ui"
48
46
  Dynamic: author
49
47
  Dynamic: author-email
50
48
  Dynamic: classifier
@@ -202,37 +200,14 @@ a tag from the list below:
202
200
  | all | All Langfun features. |
203
201
  | vertexai | VertexAI access. |
204
202
  | mime | All MIME supports. |
205
- | mime-auto | Automatic MIME type detection. |
206
203
  | mime-pil | Image support for PIL. |
207
204
  | ui | UI enhancements |
208
205
 
209
206
  For example, to install a nightly build that includes VertexAI access, full
210
207
  modality support, and UI enhancements, use:
211
- ```
212
- pip install langfun[vertexai,mime,ui] --pre
213
- ```
214
-
215
- ### Solving import issue with `libmagic`
216
-
217
- Langfun utilizes `libmagic` for automatic MIME type detection to support
218
- multi-modal functionalities. However, `pip install libmagic` may not work
219
- out-of-the-box on all operation systems, sometimes leading to an
220
- `'ImportError: failed to find libmagic.'` error after Langfun installation.
221
-
222
- If you encounter this error, you will need to follow the recommendations below
223
- to fix the installation of `libmagic` library.
224
208
 
225
- #### OSX
226
-
227
- ```
228
- conda install conda-forge::libmagic
229
209
  ```
230
-
231
- #### Windows:
232
- ```
233
- pip install python-magic
234
- pip uninstall python-magic-bin
235
- pip install python-magic-bin
210
+ pip install langfun[vertexai,mime,ui] --pre
236
211
  ```
237
212
 
238
213
  *Disclaimer: this is not an officially supported Google product.*
@@ -142,37 +142,14 @@ a tag from the list below:
142
142
  | all | All Langfun features. |
143
143
  | vertexai | VertexAI access. |
144
144
  | mime | All MIME supports. |
145
- | mime-auto | Automatic MIME type detection. |
146
145
  | mime-pil | Image support for PIL. |
147
146
  | ui | UI enhancements |
148
147
 
149
148
  For example, to install a nightly build that includes VertexAI access, full
150
149
  modality support, and UI enhancements, use:
151
- ```
152
- pip install langfun[vertexai,mime,ui] --pre
153
- ```
154
-
155
- ### Solving import issue with `libmagic`
156
-
157
- Langfun utilizes `libmagic` for automatic MIME type detection to support
158
- multi-modal functionalities. However, `pip install libmagic` may not work
159
- out-of-the-box on all operation systems, sometimes leading to an
160
- `'ImportError: failed to find libmagic.'` error after Langfun installation.
161
-
162
- If you encounter this error, you will need to follow the recommendations below
163
- to fix the installation of `libmagic` library.
164
150
 
165
- #### OSX
166
-
167
- ```
168
- conda install conda-forge::libmagic
169
151
  ```
170
-
171
- #### Windows:
172
- ```
173
- pip install python-magic
174
- pip uninstall python-magic-bin
175
- pip install python-magic-bin
152
+ pip install langfun[vertexai,mime,ui] --pre
176
153
  ```
177
154
 
178
155
  *Disclaimer: this is not an officially supported Google product.*
@@ -17,6 +17,7 @@ import collections
17
17
  from concurrent import futures
18
18
  import contextlib
19
19
  import io
20
+ import sys
20
21
  import time
21
22
  import unittest
22
23
  from langfun.core import component
@@ -330,6 +331,8 @@ class ProgressBarTest(unittest.TestCase):
330
331
  with self.assertRaisesRegex(ValueError, 'Unsupported status'):
331
332
  concurrent.ProgressBar.update(bar_id, 0, status=1)
332
333
  concurrent.ProgressBar.uninstall(bar_id)
334
+ sys.stderr.flush()
335
+ time.sleep(1)
333
336
  self.assertIn('1/4', string_io.getvalue())
334
337
  self.assertIn('2/4', string_io.getvalue())
335
338
  self.assertIn('hello', string_io.getvalue())
@@ -28,7 +28,7 @@ Example = example_lib.Example
28
28
  class SequenceWriterTest(unittest.TestCase):
29
29
 
30
30
  def test_basic(self):
31
- file = os.path.join(tempfile.gettempdir(), 'test.jsonl')
31
+ file = os.path.join(tempfile.mkdtemp(), 'test.jsonl')
32
32
  writer = checkpointing.SequenceWriter(file)
33
33
  example = Example(id=1, input=pg.Dict(x=1), output=2)
34
34
  writer.add(example)
@@ -36,7 +36,7 @@ class SequenceWriterTest(unittest.TestCase):
36
36
  self.assertTrue(pg.io.path_exists(file))
37
37
 
38
38
  def test_error_handling(self):
39
- file = os.path.join(tempfile.gettempdir(), 'test_error_handling.jsonl')
39
+ file = os.path.join(tempfile.mkdtemp(), 'test_error_handling.jsonl')
40
40
  writer = checkpointing.SequenceWriter(file)
41
41
  writer.add(Example(id=1, input=pg.Dict(x=1), output=2))
42
42
 
@@ -87,7 +87,7 @@ class CheckpointerTest(unittest.TestCase):
87
87
  class PerExampleCheckpointerTest(CheckpointerTest):
88
88
 
89
89
  def test_checkpointing(self):
90
- root_dir = os.path.join(tempfile.gettempdir(), 'per_example_checkpointer')
90
+ root_dir = os.path.join(tempfile.mkdtemp(), 'per_example_checkpointer')
91
91
  experiment = eval_test_helper.test_experiment()
92
92
  checkpoint_filename = 'checkpoint.jsonl'
93
93
  checkpointer = checkpointing.PerExampleCheckpointer(checkpoint_filename)
@@ -119,7 +119,7 @@ class PerExampleCheckpointerTest(CheckpointerTest):
119
119
  self.assertEqual(leaf.progress.num_skipped, num_processed[leaf.id])
120
120
 
121
121
  # Test warm start without reprocess.
122
- root_dir = os.path.join(tempfile.gettempdir(), 'per_example_checkpointer2')
122
+ root_dir = os.path.join(tempfile.mkdtemp(), 'per_example_checkpointer2')
123
123
  experiment = eval_test_helper.test_experiment()
124
124
  _ = experiment.run(
125
125
  root_dir, 'new', runner='sequential', plugins=[checkpointer],
@@ -129,7 +129,7 @@ class PerExampleCheckpointerTest(CheckpointerTest):
129
129
  self.assertEqual(leaf.progress.num_skipped, num_processed[leaf.id])
130
130
 
131
131
  # Test warm start with reprocess.
132
- root_dir = os.path.join(tempfile.gettempdir(), 'per_example_checkpointer3')
132
+ root_dir = os.path.join(tempfile.mkdtemp(), 'per_example_checkpointer3')
133
133
  experiment = eval_test_helper.test_experiment()
134
134
  _ = experiment.run(
135
135
  root_dir, 'new', runner='sequential', plugins=[checkpointer],
@@ -139,7 +139,7 @@ class PerExampleCheckpointerTest(CheckpointerTest):
139
139
  for leaf in experiment.leaf_nodes:
140
140
  self.assertEqual(leaf.progress.num_skipped, 0)
141
141
 
142
- root_dir = os.path.join(tempfile.gettempdir(), 'per_example_checkpointer4')
142
+ root_dir = os.path.join(tempfile.mkdtemp(), 'per_example_checkpointer4')
143
143
  experiment = eval_test_helper.test_experiment()
144
144
  _ = experiment.run(
145
145
  root_dir, 'new', runner='sequential', plugins=[checkpointer],
@@ -151,7 +151,7 @@ class PerExampleCheckpointerTest(CheckpointerTest):
151
151
 
152
152
  def test_loading_corrupted_checkpoint(self):
153
153
  root_dir = os.path.join(
154
- tempfile.gettempdir(),
154
+ tempfile.mkdtemp(),
155
155
  'per_example_checkpointer_with_corrupted_checkpoint'
156
156
  )
157
157
  experiment = eval_test_helper.TestEvaluation()
@@ -178,7 +178,7 @@ class PerExampleCheckpointerTest(CheckpointerTest):
178
178
  num_processed[example.id] = i + 1
179
179
 
180
180
  root_dir = os.path.join(
181
- tempfile.gettempdir(),
181
+ tempfile.mkdtemp(),
182
182
  'per_example_checkpointer_with_corrupted_checkpoint_warm_start'
183
183
  )
184
184
  experiment = eval_test_helper.TestEvaluation()
@@ -192,7 +192,7 @@ class PerExampleCheckpointerTest(CheckpointerTest):
192
192
 
193
193
  def test_checkpointing_error(self):
194
194
  root_dir = os.path.join(
195
- tempfile.gettempdir(),
195
+ tempfile.mkdtemp(),
196
196
  'per_example_checkpointer_with_checkpointing_error'
197
197
  )
198
198
  experiment = (eval_test_helper
@@ -207,7 +207,7 @@ class PerExampleCheckpointerTest(CheckpointerTest):
207
207
  class BulkCheckpointerTest(CheckpointerTest):
208
208
 
209
209
  def test_checkpointing(self):
210
- root_dir = os.path.join(tempfile.gettempdir(), 'test_bulk_checkpointer')
210
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_bulk_checkpointer')
211
211
  experiment = eval_test_helper.test_experiment()
212
212
  checkpoint_filename = 'checkpoint.jsonl'
213
213
  checkpointer = checkpointing.BulkCheckpointer(checkpoint_filename)
@@ -238,7 +238,7 @@ class BulkCheckpointerTest(CheckpointerTest):
238
238
 
239
239
  def test_checkpointing_error(self):
240
240
  root_dir = os.path.join(
241
- tempfile.gettempdir(),
241
+ tempfile.mkdtemp(),
242
242
  'bulk_checkpointer_with_checkpointing_error'
243
243
  )
244
244
  experiment = (eval_test_helper
@@ -116,7 +116,7 @@ class EvaluationTest(unittest.TestCase):
116
116
  self.assertEqual(example.metric_metadata, dict(error='ValueError'))
117
117
 
118
118
  def test_evaluate_withstate(self):
119
- eval_dir = os.path.join(tempfile.gettempdir(), 'test_eval')
119
+ eval_dir = os.path.join(tempfile.mkdtemp(), 'test_eval')
120
120
  pg.io.mkdirs(eval_dir, exist_ok=True)
121
121
  state_file = os.path.join(eval_dir, 'state.jsonl')
122
122
  with pg.io.open_sequence(state_file, 'w') as f:
@@ -145,7 +145,7 @@ class RunIdTest(unittest.TestCase):
145
145
  )
146
146
 
147
147
  def test_get_latest(self):
148
- root_dir = os.path.join(tempfile.gettempdir(), 'test_eval')
148
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_eval')
149
149
  pg.io.mkdirs(os.path.join(root_dir, 'run_20241102_0'))
150
150
  pg.io.mkdirs(os.path.join(root_dir, 'run_20241101_0'))
151
151
  self.assertEqual(
@@ -153,15 +153,15 @@ class RunIdTest(unittest.TestCase):
153
153
  RunId.from_id('20241102_0')
154
154
  )
155
155
  self.assertIsNone(RunId.get_latest('/notexist'))
156
- self.assertIsNone(RunId.get_latest(tempfile.gettempdir()))
156
+ self.assertIsNone(RunId.get_latest(tempfile.mkdtemp()))
157
157
 
158
158
  def test_new(self):
159
159
  rid = RunId(date=datetime.date.today(), number=1)
160
160
  self.assertEqual(
161
- RunId.new(root_dir=os.path.join(tempfile.gettempdir(), 'test_new')),
161
+ RunId.new(root_dir=os.path.join(tempfile.mkdtemp(), 'test_new')),
162
162
  rid
163
163
  )
164
- root_dir = os.path.join(tempfile.gettempdir(), 'test_eval2')
164
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_eval2')
165
165
  pg.io.mkdirs(rid.dirname(root_dir))
166
166
  self.assertEqual(RunId.new(root_dir), rid.next())
167
167
 
@@ -185,13 +185,13 @@ class RunIdTest(unittest.TestCase):
185
185
  with self.assertRaisesRegex(
186
186
  ValueError, '.* no previous runs'
187
187
  ):
188
- RunId.from_id('latest', root_dir=tempfile.gettempdir())
188
+ RunId.from_id('latest', root_dir=tempfile.mkdtemp())
189
189
 
190
190
  self.assertEqual(
191
191
  RunId.from_id('20241102_1'),
192
192
  RunId(date=datetime.date(2024, 11, 2), number=1)
193
193
  )
194
- root_dir = os.path.join(tempfile.gettempdir(), 'test_eval3')
194
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_eval3')
195
195
  rid = RunId.from_id('20241102_1')
196
196
  pg.io.mkdirs(rid.dirname(root_dir))
197
197
  self.assertEqual(
@@ -413,7 +413,7 @@ class RunnerTest(unittest.TestCase):
413
413
  ),
414
414
  TestRunner
415
415
  )
416
- root_dir = os.path.join(tempfile.gettempdir(), 'my_eval')
416
+ root_dir = os.path.join(tempfile.mkdtemp(), 'my_eval')
417
417
 
418
418
  # Test standard run.
419
419
  MyEvaluation(replica_id=0).run(
@@ -34,7 +34,7 @@ class HtmlProgressTrackerTest(unittest.TestCase):
34
34
  lf_console._notebook = pg.Dict(
35
35
  display=display
36
36
  )
37
- root_dir = os.path.join(tempfile.gettempdir(), 'test_html_progress_tracker')
37
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_html_progress_tracker')
38
38
  experiment = eval_test_helper.test_experiment()
39
39
  _ = experiment.run(root_dir, 'new', plugins=[])
40
40
  self.assertIsInstance(result['view'], pg.Html)
@@ -44,7 +44,7 @@ class HtmlProgressTrackerTest(unittest.TestCase):
44
44
  class TqdmProgressTrackerTest(unittest.TestCase):
45
45
 
46
46
  def test_basic(self):
47
- root_dir = os.path.join(tempfile.gettempdir(), 'test_tqdm_progress_tracker')
47
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_tqdm_progress_tracker')
48
48
  experiment = eval_test_helper.test_experiment()
49
49
  string_io = io.StringIO()
50
50
  with contextlib.redirect_stderr(string_io):
@@ -53,7 +53,7 @@ class TqdmProgressTrackerTest(unittest.TestCase):
53
53
 
54
54
  def test_with_example_ids(self):
55
55
  root_dir = os.path.join(
56
- tempfile.gettempdir(), 'test_tqdm_progress_tracker_with_example_ids'
56
+ tempfile.mkdtemp(), 'test_tqdm_progress_tracker_with_example_ids'
57
57
  )
58
58
  experiment = eval_test_helper.test_experiment()
59
59
  string_io = io.StringIO()
@@ -25,7 +25,7 @@ import pyglove as pg
25
25
  class ReportingTest(unittest.TestCase):
26
26
 
27
27
  def test_reporting(self):
28
- root_dir = os.path.join(tempfile.gettempdir(), 'test_reporting')
28
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_reporting')
29
29
  experiment = eval_test_helper.test_experiment()
30
30
  checkpointer = checkpointing.BulkCheckpointer('checkpoint.jsonl')
31
31
  reporter = reporting.HtmlReporter()
@@ -49,7 +49,7 @@ class ReportingTest(unittest.TestCase):
49
49
  self.assertTrue(found_generation_log)
50
50
 
51
51
  # Test warm start.
52
- root_dir = os.path.join(tempfile.gettempdir(), 'test_reporting2')
52
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_reporting2')
53
53
  experiment = eval_test_helper.test_experiment()
54
54
  run = experiment.run(
55
55
  root_dir, 'new', plugins=[checkpointer, reporter],
@@ -75,7 +75,7 @@ class ReportingTest(unittest.TestCase):
75
75
 
76
76
  def test_index_html_generation_error(self):
77
77
  root_dir = os.path.join(
78
- tempfile.gettempdir(),
78
+ tempfile.mkdtemp(),
79
79
  'test_reporting_with_index_html_generation_error'
80
80
  )
81
81
  experiment = (eval_test_helper
@@ -98,7 +98,7 @@ class ReportingTest(unittest.TestCase):
98
98
 
99
99
  def test_example_html_generation_error(self):
100
100
  root_dir = os.path.join(
101
- tempfile.gettempdir(),
101
+ tempfile.mkdtemp(),
102
102
  'test_reporting_with_example_html_generation_error'
103
103
  )
104
104
  experiment = (eval_test_helper
@@ -126,7 +126,7 @@ class ReportingTest(unittest.TestCase):
126
126
 
127
127
  # Test warm start.
128
128
  root_dir = os.path.join(
129
- tempfile.gettempdir(),
129
+ tempfile.mkdtemp(),
130
130
  'test_reporting_with_example_html_generation_error2'
131
131
  )
132
132
  experiment = (eval_test_helper
@@ -103,7 +103,7 @@ class RunnerTest(unittest.TestCase):
103
103
  def test_basic(self):
104
104
  plugin = TestPlugin()
105
105
  exp = eval_test_helper.test_experiment()
106
- root_dir = os.path.join(tempfile.gettempdir(), 'test_sequential_runner')
106
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_sequential_runner')
107
107
  run = exp.run(root_dir, runner='sequential', plugins=[plugin])
108
108
 
109
109
  self.assertIsNotNone(plugin.start_time)
@@ -143,7 +143,7 @@ class RunnerTest(unittest.TestCase):
143
143
  self.assertEqual(node.progress.num_processed, node.progress.num_total)
144
144
 
145
145
  def test_raise_if_has_error(self):
146
- root_dir = os.path.join(tempfile.gettempdir(), 'test_raise_if_has_error')
146
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_raise_if_has_error')
147
147
  exp = eval_test_helper.TestEvaluation()
148
148
  with self.assertRaisesRegex(ValueError, 'x should not be 5'):
149
149
  exp.run(
@@ -154,7 +154,7 @@ class RunnerTest(unittest.TestCase):
154
154
  exp.run(root_dir, runner='parallel', plugins=[], raise_if_has_error=True)
155
155
 
156
156
  def test_example_ids(self):
157
- root_dir = os.path.join(tempfile.gettempdir(), 'test_example_ids')
157
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_example_ids')
158
158
  exp = eval_test_helper.test_experiment()
159
159
  plugin = TestPlugin()
160
160
  _ = exp.run(
@@ -164,7 +164,7 @@ class RunnerTest(unittest.TestCase):
164
164
  self.assertEqual(plugin.completed_example_ids, [5, 7, 9] * 6)
165
165
 
166
166
  def test_shuffle_inputs(self):
167
- root_dir = os.path.join(tempfile.gettempdir(), 'test_shuffle_inputs')
167
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_shuffle_inputs')
168
168
  exp = eval_test_helper.test_experiment()
169
169
  plugin = TestPlugin()
170
170
  run = exp.run(
@@ -175,7 +175,7 @@ class RunnerTest(unittest.TestCase):
175
175
  def test_filter(self):
176
176
  plugin = TestPlugin()
177
177
  exp = eval_test_helper.test_experiment()
178
- root_dir = os.path.join(tempfile.gettempdir(), 'test_filter')
178
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_filter')
179
179
 
180
180
  _ = exp.run(
181
181
  root_dir, runner='sequential', plugins=[plugin],
@@ -207,7 +207,7 @@ class RunnerTest(unittest.TestCase):
207
207
  inputs=test_inputs(num_examples=pg.oneof([2, 4]))
208
208
  )
209
209
  # Global cache.
210
- root_dir = os.path.join(tempfile.gettempdir(), 'global_cache')
210
+ root_dir = os.path.join(tempfile.mkdtemp(), 'global_cache')
211
211
  run = exp.run(
212
212
  root_dir, 'new', runner='sequential', use_cache='global', plugins=[]
213
213
  )
@@ -216,7 +216,7 @@ class RunnerTest(unittest.TestCase):
216
216
  self.assertEqual(exp.usage_summary.uncached.total.num_requests, 2)
217
217
 
218
218
  # Per-dataset cache.
219
- root_dir = os.path.join(tempfile.gettempdir(), 'per_dataset')
219
+ root_dir = os.path.join(tempfile.mkdtemp(), 'per_dataset')
220
220
  run = exp.run(
221
221
  root_dir, 'new', runner='sequential',
222
222
  use_cache='per_dataset', plugins=[]
@@ -229,7 +229,7 @@ class RunnerTest(unittest.TestCase):
229
229
  self.assertEqual(exp.usage_summary.uncached.total.num_requests, 3)
230
230
 
231
231
  # No cache.
232
- root_dir = os.path.join(tempfile.gettempdir(), 'no')
232
+ root_dir = os.path.join(tempfile.mkdtemp(), 'no')
233
233
  run = exp.run(root_dir, runner='sequential', use_cache='no', plugins=[])
234
234
  self.assertFalse(pg.io.path_exists(run.output_path_for(exp, 'cache.json')))
235
235
  for leaf in exp.leaf_nodes:
@@ -245,7 +245,7 @@ class ParallelRunnerTest(RunnerTest):
245
245
  def test_parallel_runner(self):
246
246
  plugin = TestPlugin()
247
247
  exp = eval_test_helper.test_experiment()
248
- root_dir = os.path.join(tempfile.gettempdir(), 'test_parallel_runner')
248
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_parallel_runner')
249
249
  run = exp.run(root_dir, runner='parallel', plugins=[plugin])
250
250
 
251
251
  self.assertIsNotNone(plugin.start_time)
@@ -286,7 +286,7 @@ class ParallelRunnerTest(RunnerTest):
286
286
  plugin = TestPlugin()
287
287
  exp = eval_test_helper.test_experiment()
288
288
  root_dir = os.path.join(
289
- tempfile.gettempdir(), 'test_concurrent_startup_delay'
289
+ tempfile.mkdtemp(), 'test_concurrent_startup_delay'
290
290
  )
291
291
  _ = exp.run(
292
292
  root_dir,
@@ -301,7 +301,7 @@ class DebugRunnerTest(RunnerTest):
301
301
  def test_debug_runner(self):
302
302
  plugin = TestPlugin()
303
303
  exp = eval_test_helper.test_experiment()
304
- root_dir = os.path.join(tempfile.gettempdir(), 'test_debug_runner')
304
+ root_dir = os.path.join(tempfile.mkdtemp(), 'test_debug_runner')
305
305
  run = exp.run(root_dir, runner='debug', plugins=[plugin])
306
306
 
307
307
  self.assertIsNotNone(plugin.start_time)
@@ -667,10 +667,7 @@ class LMDebugMode(enum.IntFlag):
667
667
  PROMPT = enum.auto()
668
668
  RESPONSE = enum.auto()
669
669
 
670
- @classmethod
671
- @property
672
- def ALL(cls) -> 'LMDebugMode': # pylint: disable=invalid-name
673
- return LMDebugMode.INFO | LMDebugMode.PROMPT | LMDebugMode.RESPONSE
670
+ ALL = INFO | PROMPT | RESPONSE
674
671
 
675
672
 
676
673
  class LanguageModel(component.Component):
@@ -1101,7 +1098,10 @@ class LanguageModel(component.Component):
1101
1098
  return [job.result for job in executed_jobs]
1102
1099
 
1103
1100
  def __call__(
1104
- self, prompt: message_lib.Message, *, cache_seed: int = 0, **kwargs
1101
+ self,
1102
+ prompt: str | message_lib.Message,
1103
+ *,
1104
+ cache_seed: int = 0, **kwargs
1105
1105
  ) -> message_lib.Message:
1106
1106
  """Returns the first candidate."""
1107
1107
  prompt = message_lib.UserMessage.from_value(prompt)
@@ -683,16 +683,14 @@ class LanguageModelTest(unittest.TestCase):
683
683
 
684
684
  debug_info = string_io.getvalue()
685
685
  expected_included = [
686
- debug_prints[f]
687
- for f in lm_lib.LMDebugMode
688
- if f != lm_lib.LMDebugMode.NONE and f in debug_mode
686
+ debug_prints[f] for f in (info_flag, prompt_flag, response_flag)
687
+ if f in debug_mode
689
688
  ]
690
689
  expected_excluded = [
691
690
  debug_prints[f]
692
- for f in lm_lib.LMDebugMode
693
- if f != lm_lib.LMDebugMode.NONE and f not in debug_mode
691
+ for f in (info_flag, prompt_flag, response_flag)
692
+ if f not in debug_mode
694
693
  ]
695
-
696
694
  for expected_include in expected_included:
697
695
  self.assertIn('[0] ' + expected_include, debug_info)
698
696
  for expected_exclude in expected_excluded:
@@ -750,13 +748,13 @@ class LanguageModelTest(unittest.TestCase):
750
748
  debug_info = string_io.getvalue()
751
749
  expected_included = [
752
750
  debug_prints[f]
753
- for f in lm_lib.LMDebugMode
754
- if f != lm_lib.LMDebugMode.NONE and f in debug_mode
751
+ for f in (info_flag, prompt_flag, response_flag)
752
+ if f in debug_mode
755
753
  ]
756
754
  expected_excluded = [
757
755
  debug_prints[f]
758
- for f in lm_lib.LMDebugMode
759
- if f != lm_lib.LMDebugMode.NONE and f not in debug_mode
756
+ for f in (info_flag, prompt_flag, response_flag)
757
+ if f not in debug_mode
760
758
  ]
761
759
 
762
760
  for expected_include in expected_included:
@@ -813,13 +811,13 @@ class LanguageModelTest(unittest.TestCase):
813
811
  debug_info = string_io.getvalue()
814
812
  expected_included = [
815
813
  debug_prints[f]
816
- for f in lm_lib.LMDebugMode
817
- if f != lm_lib.LMDebugMode.NONE and f in debug_mode
814
+ for f in (info_flag, prompt_flag, response_flag)
815
+ if f in debug_mode
818
816
  ]
819
817
  expected_excluded = [
820
818
  debug_prints[f]
821
- for f in lm_lib.LMDebugMode
822
- if f != lm_lib.LMDebugMode.NONE and f not in debug_mode
819
+ for f in (info_flag, prompt_flag, response_flag)
820
+ if f not in debug_mode
823
821
  ]
824
822
 
825
823
  for expected_include in expected_included:
@@ -78,7 +78,7 @@ class RandomChoice(lf.LanguageModel):
78
78
  )
79
79
 
80
80
  def __call__(
81
- self, prompt: lf.Message, *, cache_seed: int = 0, **kwargs
81
+ self, prompt: str | lf.Message, *, cache_seed: int = 0, **kwargs
82
82
  ) -> lf.Message:
83
83
  return self._select_lm()(prompt, cache_seed=cache_seed, **kwargs)
84
84
 
@@ -225,13 +225,11 @@ class Message(
225
225
  return MessageConverter.get(format_or_type, **kwargs).to_value(self)
226
226
 
227
227
  @classmethod
228
- @property
229
228
  def convertible_formats(cls) -> list[str]:
230
229
  """Returns supported format for message conversion."""
231
230
  return MessageConverter.convertible_formats()
232
231
 
233
232
  @classmethod
234
- @property
235
233
  def convertible_types(cls) -> list[str]:
236
234
  """Returns supported types for message conversion."""
237
235
  return MessageConverter.convertible_types()
@@ -938,8 +936,8 @@ class MessageConverter(pg.Object):
938
936
  """Converts a Langfun message to other formats."""
939
937
 
940
938
  @abc.abstractmethod
941
- def from_value(self, value: Message) -> Message:
942
- """Returns a MessageConverter from a Langfun message."""
939
+ def from_value(self, value: Any) -> Message:
940
+ """Returns a Langfun message from other formats."""
943
941
 
944
942
  @classmethod
945
943
  def _safe_read(
@@ -521,12 +521,12 @@ class MessageConverterTest(unittest.TestCase):
521
521
  def from_value(self, value: tuple[int, ...]) -> message.Message:
522
522
  return message.UserMessage(','.join(str(x) for x in value))
523
523
 
524
- self.assertIn('test_format1', message.Message.convertible_formats)
525
- self.assertIn('test_format2', message.Message.convertible_formats)
526
- self.assertIn('test_format3', message.Message.convertible_formats)
524
+ self.assertIn('test_format1', message.Message.convertible_formats())
525
+ self.assertIn('test_format2', message.Message.convertible_formats())
526
+ self.assertIn('test_format3', message.Message.convertible_formats())
527
527
 
528
- self.assertIn(int, message.Message.convertible_types)
529
- self.assertIn(tuple, message.Message.convertible_types)
528
+ self.assertIn(int, message.Message.convertible_types())
529
+ self.assertIn(tuple, message.Message.convertible_types())
530
530
  self.assertEqual(
531
531
  message.Message.from_value(1, format='test_format1'),
532
532
  message.UserMessage('1')
@@ -34,8 +34,8 @@ class AudioTest(unittest.TestCase):
34
34
 
35
35
  def test_audio_content(self):
36
36
  audio = audio_lib.Audio.from_bytes(content_bytes)
37
- self.assertEqual(audio.mime_type, 'audio/x-wav')
38
- self.assertEqual(audio.audio_format, 'x-wav')
37
+ self.assertIn(audio.mime_type, ('audio/wave', 'audio/x-wav'))
38
+ self.assertIn(audio.audio_format, ('wave', 'x-wav'))
39
39
  self.assertEqual(audio.to_bytes(), content_bytes)
40
40
 
41
41
  def test_bad_audio(self):
@@ -50,8 +50,8 @@ class AudioFileTest(unittest.TestCase):
50
50
  audio = audio_lib.Audio.from_uri('http://mock/web/a.wav')
51
51
  with mock.patch('requests.get') as mock_requests_get:
52
52
  mock_requests_get.side_effect = mock_request
53
- self.assertEqual(audio.audio_format, 'x-wav')
54
- self.assertEqual(audio.mime_type, 'audio/x-wav')
53
+ self.assertIn(audio.audio_format, ('wave', 'x-wav'))
54
+ self.assertIn(audio.mime_type, ('audio/wave', 'audio/x-wav'))
55
55
  self.assertEqual(
56
56
  audio._raw_html(),
57
57
  '<audio controls> <source src="http://mock/web/a.wav"> </audio>',