langfun 0.1.2.dev202504090804__tar.gz → 0.1.2.dev202504100804__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.dev202504090804 → langfun-0.1.2.dev202504100804}/PKG-INFO +1 -1
  2. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/anthropic.py +11 -6
  3. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/anthropic_test.py +25 -3
  4. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/gemini.py +10 -2
  5. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/gemini_test.py +22 -1
  6. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/openai_compatible.py +2 -1
  7. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/openai_compatible_test.py +1 -1
  8. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/querying.py +11 -0
  9. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/querying_test.py +21 -1
  10. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun.egg-info/PKG-INFO +1 -1
  11. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/LICENSE +0 -0
  12. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/README.md +0 -0
  13. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/__init__.py +0 -0
  14. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/__init__.py +0 -0
  15. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/agentic/__init__.py +0 -0
  16. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/agentic/action.py +0 -0
  17. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/agentic/action_eval.py +0 -0
  18. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/agentic/action_eval_test.py +0 -0
  19. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/agentic/action_test.py +0 -0
  20. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/__init__.py +0 -0
  21. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/__init__.py +0 -0
  22. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/correction.py +0 -0
  23. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/correction_test.py +0 -0
  24. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/execution.py +0 -0
  25. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/execution_test.py +0 -0
  26. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/generation.py +0 -0
  27. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/generation_test.py +0 -0
  28. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/parsing.py +0 -0
  29. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/parsing_test.py +0 -0
  30. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/sandboxing.py +0 -0
  31. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/coding/python/sandboxing_test.py +0 -0
  32. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/component.py +0 -0
  33. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/component_test.py +0 -0
  34. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/concurrent.py +0 -0
  35. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/concurrent_test.py +0 -0
  36. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/console.py +0 -0
  37. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/console_test.py +0 -0
  38. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/data/__init__.py +0 -0
  39. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/data/conversion/__init__.py +0 -0
  40. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/data/conversion/anthropic.py +0 -0
  41. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/data/conversion/anthropic_test.py +0 -0
  42. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/data/conversion/gemini.py +0 -0
  43. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/data/conversion/gemini_test.py +0 -0
  44. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/data/conversion/openai.py +0 -0
  45. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/data/conversion/openai_test.py +0 -0
  46. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/__init__.py +0 -0
  47. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/base.py +0 -0
  48. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/base_test.py +0 -0
  49. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/matching.py +0 -0
  50. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/matching_test.py +0 -0
  51. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/patching.py +0 -0
  52. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/patching_test.py +0 -0
  53. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/scoring.py +0 -0
  54. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/scoring_test.py +0 -0
  55. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/__init__.py +0 -0
  56. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/checkpointing.py +0 -0
  57. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/checkpointing_test.py +0 -0
  58. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/eval_test_helper.py +0 -0
  59. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/evaluation.py +0 -0
  60. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/evaluation_test.py +0 -0
  61. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/example.py +0 -0
  62. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/example_test.py +0 -0
  63. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/experiment.py +0 -0
  64. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/experiment_test.py +0 -0
  65. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/metric_values.py +0 -0
  66. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/metric_values_test.py +0 -0
  67. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/metrics.py +0 -0
  68. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/metrics_test.py +0 -0
  69. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/progress.py +0 -0
  70. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/progress_test.py +0 -0
  71. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/progress_tracking.py +0 -0
  72. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/progress_tracking_test.py +0 -0
  73. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/reporting.py +0 -0
  74. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/reporting_test.py +0 -0
  75. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/runners.py +0 -0
  76. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/eval/v2/runners_test.py +0 -0
  77. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/langfunc.py +0 -0
  78. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/langfunc_test.py +0 -0
  79. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/language_model.py +0 -0
  80. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/language_model_test.py +0 -0
  81. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/__init__.py +0 -0
  82. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/azure_openai.py +0 -0
  83. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/azure_openai_test.py +0 -0
  84. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/cache/__init__.py +0 -0
  85. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/cache/base.py +0 -0
  86. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/cache/in_memory.py +0 -0
  87. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/cache/in_memory_test.py +0 -0
  88. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/compositional.py +0 -0
  89. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/compositional_test.py +0 -0
  90. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/deepseek.py +0 -0
  91. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/deepseek_test.py +0 -0
  92. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/fake.py +0 -0
  93. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/fake_test.py +0 -0
  94. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/google_genai.py +0 -0
  95. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/google_genai_test.py +0 -0
  96. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/groq.py +0 -0
  97. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/groq_test.py +0 -0
  98. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/llama_cpp.py +0 -0
  99. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/llama_cpp_test.py +0 -0
  100. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/openai.py +0 -0
  101. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/openai_test.py +0 -0
  102. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/rest.py +0 -0
  103. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/rest_test.py +0 -0
  104. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/vertexai.py +0 -0
  105. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/llms/vertexai_test.py +0 -0
  106. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/logging.py +0 -0
  107. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/logging_test.py +0 -0
  108. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/memories/__init__.py +0 -0
  109. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/memories/conversation_history.py +0 -0
  110. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/memories/conversation_history_test.py +0 -0
  111. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/memory.py +0 -0
  112. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/message.py +0 -0
  113. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/message_test.py +0 -0
  114. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/__init__.py +0 -0
  115. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/audio.py +0 -0
  116. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/audio_test.py +0 -0
  117. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/image.py +0 -0
  118. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/image_test.py +0 -0
  119. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/mime.py +0 -0
  120. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/mime_test.py +0 -0
  121. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/pdf.py +0 -0
  122. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/pdf_test.py +0 -0
  123. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/video.py +0 -0
  124. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modalities/video_test.py +0 -0
  125. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modality.py +0 -0
  126. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/modality_test.py +0 -0
  127. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/natural_language.py +0 -0
  128. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/natural_language_test.py +0 -0
  129. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/sampling.py +0 -0
  130. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/sampling_test.py +0 -0
  131. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/__init__.py +0 -0
  132. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/completion.py +0 -0
  133. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/completion_test.py +0 -0
  134. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/description.py +0 -0
  135. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/description_test.py +0 -0
  136. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/function_generation.py +0 -0
  137. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/function_generation_test.py +0 -0
  138. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/mapping.py +0 -0
  139. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/mapping_test.py +0 -0
  140. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/parsing.py +0 -0
  141. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/parsing_test.py +0 -0
  142. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/schema.py +0 -0
  143. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/schema_generation.py +0 -0
  144. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/schema_generation_test.py +0 -0
  145. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/schema_test.py +0 -0
  146. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/scoring.py +0 -0
  147. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/scoring_test.py +0 -0
  148. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/tokenization.py +0 -0
  149. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/structured/tokenization_test.py +0 -0
  150. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/subscription.py +0 -0
  151. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/subscription_test.py +0 -0
  152. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/template.py +0 -0
  153. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/template_test.py +0 -0
  154. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/__init__.py +0 -0
  155. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/completion.py +0 -0
  156. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/completion_test.py +0 -0
  157. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/conversation.py +0 -0
  158. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/conversation_test.py +0 -0
  159. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/demonstration.py +0 -0
  160. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/demonstration_test.py +0 -0
  161. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/selfplay.py +0 -0
  162. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun/core/templates/selfplay_test.py +0 -0
  163. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun.egg-info/SOURCES.txt +0 -0
  164. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun.egg-info/dependency_links.txt +0 -0
  165. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun.egg-info/requires.txt +0 -0
  166. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/langfun.egg-info/top_level.txt +0 -0
  167. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/setup.cfg +0 -0
  168. {langfun-0.1.2.dev202504090804 → langfun-0.1.2.dev202504100804}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202504090804
3
+ Version: 0.1.2.dev202504100804
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors
@@ -509,13 +509,18 @@ class Anthropic(rest.REST):
509
509
  raise ValueError(f'Unsupported modality: {chunk!r}.')
510
510
  return chunk
511
511
 
512
- request.update(
513
- dict(
514
- messages=[
515
- prompt.as_format('anthropic', chunk_preprocessor=modality_check)
516
- ]
517
- )
512
+ messages = []
513
+ if system_message := prompt.get('system_message'):
514
+ assert isinstance(system_message, lf.SystemMessage), type(system_message)
515
+ messages.append(
516
+ system_message.as_format(
517
+ 'anthropic', chunk_preprocessor=modality_check
518
+ )
519
+ )
520
+ messages.append(
521
+ prompt.as_format('anthropic', chunk_preprocessor=modality_check)
518
522
  )
523
+ request.update(messages=messages)
519
524
  return request
520
525
 
521
526
  def _request_args(self, options: lf.LMSamplingOptions) -> dict[str, Any]:
@@ -35,7 +35,8 @@ def mock_requests_post(url: str, json: dict[str, Any], **kwargs):
35
35
  'content': [{
36
36
  'type': 'text',
37
37
  'text': (
38
- f'hello with temperature={json.get("temperature")}, '
38
+ '\n'.join(c['content'][0]['text'] for c in json['messages']) +
39
+ f' with temperature={json.get("temperature")}, '
39
40
  f'top_k={json.get("top_k")}, '
40
41
  f'top_p={json.get("top_p")}, '
41
42
  f'max_tokens={json.get("max_tokens")}, '
@@ -140,11 +141,11 @@ class AnthropicTest(unittest.TestCase):
140
141
  mock_request.side_effect = mock_requests_post
141
142
 
142
143
  lm = anthropic.Claude3Haiku(api_key='fake key')
143
- self.assertRegex(lm('hi').text, 'hello.*')
144
+ self.assertRegex(lm('hello').text, 'hello.*')
144
145
 
145
146
  os.environ['ANTHROPIC_API_KEY'] = 'abc'
146
147
  lm = anthropic.Claude3Haiku()
147
- self.assertRegex(lm('hi').text, 'hello.*')
148
+ self.assertRegex(lm('hello').text, 'hello.*')
148
149
  del os.environ['ANTHROPIC_API_KEY']
149
150
 
150
151
  def test_call(self):
@@ -165,6 +166,27 @@ class AnthropicTest(unittest.TestCase):
165
166
  self.assertIsNotNone(response.usage.total_tokens, 3)
166
167
  self.assertGreater(response.usage.estimated_cost, 0)
167
168
 
169
+ def test_call_with_system_message(self):
170
+ with mock.patch('requests.Session.post') as mock_request:
171
+ mock_request.side_effect = mock_requests_post
172
+ lm = anthropic.Claude3Haiku(api_key='fake_key')
173
+ response = lm(
174
+ lf.UserMessage(
175
+ 'hello', system_message=lf.SystemMessage('system')
176
+ ),
177
+ temperature=0.0,
178
+ top_k=0.1,
179
+ top_p=0.2,
180
+ stop=['\n'],
181
+ )
182
+ self.assertEqual(
183
+ response.text,
184
+ (
185
+ 'system\nhello with temperature=0.0, top_k=0.1, top_p=0.2, '
186
+ "max_tokens=4096, stop=['\\n']."
187
+ ),
188
+ )
189
+
168
190
  def test_mm_call(self):
169
191
  with mock.patch('requests.Session.post') as mock_mm_request:
170
192
  mock_mm_request.side_effect = mock_mm_requests_post
@@ -582,9 +582,17 @@ class Gemini(rest.REST):
582
582
  raise lf.ModalityError(f'Unsupported modality: {chunk!r}') from e
583
583
  return chunk
584
584
 
585
- request['contents'] = [
585
+ contents = []
586
+ if system_message := prompt.get('system_message'):
587
+ assert isinstance(system_message, lf.SystemMessage), type(system_message)
588
+ contents.append(
589
+ system_message.as_format(
590
+ 'gemini', chunk_preprocessor=modality_conversion)
591
+ )
592
+ contents.append(
586
593
  prompt.as_format('gemini', chunk_preprocessor=modality_conversion)
587
- ]
594
+ )
595
+ request['contents'] = contents
588
596
  return request
589
597
 
590
598
  def _generation_config(
@@ -38,7 +38,7 @@ example_image = (
38
38
  def mock_requests_post(url: str, json: dict[str, Any], **kwargs):
39
39
  del url, kwargs
40
40
  c = pg.Dict(json['generationConfig'])
41
- content = json['contents'][0]['parts'][0]['text']
41
+ content = '\n'.join(c['parts'][0]['text'] for c in json['contents'])
42
42
  response = requests.Response()
43
43
  response.status_code = 200
44
44
  response._content = pg.to_json_str({
@@ -178,6 +178,27 @@ class GeminiTest(unittest.TestCase):
178
178
  self.assertEqual(r.metadata.usage.prompt_tokens, 3)
179
179
  self.assertEqual(r.metadata.usage.completion_tokens, 4)
180
180
 
181
+ def test_call_model_with_system_message(self):
182
+ with mock.patch('requests.Session.post') as mock_generate:
183
+ mock_generate.side_effect = mock_requests_post
184
+
185
+ lm = gemini.Gemini('gemini-1.5-pro', api_endpoint='')
186
+ r = lm(
187
+ lf.UserMessage('hello', system_message=lf.SystemMessage('system')),
188
+ temperature=2.0,
189
+ top_p=1.0,
190
+ top_k=20,
191
+ max_tokens=1024,
192
+ stop='\n',
193
+ )
194
+ self.assertEqual(
195
+ r.text,
196
+ (
197
+ 'This is a response to system\nhello with temperature=2.0, '
198
+ 'top_p=1.0, top_k=20, max_tokens=1024, stop=\n.'
199
+ ),
200
+ )
201
+
181
202
 
182
203
  if __name__ == '__main__':
183
204
  unittest.main()
@@ -113,8 +113,9 @@ class OpenAICompatible(rest.REST):
113
113
  # Users could use `metadata_system_message` to pass system message.
114
114
  system_message = prompt.metadata.get('system_message')
115
115
  if system_message:
116
+ assert isinstance(system_message, lf.SystemMessage), type(system_message)
116
117
  messages.append(
117
- lf.SystemMessage.from_value(system_message).as_format(
118
+ system_message.as_format(
118
119
  'openai', chunk_preprocessor=modality_check
119
120
  )
120
121
  )
@@ -465,7 +465,7 @@ class OpenAIComptibleTest(unittest.TestCase):
465
465
  lm(
466
466
  lf.UserMessage(
467
467
  'hello',
468
- system_message='hi',
468
+ system_message=lf.SystemMessage('hi'),
469
469
  ),
470
470
  sampling_options=lf.LMSamplingOptions(n=2)
471
471
  ),
@@ -109,6 +109,7 @@ def query(
109
109
  *,
110
110
  lm: lf.LanguageModel | list[lf.LanguageModel] | None = None,
111
111
  num_samples: int | list[int] = 1,
112
+ system_message: str | lf.Template | None = None,
112
113
  examples: list[mapping.MappingExample] | None = None,
113
114
  cache_seed: int | None = 0,
114
115
  response_postprocess: Callable[[str], str] | None = None,
@@ -244,6 +245,8 @@ def query(
244
245
  If `None`, the LM from `lf.context` will be used.
245
246
  num_samples: Number of samples to generate. If a list is provided, its
246
247
  length must match the number of models in `lm`.
248
+ system_message: System instructions to guide the model output. If None,
249
+ no system message will be used.
247
250
  examples: Few-shot examples to guide the model output. Defaults to `None`.
248
251
  cache_seed: Seed for caching the query. Queries with the same
249
252
  `(lm, prompt, cache_seed)` will use cached responses. If `None`,
@@ -282,6 +285,7 @@ def query(
282
285
  schema,
283
286
  default=default,
284
287
  lm=lm,
288
+ system_message=system_message,
285
289
  examples=examples,
286
290
  # Usually num_examples should not be large, so we multiple the user
287
291
  # provided cache seed by 100 to avoid collision.
@@ -326,6 +330,13 @@ def query(
326
330
  if isinstance(prompt, pg.Symbolic) and prompt.sym_partial and schema is None:
327
331
  schema = prompt.__class__
328
332
 
333
+ # Attach system message as input template metadata, which will be passed
334
+ # through to the rendered message metadata under key `system_message`.
335
+ if system_message is not None:
336
+ kwargs['metadata_system_message'] = lf.Template.from_value(
337
+ system_message
338
+ ).render(message_cls=lf.SystemMessage)
339
+
329
340
  # Normalize query input.
330
341
  if isinstance(prompt, (lf.Message, str)):
331
342
  # Query with structured output.
@@ -45,14 +45,16 @@ class QueryTest(unittest.TestCase):
45
45
  prompt,
46
46
  schema,
47
47
  examples: list[mapping.MappingExample] | None = None,
48
+ system_message: str | None = None,
48
49
  *,
49
50
  expected_snippet: str,
50
51
  exact_match: bool = False,
51
52
  expected_modalities: int = 0,
53
+ exepcted_system_message: str | None = None,
52
54
  **kwargs,
53
55
  ):
54
56
  m = querying.query(
55
- prompt, schema=schema, examples=examples,
57
+ prompt, schema=schema, system_message=system_message, examples=examples,
56
58
  **kwargs, returns_message=True
57
59
  )
58
60
  self.assertIsNotNone(m.lm_input)
@@ -64,6 +66,11 @@ class QueryTest(unittest.TestCase):
64
66
  len([c for c in m.lm_input.chunk() if isinstance(c, lf.Modality)]),
65
67
  expected_modalities,
66
68
  )
69
+ if system_message is not None:
70
+ self.assertEqual(
71
+ m.lm_input.system_message.text,
72
+ exepcted_system_message,
73
+ )
67
74
 
68
75
  def test_call(self):
69
76
  lm = fake.StaticSequence(['1'])
@@ -114,6 +121,19 @@ class QueryTest(unittest.TestCase):
114
121
  Activity(description='hello'),
115
122
  )
116
123
 
124
+ def test_render_with_system_message(self):
125
+ lm = fake.StaticResponse('1')
126
+ self.assert_render(
127
+ 'What is {{x}} + {{y}}?',
128
+ schema=None,
129
+ system_message='You are a helpful assistant.',
130
+ x=1,
131
+ y=2,
132
+ lm=lm.clone(),
133
+ expected_snippet='What is 1 + 2?',
134
+ exepcted_system_message='You are a helpful assistant.',
135
+ )
136
+
117
137
  def test_str_to_structure_render(self):
118
138
  lm = fake.StaticResponse('1')
119
139
  self.assert_render(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langfun
3
- Version: 0.1.2.dev202504090804
3
+ Version: 0.1.2.dev202504100804
4
4
  Summary: Langfun: Language as Functions.
5
5
  Home-page: https://github.com/google/langfun
6
6
  Author: Langfun Authors