langfun 0.1.2.dev202505050805__tar.gz → 0.1.2.dev202505070805__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.dev202505050805 → langfun-0.1.2.dev202505070805}/PKG-INFO +1 -1
  2. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/agentic/action.py +84 -14
  3. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/agentic/action_test.py +4 -2
  4. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/__init__.py +3 -0
  5. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/gemini.py +24 -1
  6. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/google_genai.py +4 -0
  7. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/openai.py +29 -0
  8. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/vertexai.py +4 -0
  9. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/memories/conversation_history.py +6 -6
  10. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/memories/conversation_history_test.py +31 -27
  11. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/memory.py +12 -21
  12. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/schema.py +13 -3
  13. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/schema_test.py +16 -0
  14. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/conversation.py +1 -1
  15. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun.egg-info/PKG-INFO +1 -1
  16. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/LICENSE +0 -0
  17. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/README.md +0 -0
  18. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/__init__.py +0 -0
  19. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/__init__.py +0 -0
  20. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/agentic/__init__.py +0 -0
  21. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/agentic/action_eval.py +0 -0
  22. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/agentic/action_eval_test.py +0 -0
  23. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/__init__.py +0 -0
  24. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/__init__.py +0 -0
  25. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/correction.py +0 -0
  26. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/correction_test.py +0 -0
  27. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/execution.py +0 -0
  28. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/execution_test.py +0 -0
  29. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/generation.py +0 -0
  30. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/generation_test.py +0 -0
  31. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/parsing.py +0 -0
  32. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/parsing_test.py +0 -0
  33. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/sandboxing.py +0 -0
  34. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/coding/python/sandboxing_test.py +0 -0
  35. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/component.py +0 -0
  36. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/component_test.py +0 -0
  37. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/concurrent.py +0 -0
  38. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/concurrent_test.py +0 -0
  39. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/console.py +0 -0
  40. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/console_test.py +0 -0
  41. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/data/__init__.py +0 -0
  42. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/data/conversion/__init__.py +0 -0
  43. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/data/conversion/anthropic.py +0 -0
  44. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/data/conversion/anthropic_test.py +0 -0
  45. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/data/conversion/gemini.py +0 -0
  46. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/data/conversion/gemini_test.py +0 -0
  47. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/data/conversion/openai.py +0 -0
  48. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/data/conversion/openai_test.py +0 -0
  49. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/__init__.py +0 -0
  50. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/base.py +0 -0
  51. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/base_test.py +0 -0
  52. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/matching.py +0 -0
  53. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/matching_test.py +0 -0
  54. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/patching.py +0 -0
  55. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/patching_test.py +0 -0
  56. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/scoring.py +0 -0
  57. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/scoring_test.py +0 -0
  58. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/__init__.py +0 -0
  59. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/checkpointing.py +0 -0
  60. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/checkpointing_test.py +0 -0
  61. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/eval_test_helper.py +0 -0
  62. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/evaluation.py +0 -0
  63. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/evaluation_test.py +0 -0
  64. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/example.py +0 -0
  65. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/example_test.py +0 -0
  66. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/experiment.py +0 -0
  67. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/experiment_test.py +0 -0
  68. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/metric_values.py +0 -0
  69. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/metric_values_test.py +0 -0
  70. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/metrics.py +0 -0
  71. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/metrics_test.py +0 -0
  72. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/progress.py +0 -0
  73. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/progress_test.py +0 -0
  74. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/progress_tracking.py +0 -0
  75. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/progress_tracking_test.py +0 -0
  76. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/reporting.py +0 -0
  77. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/reporting_test.py +0 -0
  78. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/runners.py +0 -0
  79. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/eval/v2/runners_test.py +0 -0
  80. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/langfunc.py +0 -0
  81. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/langfunc_test.py +0 -0
  82. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/language_model.py +0 -0
  83. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/language_model_test.py +0 -0
  84. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/anthropic.py +0 -0
  85. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/anthropic_test.py +0 -0
  86. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/azure_openai.py +0 -0
  87. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/azure_openai_test.py +0 -0
  88. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/cache/__init__.py +0 -0
  89. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/cache/base.py +0 -0
  90. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/cache/in_memory.py +0 -0
  91. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/cache/in_memory_test.py +0 -0
  92. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/compositional.py +0 -0
  93. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/compositional_test.py +0 -0
  94. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/deepseek.py +0 -0
  95. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/deepseek_test.py +0 -0
  96. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/fake.py +0 -0
  97. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/fake_test.py +0 -0
  98. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/gemini_test.py +0 -0
  99. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/google_genai_test.py +0 -0
  100. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/groq.py +0 -0
  101. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/groq_test.py +0 -0
  102. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/llama_cpp.py +0 -0
  103. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/llama_cpp_test.py +0 -0
  104. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/openai_compatible.py +0 -0
  105. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/openai_compatible_test.py +0 -0
  106. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/openai_test.py +0 -0
  107. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/rest.py +0 -0
  108. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/rest_test.py +0 -0
  109. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/llms/vertexai_test.py +0 -0
  110. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/logging.py +0 -0
  111. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/logging_test.py +0 -0
  112. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/memories/__init__.py +0 -0
  113. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/message.py +0 -0
  114. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/message_test.py +0 -0
  115. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/__init__.py +0 -0
  116. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/audio.py +0 -0
  117. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/audio_test.py +0 -0
  118. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/image.py +0 -0
  119. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/image_test.py +0 -0
  120. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/mime.py +0 -0
  121. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/mime_test.py +0 -0
  122. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/pdf.py +0 -0
  123. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/pdf_test.py +0 -0
  124. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/video.py +0 -0
  125. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modalities/video_test.py +0 -0
  126. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modality.py +0 -0
  127. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/modality_test.py +0 -0
  128. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/natural_language.py +0 -0
  129. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/natural_language_test.py +0 -0
  130. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/sampling.py +0 -0
  131. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/sampling_test.py +0 -0
  132. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/__init__.py +0 -0
  133. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/completion.py +0 -0
  134. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/completion_test.py +0 -0
  135. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/description.py +0 -0
  136. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/description_test.py +0 -0
  137. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/function_generation.py +0 -0
  138. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/function_generation_test.py +0 -0
  139. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/mapping.py +0 -0
  140. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/mapping_test.py +0 -0
  141. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/parsing.py +0 -0
  142. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/parsing_test.py +0 -0
  143. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/querying.py +0 -0
  144. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/querying_test.py +0 -0
  145. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/schema_generation.py +0 -0
  146. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/schema_generation_test.py +0 -0
  147. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/scoring.py +0 -0
  148. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/scoring_test.py +0 -0
  149. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/tokenization.py +0 -0
  150. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/structured/tokenization_test.py +0 -0
  151. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/subscription.py +0 -0
  152. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/subscription_test.py +0 -0
  153. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/template.py +0 -0
  154. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/template_test.py +0 -0
  155. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/__init__.py +0 -0
  156. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/completion.py +0 -0
  157. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/completion_test.py +0 -0
  158. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/conversation_test.py +0 -0
  159. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/demonstration.py +0 -0
  160. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/demonstration_test.py +0 -0
  161. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/selfplay.py +0 -0
  162. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun/core/templates/selfplay_test.py +0 -0
  163. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun.egg-info/SOURCES.txt +0 -0
  164. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun.egg-info/dependency_links.txt +0 -0
  165. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun.egg-info/requires.txt +0 -0
  166. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/langfun.egg-info/top_level.txt +0 -0
  167. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/setup.cfg +0 -0
  168. {langfun-0.1.2.dev202505050805 → langfun-0.1.2.dev202505070805}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202505050805
3
+ Version: 0.1.2.dev202505070805
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -194,6 +194,11 @@ class Action(pg.Object):
194
194
  """Returns the metadata associated with the result from previous call."""
195
195
  return self._invocation.metadata if self._invocation else None
196
196
 
197
+ @property
198
+ def invocation(self) -> Optional['ActionInvocation']:
199
+ """Returns last invocation. None if the action is not executed."""
200
+ return self._invocation
201
+
197
202
  def __call__(
198
203
  self,
199
204
  session: Optional['Session'] = None,
@@ -825,6 +830,7 @@ class ActionInvocation(pg.Object, pg.views.html.HtmlTreeView.Extension):
825
830
  def _on_bound(self):
826
831
  super()._on_bound()
827
832
  self._tab_control = None
833
+ self.action._invocation = self # pylint: disable=protected-access
828
834
 
829
835
  def _on_parent_change(self, *args, **kwargs):
830
836
  super()._on_parent_change(*args, **kwargs)
@@ -1154,7 +1160,6 @@ class Session(pg.Object, pg.views.html.HtmlTreeView.Extension):
1154
1160
  )
1155
1161
 
1156
1162
  invocation = ActionInvocation(pg.maybe_ref(action))
1157
- action._invocation = invocation # pylint: disable=protected-access
1158
1163
  parent_action = self._current_action
1159
1164
  parent_execution = self._current_execution
1160
1165
  parent_execution.append(invocation)
@@ -1412,38 +1417,103 @@ class Session(pg.Object, pg.views.html.HtmlTreeView.Extension):
1412
1417
  level: lf.logging.LogLevel,
1413
1418
  message: str,
1414
1419
  keep: bool,
1420
+ *,
1421
+ for_action: Action | ActionInvocation | None = None,
1415
1422
  **kwargs
1416
1423
  ) -> None:
1417
- """Logs a message to the session."""
1418
- action_name = self._current_action.action.__class__.__name__
1424
+ """Logs a message to the session.
1425
+
1426
+ Args:
1427
+ level: The logging level.
1428
+ message: The message to log.
1429
+ keep: Whether to keep the log entry in the execution trace.
1430
+ for_action: The action to log the message for. If not provided, the
1431
+ current action will be used.
1432
+ **kwargs: Additional keyword arguments to pass to `lf.logging.log` as
1433
+ metadata to show.
1434
+ """
1419
1435
  execution = self._current_execution
1436
+ if for_action is None:
1437
+ for_action = self._current_action
1438
+ elif isinstance(for_action, Action):
1439
+ for_action = for_action.invocation
1440
+ assert for_action is not None
1441
+
1420
1442
  log_entry = lf.logging.log(
1421
1443
  level,
1422
- f'[{execution.id} ({action_name})]: {message}',
1444
+ (
1445
+ f'[{for_action.id} ({for_action.action.__class__.__name__})]: '
1446
+ f'{message}'
1447
+ ),
1423
1448
  **kwargs
1424
1449
  )
1425
1450
  if keep:
1426
1451
  execution.append(log_entry)
1427
1452
 
1428
- def debug(self, message: str, keep: bool = True, **kwargs):
1453
+ def debug(
1454
+ self,
1455
+ message: str,
1456
+ keep: bool = True,
1457
+ *,
1458
+ for_action: Action | ActionInvocation | None = None,
1459
+ **kwargs
1460
+ ) -> None:
1429
1461
  """Logs a debug message to the session."""
1430
- self._log('debug', message, keep=keep, **kwargs)
1462
+ self._log(
1463
+ 'debug', message, keep=keep, for_action=for_action, **kwargs
1464
+ )
1431
1465
 
1432
- def info(self, message: str, keep: bool = True, **kwargs):
1466
+ def info(
1467
+ self,
1468
+ message: str,
1469
+ keep: bool = True,
1470
+ *,
1471
+ for_action: Action | ActionInvocation | None = None,
1472
+ **kwargs
1473
+ ) -> None:
1433
1474
  """Logs an info message to the session."""
1434
- self._log('info', message, keep=keep, **kwargs)
1475
+ self._log(
1476
+ 'info', message, keep=keep, for_action=for_action, **kwargs
1477
+ )
1435
1478
 
1436
- def warning(self, message: str, keep: bool = True, **kwargs):
1479
+ def warning(
1480
+ self,
1481
+ message: str,
1482
+ keep: bool = True,
1483
+ *,
1484
+ for_action: Action | ActionInvocation | None = None,
1485
+ **kwargs
1486
+ ) -> None:
1437
1487
  """Logs a warning message to the session."""
1438
- self._log('warning', message, keep=keep, **kwargs)
1488
+ self._log(
1489
+ 'warning', message, keep=keep, for_action=for_action, **kwargs
1490
+ )
1439
1491
 
1440
- def error(self, message: str, keep: bool = True, **kwargs):
1492
+ def error(
1493
+ self,
1494
+ message: str,
1495
+ keep: bool = True,
1496
+ *,
1497
+ for_action: Action | ActionInvocation | None = None,
1498
+ **kwargs
1499
+ ):
1441
1500
  """Logs an error message to the session."""
1442
- self._log('error', message, keep=keep, **kwargs)
1501
+ self._log(
1502
+ 'error', message, keep=keep, for_action=for_action, **kwargs
1503
+ )
1443
1504
 
1444
- def fatal(self, message: str, **kwargs):
1505
+ def fatal(
1506
+ self,
1507
+ message: str,
1508
+ keep: bool = True,
1509
+ *,
1510
+ for_action: Action | ActionInvocation | None = None,
1511
+ **kwargs
1512
+ ):
1445
1513
  """Logs a fatal message to the session."""
1446
- self._log('fatal', message, keep=True, **kwargs)
1514
+ self._log(
1515
+ 'fatal', message, keep=keep, for_action=for_action, **kwargs
1516
+ )
1447
1517
 
1448
1518
  def as_message(self) -> lf.AIMessage:
1449
1519
  """Returns the session as a message."""
@@ -107,6 +107,7 @@ class SessionTest(unittest.TestCase):
107
107
  lm = fake.StaticResponse('lm response')
108
108
  foo = Foo(1)
109
109
  self.assertIsNone(foo.session)
110
+ self.assertIsNone(foo.invocation)
110
111
  self.assertIsNone(foo.result)
111
112
  self.assertIsNone(foo.metadata)
112
113
 
@@ -167,6 +168,7 @@ class SessionTest(unittest.TestCase):
167
168
 
168
169
  # Inspecting the top-level action (Foo)
169
170
  foo_invocation = root.execution[0]
171
+ self.assertIs(foo.invocation, foo_invocation)
170
172
  self.assertIs(foo_invocation.parent_action, root)
171
173
  self.assertEqual(foo_invocation.id, 'agent@1:/a1')
172
174
  self.assertEqual(foo_invocation.execution.id, 'agent@1:/a1')
@@ -414,8 +416,8 @@ class SessionTest(unittest.TestCase):
414
416
  def test_log(self):
415
417
  session = action_lib.Session()
416
418
  session.debug('hi', x=1, y=2)
417
- session.info('hi', x=1, y=2)
418
- session.warning('hi', x=1, y=2)
419
+ session.info('hi', x=1, y=2, for_action=session.root)
420
+ session.warning('hi', x=1, y=2, for_action=session.root.action)
419
421
  session.error('hi', x=1, y=2)
420
422
  session.fatal('hi', x=1, y=2)
421
423
 
@@ -40,6 +40,7 @@ from langfun.core.llms.azure_openai import AzureOpenAI
40
40
 
41
41
  # Gemini models.
42
42
  from langfun.core.llms.google_genai import GenAI
43
+ from langfun.core.llms.google_genai import Gemini25ProPreview_20250506
43
44
  from langfun.core.llms.google_genai import Gemini25FlashPreview_20250417
44
45
  from langfun.core.llms.google_genai import Gemini25ProPreview_20250325
45
46
  from langfun.core.llms.google_genai import Gemini2Flash
@@ -77,6 +78,7 @@ from langfun.core.llms.vertexai import VertexAIGeminiExp_20241206
77
78
  from langfun.core.llms.vertexai import VertexAIGemini25ProExp_20250325
78
79
  from langfun.core.llms.vertexai import VertexAIGemini25ProPreview_20250325
79
80
  from langfun.core.llms.vertexai import VertexAIGemini25FlashPreview_20250417
81
+ from langfun.core.llms.vertexai import VertexAIGemini25ProPreview_20250506
80
82
 
81
83
  # For backward compatibility.
82
84
  GeminiPro1_5 = Gemini15Pro
@@ -87,6 +89,7 @@ VertexAIGeminiFlash1_5 = VertexAIGemini15Flash
87
89
  # OpenAI models.
88
90
  from langfun.core.llms.openai import OpenAI
89
91
 
92
+ from langfun.core.llms.openai import Gpt41
90
93
  from langfun.core.llms.openai import GptO3
91
94
  from langfun.core.llms.openai import GptO4Mini
92
95
  from langfun.core.llms.openai import Gpt45Preview_20250227
@@ -151,6 +151,29 @@ SUPPORTED_MODELS = [
151
151
  #
152
152
  # Production models.
153
153
  #
154
+ # Gemini 2.5 Pro Preview
155
+ GeminiModelInfo(
156
+ model_id='gemini-2.5-pro-preview-05-06',
157
+ in_service=True,
158
+ provider=pg.oneof(['Google GenAI', ' VertexAI']),
159
+ model_type='instruction-tuned',
160
+ description='Gemini 2.5 Pro.',
161
+ release_date=datetime.datetime(2025, 5, 6),
162
+ input_modalities=GeminiModelInfo.ALL_SUPPORTED_INPUT_TYPES,
163
+ context_length=lf.ModelInfo.ContextLength(
164
+ max_input_tokens=1_048_576,
165
+ max_output_tokens=65_536,
166
+ ),
167
+ pricing=GeminiModelInfo.Pricing(
168
+ cost_per_1m_cached_input_tokens=1.25,
169
+ cost_per_1m_input_tokens=1.25,
170
+ cost_per_1m_output_tokens=10.0,
171
+ ),
172
+ rate_limits=lf.ModelInfo.RateLimits(
173
+ max_requests_per_minute=2000,
174
+ max_tokens_per_minute=4_000_000,
175
+ )
176
+ ),
154
177
  # Gemini 2.5 Flash Preview
155
178
  GeminiModelInfo(
156
179
  model_id='gemini-2.5-flash-preview-04-17',
@@ -657,7 +680,7 @@ class Gemini(rest.REST):
657
680
  def result(self, json: dict[str, Any]) -> lf.LMSamplingResult:
658
681
  messages = [
659
682
  lf.Message.from_value(candidate['content'], format='gemini')
660
- for candidate in json['candidates']
683
+ for candidate in json.get('candidates', [])
661
684
  ]
662
685
  usage = json['usageMetadata']
663
686
  input_tokens = usage['promptTokenCount']
@@ -106,6 +106,10 @@ class GeminiExp_20241206(GenAI):
106
106
  #
107
107
  # Production models.
108
108
  #
109
+ class Gemini25ProPreview_20250506(GenAI):
110
+ """Gemini 2.5 Pro model launched on 05/06/2025."""
111
+
112
+ model = 'gemini-2.5-pro-preview-05-06'
109
113
 
110
114
 
111
115
  class Gemini25FlashPreview_20250417(GenAI):
@@ -49,6 +49,30 @@ class OpenAIModelInfo(lf.ModelInfo):
49
49
  #
50
50
 
51
51
  SUPPORTED_MODELS = [
52
+ # GPT-4.1 models
53
+ OpenAIModelInfo(
54
+ model_id='gpt-4.1',
55
+ alias_for='gpt-4.1-2025-04-14',
56
+ in_service=True,
57
+ model_type='instruction-tuned',
58
+ description='GPT 4.1 model (latest stable).',
59
+ url='https://platform.openai.com/docs/models/gpt-4.1',
60
+ input_modalities=OpenAIModelInfo.INPUT_IMAGE_TYPES,
61
+ context_length=lf.ModelInfo.ContextLength(
62
+ max_input_tokens=1_047_576,
63
+ max_output_tokens=32_768,
64
+ ),
65
+ pricing=lf.ModelInfo.Pricing(
66
+ cost_per_1m_cached_input_tokens=0.50,
67
+ cost_per_1m_input_tokens=2.0,
68
+ cost_per_1m_output_tokens=8.0,
69
+ ),
70
+ # Tier 5 rate limits.
71
+ rate_limits=lf.ModelInfo.RateLimits(
72
+ max_requests_per_minute=10_000,
73
+ max_tokens_per_minute=30_000_000,
74
+ ),
75
+ ),
52
76
  # o3 models.
53
77
  OpenAIModelInfo(
54
78
  model_id='o3',
@@ -1045,6 +1069,11 @@ class OpenAI(openai_compatible.OpenAICompatible):
1045
1069
  return super()._request_args(options)
1046
1070
 
1047
1071
 
1072
+ class Gpt41(OpenAI):
1073
+ """GPT-4.1."""
1074
+ model = 'gpt-4.1'
1075
+
1076
+
1048
1077
  class GptO4Mini(OpenAI):
1049
1078
  """GPT O4 mini."""
1050
1079
 
@@ -173,9 +173,13 @@ class VertexAIGemini(VertexAI, gemini.Gemini):
173
173
  def model_info(self) -> gemini.GeminiModelInfo:
174
174
  return super().model_info.clone(override=dict(provider='VertexAI'))
175
175
 
176
+
176
177
  #
177
178
  # Production models.
178
179
  #
180
+ class VertexAIGemini25ProPreview_20250506(VertexAIGemini): # pylint: disable=invalid-name
181
+ """Gemini 2.5 Pro model launched on 05/06/2025."""
182
+ model = 'gemini-2.5-pro-preview-05-06'
179
183
 
180
184
 
181
185
  class VertexAIGemini25FlashPreview_20250417(VertexAIGemini): # pylint: disable=invalid-name
@@ -43,19 +43,19 @@ class ConversationHistory(lf.Memory):
43
43
  messages.append(r[1])
44
44
  return messages
45
45
 
46
- def _recollect(self, **kwargs) -> lf.MemoryRecord:
47
- return lf.MemoryRecord(
48
- '\n'.join([f'{m.sender}: {m.text}' for m in self.messages]))
46
+ def _recollect(self, **kwargs) -> str:
47
+ return '\n'.join([f'{m.sender}: {m.text}' for m in self.messages])
49
48
 
50
49
  def _remember(
51
50
  self,
52
- input_message: lf.Message,
53
- output_message: lf.Message | None = None,
51
+ value: tuple[str | lf.Message, str | lf.Message],
54
52
  **kwargs
55
53
  ) -> None:
56
54
  if self.max_turns and self.max_turns == len(self._turns):
57
55
  self._turns.pop(0)
58
- self._turns.append((input_message, output_message))
56
+ self._turns.append(
57
+ (lf.UserMessage.from_value(value[0]), lf.AIMessage.from_value(value[1]))
58
+ )
59
59
 
60
60
  def _reset(self, **kwargs) -> None:
61
61
  self._turns = []
@@ -13,58 +13,62 @@
13
13
  # limitations under the License.
14
14
  """Base memory test."""
15
15
 
16
- import inspect
17
16
  import unittest
18
17
  import langfun.core as lf
19
18
  from langfun.core.memories.conversation_history import ConversationHistory
19
+ import pyglove as pg
20
20
 
21
21
 
22
22
  class ConversationHistoryTest(unittest.TestCase):
23
23
 
24
24
  def test_history_with_no_round_limit(self):
25
25
  m = ConversationHistory()
26
- m.remember('hi', 'hello')
26
+ m.remember(('hi', 'hello'))
27
27
  m.remember(
28
- 'how are you',
29
- 'Fine, thank you. Anything I can help with?',
28
+ ('how are you', 'Fine, thank you. Anything I can help with?'),
30
29
  )
31
30
  m.remember(
32
- 'Not for now, bye.',
33
- 'Okay, bye!',
31
+ ('Not for now, bye.', 'Okay, bye!'),
34
32
  )
35
33
  self.assertEqual(len(m.turns), 3)
36
34
  self.assertEqual(len(m.messages), 6)
37
- self.assertEqual(
38
- m.recollect(),
39
- lf.MemoryRecord(inspect.cleandoc("""
40
- User: hi
41
- AI: hello
42
- User: how are you
43
- AI: Fine, thank you. Anything I can help with?
44
- User: Not for now, bye.
45
- AI: Okay, bye!
46
- """)),
35
+ self.assertTrue(
36
+ pg.eq(
37
+ m.recollect(),
38
+ lf.Template(
39
+ """
40
+ User: hi
41
+ AI: hello
42
+ User: how are you
43
+ AI: Fine, thank you. Anything I can help with?
44
+ User: Not for now, bye.
45
+ AI: Okay, bye!
46
+ """
47
+ )
48
+ )
47
49
  )
48
50
 
49
51
  def test_history_with_round_limit(self):
50
52
  m = ConversationHistory(max_turns=1)
51
- m.remember('hi', 'hello')
53
+ m.remember(('hi', 'hello'))
52
54
  m.remember(
53
- 'how are you',
54
- 'Fine, thank you. Anything I can help with?',
55
+ ('how are you', 'Fine, thank you. Anything I can help with?'),
55
56
  )
56
57
  m.remember(
57
- 'Not for now, bye.',
58
- 'Okay, bye!',
58
+ ('Not for now, bye.', 'Okay, bye!'),
59
59
  )
60
60
  self.assertEqual(len(m.turns), 1)
61
61
  self.assertEqual(len(m.messages), 2)
62
- self.assertEqual(
63
- m.recollect(),
64
- lf.MemoryRecord(inspect.cleandoc("""
65
- User: Not for now, bye.
66
- AI: Okay, bye!
67
- """)),
62
+ self.assertTrue(
63
+ pg.eq(
64
+ m.recollect(),
65
+ lf.Template(
66
+ """
67
+ User: Not for now, bye.
68
+ AI: Okay, bye!
69
+ """
70
+ )
71
+ )
68
72
  )
69
73
 
70
74
 
@@ -14,7 +14,9 @@
14
14
  """Interface for memories."""
15
15
 
16
16
  import abc
17
- from langfun.core import message as message_lib
17
+ from typing import Any
18
+
19
+ from langfun.core import template as template_lib
18
20
  from langfun.core.component import Component
19
21
  from langfun.core.natural_language import NaturalLanguageFormattable
20
22
 
@@ -30,40 +32,29 @@ class Memory(NaturalLanguageFormattable, Component):
30
32
  """
31
33
 
32
34
  def natural_language_format(self) -> str:
33
- return self.recollect().text
35
+ return self.recollect().render().text
34
36
 
35
- def recollect(self, **kwargs) -> message_lib.MemoryRecord:
37
+ def recollect(self, **kwargs) -> template_lib.Template:
36
38
  """Recollects a message from the memory."""
37
- return self._recollect(**kwargs)
39
+ return template_lib.Template.from_value(self._recollect(**kwargs))
38
40
 
39
41
  def remember(
40
42
  self,
41
- input_message: str | message_lib.Message,
42
- output_message: str | message_lib.Message,
43
+ value: Any,
43
44
  **kwargs
44
- ) -> str:
45
- if isinstance(input_message, str):
46
- input_message = message_lib.UserMessage(input_message)
47
- if isinstance(output_message, str):
48
- output_message = message_lib.AIMessage(output_message)
49
- self._remember(input_message, output_message, **kwargs)
50
- return output_message.text
45
+ ) -> None:
46
+ self._remember(value, **kwargs)
51
47
 
52
48
  def reset(self, **kwargs) -> None:
53
49
  """Resets the memory."""
54
- self._reset()
50
+ self._reset(**kwargs)
55
51
 
56
52
  @abc.abstractmethod
57
- def _recollect(self, **kwargs) -> message_lib.MemoryRecord:
53
+ def _recollect(self, **kwargs) -> str | template_lib.Template:
58
54
  """Recollects a message from the memory."""
59
55
 
60
56
  @abc.abstractmethod
61
- def _remember(
62
- self,
63
- input_message: message_lib.Message,
64
- output_message: message_lib.Message,
65
- **kwargs
66
- ) -> None:
57
+ def _remember(self, value: Any, **kwargs) -> None:
67
58
  """Remembers the input message and the output message."""
68
59
 
69
60
  @abc.abstractmethod
@@ -185,10 +185,14 @@ class Schema(
185
185
  def class_dependencies(
186
186
  self,
187
187
  include_base_classes: bool = True,
188
- include_subclasses: bool = True) -> list[Type[Any]]:
188
+ include_subclasses: bool = True,
189
+ include_generated_subclasses: bool = False) -> list[Type[Any]]:
189
190
  """Returns a list of class dependencies for current schema."""
190
191
  return class_dependencies(
191
- self.spec, include_base_classes, include_subclasses
192
+ self.spec,
193
+ include_base_classes,
194
+ include_subclasses,
195
+ include_generated_subclasses
192
196
  )
193
197
 
194
198
  @classmethod
@@ -247,6 +251,7 @@ def class_dependencies(
247
251
  ],
248
252
  include_base_classes: bool = True,
249
253
  include_subclasses: bool = True,
254
+ include_generated_subclasses: bool = False,
250
255
  ) -> list[Type[Any]]:
251
256
  """Returns a list of class dependencies from a value or specs."""
252
257
  if isinstance(value_or_spec, Schema):
@@ -301,7 +306,12 @@ def class_dependencies(
301
306
  # Check subclasses if available.
302
307
  if include_subclasses:
303
308
  for cls in vs.cls.__subclasses__():
304
- if cls not in dependencies:
309
+ # NOTE(daiyip): To prevent LLM-generated "hallucinated" classes from
310
+ # polluting the generation space, classes dynamically created by
311
+ # 'eval' (which have __module__ == 'builtins') are excluded from
312
+ # dependencies by default.
313
+ if ((include_generated_subclasses or cls.__module__ != 'builtins')
314
+ and cls not in dependencies):
305
315
  _fill_dependencies(pg.typing.Object(cls), include_subclasses=True)
306
316
 
307
317
  if isinstance(vs, pg.typing.List):
@@ -144,6 +144,14 @@ class SchemaTest(unittest.TestCase):
144
144
  foo2: Foo | X
145
145
 
146
146
  schema = schema_lib.Schema([B])
147
+ v = schema_lib.structure_from_python(
148
+ """
149
+ class C(B):
150
+ pass
151
+ """,
152
+ global_vars=dict(B=B)
153
+ )
154
+ self.assertEqual(v.__module__, 'builtins')
147
155
  self.assertEqual(schema.class_dependencies(), [Foo, A, Bar, X, B])
148
156
 
149
157
  def test_class_dependencies_non_pyglove(self):
@@ -162,6 +170,14 @@ class SchemaTest(unittest.TestCase):
162
170
  class BB(AA):
163
171
  foo2: Baz | XX
164
172
 
173
+ v = schema_lib.structure_from_python(
174
+ """
175
+ class CC(BB):
176
+ pass
177
+ """,
178
+ global_vars=dict(BB=BB)
179
+ )
180
+ self.assertEqual(v.__module__, 'builtins')
165
181
  schema = schema_lib.Schema([AA])
166
182
  self.assertEqual(schema.class_dependencies(), [Baz, AA, XX, BB])
167
183
 
@@ -90,7 +90,7 @@ class Conversation(Completion):
90
90
  self, input_message: lf.Message | str, lm_response: lf.Message | str
91
91
  ) -> None:
92
92
  """Adds a turn."""
93
- self.memory.remember(input_message, lm_response)
93
+ self.memory.remember((input_message, lm_response))
94
94
 
95
95
  def reset(self) -> None:
96
96
  """Resets current conversation."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202505050805
3
+ Version: 0.1.2.dev202505070805
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors