langfun 0.0.2.dev20240319__tar.gz → 0.1.2.dev202501150804__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.
- langfun-0.1.2.dev202501150804/PKG-INFO +225 -0
- langfun-0.1.2.dev202501150804/README.md +155 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/__init__.py +22 -2
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/__init__.py +17 -5
- langfun-0.1.2.dev202501150804/langfun/core/agentic/__init__.py +30 -0
- langfun-0.1.2.dev202501150804/langfun/core/agentic/action.py +854 -0
- langfun-0.1.2.dev202501150804/langfun/core/agentic/action_eval.py +150 -0
- langfun-0.1.2.dev202501150804/langfun/core/agentic/action_eval_test.py +109 -0
- langfun-0.1.2.dev202501150804/langfun/core/agentic/action_test.py +136 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/coding/python/__init__.py +5 -11
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/coding/python/correction.py +37 -28
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/coding/python/correction_test.py +29 -3
- langfun-0.1.2.dev202501150804/langfun/core/coding/python/execution.py +119 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/coding/python/execution_test.py +29 -89
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/coding/python/generation.py +21 -11
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/coding/python/generation_test.py +2 -2
- langfun-0.1.2.dev202501150804/langfun/core/coding/python/parsing.py +147 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/coding/python/parsing_test.py +2 -105
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/component.py +69 -2
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/component_test.py +54 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/concurrent.py +414 -117
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/concurrent_test.py +111 -24
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/console.py +17 -5
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/console_test.py +17 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/eval/__init__.py +17 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/eval/base.py +801 -150
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/eval/base_test.py +241 -61
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/eval/matching.py +80 -76
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/eval/matching_test.py +20 -12
- langfun-0.1.2.dev202501150804/langfun/core/eval/patching.py +130 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/patching_test.py +170 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/eval/scoring.py +37 -28
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/eval/scoring_test.py +21 -4
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/__init__.py +42 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/checkpointing.py +380 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/checkpointing_test.py +228 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/eval_test_helper.py +136 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/evaluation.py +725 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/evaluation_test.py +180 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/example.py +305 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/example_test.py +128 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/experiment.py +1048 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/experiment_test.py +433 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/metric_values.py +156 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/metric_values_test.py +80 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/metrics.py +357 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/metrics_test.py +203 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/progress.py +348 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/progress_test.py +82 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/progress_tracking.py +210 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/progress_tracking_test.py +66 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/reporting.py +270 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/reporting_test.py +158 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/runners.py +488 -0
- langfun-0.1.2.dev202501150804/langfun/core/eval/v2/runners_test.py +334 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/langfunc.py +3 -21
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/langfunc_test.py +26 -8
- langfun-0.1.2.dev202501150804/langfun/core/language_model.py +1188 -0
- langfun-0.1.2.dev202501150804/langfun/core/language_model_test.py +983 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/__init__.py +158 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/anthropic.py +488 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/anthropic_test.py +235 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/llms/cache/base.py +21 -2
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/llms/cache/in_memory.py +13 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/llms/cache/in_memory_test.py +88 -28
- langfun-0.1.2.dev202501150804/langfun/core/llms/compositional.py +101 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/compositional_test.py +73 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/deepseek.py +117 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/deepseek_test.py +61 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/llms/fake.py +39 -26
- langfun-0.1.2.dev202501150804/langfun/core/llms/fake_test.py +241 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/gemini.py +507 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/gemini_test.py +195 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/google_genai.py +131 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/google_genai_test.py +38 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/groq.py +276 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/groq_test.py +64 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/llama_cpp.py +47 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/llama_cpp_test.py +30 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/openai.py +594 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/openai_compatible.py +179 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/openai_compatible_test.py +495 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/openai_test.py +85 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/rest.py +113 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/rest_test.py +111 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/vertexai.py +192 -0
- langfun-0.1.2.dev202501150804/langfun/core/llms/vertexai_test.py +52 -0
- langfun-0.1.2.dev202501150804/langfun/core/logging.py +284 -0
- langfun-0.1.2.dev202501150804/langfun/core/logging_test.py +125 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/message.py +319 -9
- langfun-0.1.2.dev202501150804/langfun/core/message_test.py +497 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/modalities/__init__.py +6 -2
- langfun-0.1.2.dev202501150804/langfun/core/modalities/audio.py +30 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/audio_test.py +63 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/image.py +59 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/image_test.py +108 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/mime.py +258 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/mime_test.py +140 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/ms_office.py +117 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/ms_office_test.py +389 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/pdf.py +22 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/pdf_test.py +57 -0
- langfun-0.1.2.dev202501150804/langfun/core/modalities/video.py +30 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/modalities/video_test.py +3 -3
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/modality.py +26 -3
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/modality_test.py +2 -2
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/sampling.py +11 -11
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/__init__.py +15 -16
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/completion.py +32 -5
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/completion_test.py +9 -8
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/description.py +2 -2
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/description_test.py +3 -3
- langfun-0.1.2.dev202501150804/langfun/core/structured/function_generation.py +278 -0
- langfun-0.1.2.dev202501150804/langfun/core/structured/function_generation_test.py +399 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/mapping.py +153 -47
- langfun-0.1.2.dev202501150804/langfun/core/structured/mapping_test.py +230 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/parsing.py +33 -20
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/parsing_test.py +71 -22
- langfun-0.1.2.dev202501150804/langfun/core/structured/querying.py +746 -0
- langfun-0.0.2.dev20240319/langfun/core/structured/prompting_test.py → langfun-0.1.2.dev202501150804/langfun/core/structured/querying_test.py +545 -60
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/schema.py +216 -106
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/schema_generation.py +3 -4
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/schema_generation_test.py +2 -2
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/schema_test.py +171 -55
- langfun-0.1.2.dev202501150804/langfun/core/structured/scoring.py +181 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/structured/scoring_test.py +30 -0
- langfun-0.0.2.dev20240319/langfun/core/structured/scoring.py → langfun-0.1.2.dev202501150804/langfun/core/structured/tokenization.py +20 -31
- langfun-0.1.2.dev202501150804/langfun/core/structured/tokenization_test.py +48 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/template.py +240 -11
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/template_test.py +146 -1
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/conversation.py +9 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/conversation_test.py +4 -3
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/selfplay_test.py +14 -2
- langfun-0.1.2.dev202501150804/langfun.egg-info/PKG-INFO +225 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun.egg-info/SOURCES.txt +59 -8
- langfun-0.1.2.dev202501150804/langfun.egg-info/requires.txt +43 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/setup.py +37 -15
- langfun-0.0.2.dev20240319/PKG-INFO +0 -99
- langfun-0.0.2.dev20240319/README.md +0 -67
- langfun-0.0.2.dev20240319/langfun/core/coding/python/errors.py +0 -108
- langfun-0.0.2.dev20240319/langfun/core/coding/python/errors_test.py +0 -99
- langfun-0.0.2.dev20240319/langfun/core/coding/python/execution.py +0 -295
- langfun-0.0.2.dev20240319/langfun/core/coding/python/parsing.py +0 -232
- langfun-0.0.2.dev20240319/langfun/core/coding/python/permissions.py +0 -90
- langfun-0.0.2.dev20240319/langfun/core/coding/python/permissions_test.py +0 -86
- langfun-0.0.2.dev20240319/langfun/core/language_model.py +0 -550
- langfun-0.0.2.dev20240319/langfun/core/language_model_test.py +0 -346
- langfun-0.0.2.dev20240319/langfun/core/llms/__init__.py +0 -68
- langfun-0.0.2.dev20240319/langfun/core/llms/fake_test.py +0 -116
- langfun-0.0.2.dev20240319/langfun/core/llms/gemini.py +0 -185
- langfun-0.0.2.dev20240319/langfun/core/llms/gemini_test.py +0 -163
- langfun-0.0.2.dev20240319/langfun/core/llms/llama_cpp.py +0 -72
- langfun-0.0.2.dev20240319/langfun/core/llms/llama_cpp_test.py +0 -56
- langfun-0.0.2.dev20240319/langfun/core/llms/openai.py +0 -384
- langfun-0.0.2.dev20240319/langfun/core/llms/openai_test.py +0 -224
- langfun-0.0.2.dev20240319/langfun/core/message_test.py +0 -320
- langfun-0.0.2.dev20240319/langfun/core/modalities/image.py +0 -40
- langfun-0.0.2.dev20240319/langfun/core/modalities/image_test.py +0 -65
- langfun-0.0.2.dev20240319/langfun/core/modalities/mime.py +0 -81
- langfun-0.0.2.dev20240319/langfun/core/modalities/mime_test.py +0 -59
- langfun-0.0.2.dev20240319/langfun/core/modalities/video.py +0 -44
- langfun-0.0.2.dev20240319/langfun/core/structured/mapping_test.py +0 -125
- langfun-0.0.2.dev20240319/langfun/core/structured/prompting.py +0 -217
- langfun-0.0.2.dev20240319/langfun/core/text_formatting.py +0 -162
- langfun-0.0.2.dev20240319/langfun/core/text_formatting_test.py +0 -47
- langfun-0.0.2.dev20240319/langfun.egg-info/PKG-INFO +0 -99
- langfun-0.0.2.dev20240319/langfun.egg-info/requires.txt +0 -8
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/LICENSE +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/coding/__init__.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/llms/cache/__init__.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/memories/__init__.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/memories/conversation_history.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/memories/conversation_history_test.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/memory.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/natural_language.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/natural_language_test.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/sampling_test.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/subscription.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/subscription_test.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/__init__.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/completion.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/completion_test.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/demonstration.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/demonstration_test.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun/core/templates/selfplay.py +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun.egg-info/dependency_links.txt +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/langfun.egg-info/top_level.txt +0 -0
- {langfun-0.0.2.dev20240319 → langfun-0.1.2.dev202501150804}/setup.cfg +0 -0
@@ -0,0 +1,225 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: langfun
|
3
|
+
Version: 0.1.2.dev202501150804
|
4
|
+
Summary: Langfun: Language as Functions.
|
5
|
+
Home-page: https://github.com/google/langfun
|
6
|
+
Author: Langfun Authors
|
7
|
+
Author-email: langfun-authors@google.com
|
8
|
+
License: Apache License 2.0
|
9
|
+
Keywords: llm generative-ai machine-learning
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
11
|
+
Classifier: Intended Audience :: Developers
|
12
|
+
Classifier: Intended Audience :: Education
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
21
|
+
Classifier: Topic :: Software Development :: Libraries
|
22
|
+
Description-Content-Type: text/markdown
|
23
|
+
License-File: LICENSE
|
24
|
+
Requires-Dist: pyglove>=0.4.5.dev202409110000
|
25
|
+
Requires-Dist: jinja2>=3.1.2
|
26
|
+
Requires-Dist: requests>=2.31.0
|
27
|
+
Provides-Extra: all
|
28
|
+
Requires-Dist: pyglove>=0.4.5.dev202409110000; extra == "all"
|
29
|
+
Requires-Dist: jinja2>=3.1.2; extra == "all"
|
30
|
+
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
|
+
Requires-Dist: google-auth>=2.16.0; extra == "all"
|
34
|
+
Requires-Dist: python-magic>=0.4.27; extra == "all"
|
35
|
+
Requires-Dist: python-docx>=0.8.11; extra == "all"
|
36
|
+
Requires-Dist: pillow>=10.0.0; extra == "all"
|
37
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "all"
|
38
|
+
Requires-Dist: pandas>=2.0.3; extra == "all"
|
39
|
+
Provides-Extra: ui
|
40
|
+
Requires-Dist: termcolor==1.1.0; extra == "ui"
|
41
|
+
Requires-Dist: tqdm>=4.64.1; extra == "ui"
|
42
|
+
Provides-Extra: vertexai
|
43
|
+
Requires-Dist: google-auth>=2.16.0; extra == "vertexai"
|
44
|
+
Provides-Extra: mime
|
45
|
+
Requires-Dist: python-magic>=0.4.27; extra == "mime"
|
46
|
+
Requires-Dist: python-docx>=0.8.11; extra == "mime"
|
47
|
+
Requires-Dist: pillow>=10.0.0; extra == "mime"
|
48
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "mime"
|
49
|
+
Requires-Dist: pandas>=2.0.3; extra == "mime"
|
50
|
+
Provides-Extra: mime-auto
|
51
|
+
Requires-Dist: python-magic>=0.4.27; extra == "mime-auto"
|
52
|
+
Provides-Extra: mime-docx
|
53
|
+
Requires-Dist: python-docx>=0.8.11; extra == "mime-docx"
|
54
|
+
Provides-Extra: mime-pil
|
55
|
+
Requires-Dist: pillow>=10.0.0; extra == "mime-pil"
|
56
|
+
Provides-Extra: mime-xlsx
|
57
|
+
Requires-Dist: openpyxl>=3.1.0; extra == "mime-xlsx"
|
58
|
+
Requires-Dist: pandas>=2.0.3; extra == "mime-xlsx"
|
59
|
+
Dynamic: author
|
60
|
+
Dynamic: author-email
|
61
|
+
Dynamic: classifier
|
62
|
+
Dynamic: description
|
63
|
+
Dynamic: description-content-type
|
64
|
+
Dynamic: home-page
|
65
|
+
Dynamic: keywords
|
66
|
+
Dynamic: license
|
67
|
+
Dynamic: provides-extra
|
68
|
+
Dynamic: requires-dist
|
69
|
+
Dynamic: summary
|
70
|
+
|
71
|
+
<div align="center">
|
72
|
+
<img src="https://raw.githubusercontent.com/google/langfun/main/docs/_static/logo.svg" width="520px" alt="logo"></img>
|
73
|
+
</div>
|
74
|
+
|
75
|
+
# Langfun
|
76
|
+
|
77
|
+
[](https://badge.fury.io/py/langfun)
|
78
|
+
[](https://codecov.io/gh/google/langfun)
|
79
|
+

|
80
|
+
|
81
|
+
[**Installation**](#install) | [**Getting started**](#hello-langfun) | [**Tutorial**](https://colab.research.google.com/github/google/langfun/blob/main/docs/notebooks/langfun101.ipynb) | [**Discord community**](https://discord.gg/U6wPN9R68k)
|
82
|
+
|
83
|
+
## Introduction
|
84
|
+
|
85
|
+
Langfun is a [PyGlove](https://github.com/google/pyglove) powered library that
|
86
|
+
aims to *make language models (LM) fun to work with*. Its central principle is
|
87
|
+
to enable seamless integration between natural language and programming by
|
88
|
+
treating language as functions. Through the introduction of *Object-Oriented Prompting*,
|
89
|
+
Langfun empowers users to prompt LLMs using objects and types, offering enhanced
|
90
|
+
control and simplifying agent development.
|
91
|
+
|
92
|
+
To unlock the magic of Langfun, you can start with
|
93
|
+
[Langfun 101](https://colab.research.google.com/github/google/langfun/blob/main/docs/notebooks/langfun101.ipynb). Notably, Langfun is compatible with popular LLMs such as Gemini, GPT,
|
94
|
+
Claude, all without the need for additional fine-tuning.
|
95
|
+
|
96
|
+
## Why Langfun?
|
97
|
+
|
98
|
+
Langfun is *powerful and scalable*:
|
99
|
+
|
100
|
+
* Seamless integration between natural language and computer programs.
|
101
|
+
* Modular prompts, which allows a natural blend of texts and modalities;
|
102
|
+
* Efficient for both request-based workflows and batch jobs;
|
103
|
+
* A powerful eval framework that thrives dimension explosions.
|
104
|
+
|
105
|
+
Langfun is *simple and elegant*:
|
106
|
+
|
107
|
+
* An intuitive programming model, graspable in 5 minutes;
|
108
|
+
* Plug-and-play into any Python codebase, making an immediate difference;
|
109
|
+
* Comprehensive LLMs under a unified API: Gemini, GPT, Claude, Llama3, and more.
|
110
|
+
* Designed for agile developement: offering intellisense, easy debugging, with minimal overhead;
|
111
|
+
|
112
|
+
## Hello, Langfun
|
113
|
+
|
114
|
+
```python
|
115
|
+
import langfun as lf
|
116
|
+
import pyglove as pg
|
117
|
+
|
118
|
+
from IPython import display
|
119
|
+
|
120
|
+
class Item(pg.Object):
|
121
|
+
name: str
|
122
|
+
color: str
|
123
|
+
|
124
|
+
class ImageDescription(pg.Object):
|
125
|
+
items: list[Item]
|
126
|
+
|
127
|
+
image = lf.Image.from_uri('https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Solar_system.jpg/1646px-Solar_system.jpg')
|
128
|
+
display.display(image)
|
129
|
+
|
130
|
+
desc = lf.query(
|
131
|
+
'Describe objects in {{my_image}} from top to bottom.',
|
132
|
+
ImageDescription,
|
133
|
+
lm=lf.llms.Gpt4o(api_key='<your-openai-api-key>'),
|
134
|
+
my_image=image,
|
135
|
+
)
|
136
|
+
print(desc)
|
137
|
+
```
|
138
|
+
*Output:*
|
139
|
+
|
140
|
+
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Solar_system.jpg/1646px-Solar_system.jpg" width="520px" alt="my_image"></img>
|
141
|
+
|
142
|
+
```
|
143
|
+
ImageDescription(
|
144
|
+
items = [
|
145
|
+
0 : Item(
|
146
|
+
name = 'Mercury',
|
147
|
+
color = 'Gray'
|
148
|
+
),
|
149
|
+
1 : Item(
|
150
|
+
name = 'Venus',
|
151
|
+
color = 'Yellow'
|
152
|
+
),
|
153
|
+
2 : Item(
|
154
|
+
name = 'Earth',
|
155
|
+
color = 'Blue and white'
|
156
|
+
),
|
157
|
+
3 : Item(
|
158
|
+
name = 'Moon',
|
159
|
+
color = 'Gray'
|
160
|
+
),
|
161
|
+
4 : Item(
|
162
|
+
name = 'Mars',
|
163
|
+
color = 'Red'
|
164
|
+
),
|
165
|
+
5 : Item(
|
166
|
+
name = 'Jupiter',
|
167
|
+
color = 'Brown and white'
|
168
|
+
),
|
169
|
+
6 : Item(
|
170
|
+
name = 'Saturn',
|
171
|
+
color = 'Yellowish-brown with rings'
|
172
|
+
),
|
173
|
+
7 : Item(
|
174
|
+
name = 'Uranus',
|
175
|
+
color = 'Light blue'
|
176
|
+
),
|
177
|
+
8 : Item(
|
178
|
+
name = 'Neptune',
|
179
|
+
color = 'Dark blue'
|
180
|
+
)
|
181
|
+
]
|
182
|
+
)
|
183
|
+
```
|
184
|
+
See [Langfun 101](https://colab.research.google.com/github/google/langfun/blob/main/docs/notebooks/langfun101.ipynb) for more examples.
|
185
|
+
|
186
|
+
## Install
|
187
|
+
|
188
|
+
Langfun offers a range of features through [Extras](https://packaging.python.org/en/latest/tutorials/installing-packages/#installing-extras), allowing users to install only what they need. The minimal installation of Langfun requires only [PyGlove](https://github.com/google/pyglove), [Jinja2](https://github.com/pallets/jinja/), and [requests](https://github.com/psf/requests). To install Langfun with its minimal dependencies, use:
|
189
|
+
|
190
|
+
```
|
191
|
+
pip install langfun
|
192
|
+
```
|
193
|
+
|
194
|
+
For a complete installation with all dependencies, use:
|
195
|
+
|
196
|
+
```
|
197
|
+
pip install langfun[all]
|
198
|
+
```
|
199
|
+
|
200
|
+
To install a nightly build, include the `--pre` flag, like this:
|
201
|
+
|
202
|
+
```
|
203
|
+
pip install langfun[all] --pre
|
204
|
+
```
|
205
|
+
|
206
|
+
If you want to customize your installation, you can select specific features using package names like `langfun[X1, X2, ..., Xn]`, where `Xi` corresponds to a tag from the list below:
|
207
|
+
|
208
|
+
| Tag | Description |
|
209
|
+
| ------------------- | ---------------------------------------- |
|
210
|
+
| all | All Langfun features. |
|
211
|
+
| vertexai | VertexAI access. |
|
212
|
+
| mime | All MIME supports. |
|
213
|
+
| mime-auto | Automatic MIME type detection. |
|
214
|
+
| mime-docx | DocX format support. |
|
215
|
+
| mime-pil | Image support for PIL. |
|
216
|
+
| mime-xlsx | XlsX format support. |
|
217
|
+
| ui | UI enhancements |
|
218
|
+
|
219
|
+
|
220
|
+
For example, to install a nightly build that includes VertexAI access, full modality support, and UI enhancements, use:
|
221
|
+
```
|
222
|
+
pip install langfun[vertexai,mime,ui] --pre
|
223
|
+
```
|
224
|
+
|
225
|
+
*Disclaimer: this is not an officially supported Google product.*
|
@@ -0,0 +1,155 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<img src="https://raw.githubusercontent.com/google/langfun/main/docs/_static/logo.svg" width="520px" alt="logo"></img>
|
3
|
+
</div>
|
4
|
+
|
5
|
+
# Langfun
|
6
|
+
|
7
|
+
[](https://badge.fury.io/py/langfun)
|
8
|
+
[](https://codecov.io/gh/google/langfun)
|
9
|
+

|
10
|
+
|
11
|
+
[**Installation**](#install) | [**Getting started**](#hello-langfun) | [**Tutorial**](https://colab.research.google.com/github/google/langfun/blob/main/docs/notebooks/langfun101.ipynb) | [**Discord community**](https://discord.gg/U6wPN9R68k)
|
12
|
+
|
13
|
+
## Introduction
|
14
|
+
|
15
|
+
Langfun is a [PyGlove](https://github.com/google/pyglove) powered library that
|
16
|
+
aims to *make language models (LM) fun to work with*. Its central principle is
|
17
|
+
to enable seamless integration between natural language and programming by
|
18
|
+
treating language as functions. Through the introduction of *Object-Oriented Prompting*,
|
19
|
+
Langfun empowers users to prompt LLMs using objects and types, offering enhanced
|
20
|
+
control and simplifying agent development.
|
21
|
+
|
22
|
+
To unlock the magic of Langfun, you can start with
|
23
|
+
[Langfun 101](https://colab.research.google.com/github/google/langfun/blob/main/docs/notebooks/langfun101.ipynb). Notably, Langfun is compatible with popular LLMs such as Gemini, GPT,
|
24
|
+
Claude, all without the need for additional fine-tuning.
|
25
|
+
|
26
|
+
## Why Langfun?
|
27
|
+
|
28
|
+
Langfun is *powerful and scalable*:
|
29
|
+
|
30
|
+
* Seamless integration between natural language and computer programs.
|
31
|
+
* Modular prompts, which allows a natural blend of texts and modalities;
|
32
|
+
* Efficient for both request-based workflows and batch jobs;
|
33
|
+
* A powerful eval framework that thrives dimension explosions.
|
34
|
+
|
35
|
+
Langfun is *simple and elegant*:
|
36
|
+
|
37
|
+
* An intuitive programming model, graspable in 5 minutes;
|
38
|
+
* Plug-and-play into any Python codebase, making an immediate difference;
|
39
|
+
* Comprehensive LLMs under a unified API: Gemini, GPT, Claude, Llama3, and more.
|
40
|
+
* Designed for agile developement: offering intellisense, easy debugging, with minimal overhead;
|
41
|
+
|
42
|
+
## Hello, Langfun
|
43
|
+
|
44
|
+
```python
|
45
|
+
import langfun as lf
|
46
|
+
import pyglove as pg
|
47
|
+
|
48
|
+
from IPython import display
|
49
|
+
|
50
|
+
class Item(pg.Object):
|
51
|
+
name: str
|
52
|
+
color: str
|
53
|
+
|
54
|
+
class ImageDescription(pg.Object):
|
55
|
+
items: list[Item]
|
56
|
+
|
57
|
+
image = lf.Image.from_uri('https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Solar_system.jpg/1646px-Solar_system.jpg')
|
58
|
+
display.display(image)
|
59
|
+
|
60
|
+
desc = lf.query(
|
61
|
+
'Describe objects in {{my_image}} from top to bottom.',
|
62
|
+
ImageDescription,
|
63
|
+
lm=lf.llms.Gpt4o(api_key='<your-openai-api-key>'),
|
64
|
+
my_image=image,
|
65
|
+
)
|
66
|
+
print(desc)
|
67
|
+
```
|
68
|
+
*Output:*
|
69
|
+
|
70
|
+
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/83/Solar_system.jpg/1646px-Solar_system.jpg" width="520px" alt="my_image"></img>
|
71
|
+
|
72
|
+
```
|
73
|
+
ImageDescription(
|
74
|
+
items = [
|
75
|
+
0 : Item(
|
76
|
+
name = 'Mercury',
|
77
|
+
color = 'Gray'
|
78
|
+
),
|
79
|
+
1 : Item(
|
80
|
+
name = 'Venus',
|
81
|
+
color = 'Yellow'
|
82
|
+
),
|
83
|
+
2 : Item(
|
84
|
+
name = 'Earth',
|
85
|
+
color = 'Blue and white'
|
86
|
+
),
|
87
|
+
3 : Item(
|
88
|
+
name = 'Moon',
|
89
|
+
color = 'Gray'
|
90
|
+
),
|
91
|
+
4 : Item(
|
92
|
+
name = 'Mars',
|
93
|
+
color = 'Red'
|
94
|
+
),
|
95
|
+
5 : Item(
|
96
|
+
name = 'Jupiter',
|
97
|
+
color = 'Brown and white'
|
98
|
+
),
|
99
|
+
6 : Item(
|
100
|
+
name = 'Saturn',
|
101
|
+
color = 'Yellowish-brown with rings'
|
102
|
+
),
|
103
|
+
7 : Item(
|
104
|
+
name = 'Uranus',
|
105
|
+
color = 'Light blue'
|
106
|
+
),
|
107
|
+
8 : Item(
|
108
|
+
name = 'Neptune',
|
109
|
+
color = 'Dark blue'
|
110
|
+
)
|
111
|
+
]
|
112
|
+
)
|
113
|
+
```
|
114
|
+
See [Langfun 101](https://colab.research.google.com/github/google/langfun/blob/main/docs/notebooks/langfun101.ipynb) for more examples.
|
115
|
+
|
116
|
+
## Install
|
117
|
+
|
118
|
+
Langfun offers a range of features through [Extras](https://packaging.python.org/en/latest/tutorials/installing-packages/#installing-extras), allowing users to install only what they need. The minimal installation of Langfun requires only [PyGlove](https://github.com/google/pyglove), [Jinja2](https://github.com/pallets/jinja/), and [requests](https://github.com/psf/requests). To install Langfun with its minimal dependencies, use:
|
119
|
+
|
120
|
+
```
|
121
|
+
pip install langfun
|
122
|
+
```
|
123
|
+
|
124
|
+
For a complete installation with all dependencies, use:
|
125
|
+
|
126
|
+
```
|
127
|
+
pip install langfun[all]
|
128
|
+
```
|
129
|
+
|
130
|
+
To install a nightly build, include the `--pre` flag, like this:
|
131
|
+
|
132
|
+
```
|
133
|
+
pip install langfun[all] --pre
|
134
|
+
```
|
135
|
+
|
136
|
+
If you want to customize your installation, you can select specific features using package names like `langfun[X1, X2, ..., Xn]`, where `Xi` corresponds to a tag from the list below:
|
137
|
+
|
138
|
+
| Tag | Description |
|
139
|
+
| ------------------- | ---------------------------------------- |
|
140
|
+
| all | All Langfun features. |
|
141
|
+
| vertexai | VertexAI access. |
|
142
|
+
| mime | All MIME supports. |
|
143
|
+
| mime-auto | Automatic MIME type detection. |
|
144
|
+
| mime-docx | DocX format support. |
|
145
|
+
| mime-pil | Image support for PIL. |
|
146
|
+
| mime-xlsx | XlsX format support. |
|
147
|
+
| ui | UI enhancements |
|
148
|
+
|
149
|
+
|
150
|
+
For example, to install a nightly build that includes VertexAI access, full modality support, and UI enhancements, use:
|
151
|
+
```
|
152
|
+
pip install langfun[vertexai,mime,ui] --pre
|
153
|
+
```
|
154
|
+
|
155
|
+
*Disclaimer: this is not an officially supported Google product.*
|
@@ -23,6 +23,8 @@ Schema = structured.Schema
|
|
23
23
|
MISSING = structured.MISSING
|
24
24
|
UNKNOWN = structured.UNKNOWN
|
25
25
|
|
26
|
+
include_method_in_prompt = structured.include_method_in_prompt
|
27
|
+
|
26
28
|
MappingExample = structured.MappingExample
|
27
29
|
|
28
30
|
call = structured.call
|
@@ -33,7 +35,18 @@ complete = structured.complete
|
|
33
35
|
score = structured.score
|
34
36
|
generate_class = structured.generate_class
|
35
37
|
|
38
|
+
track_queries = structured.track_queries
|
39
|
+
|
40
|
+
# Helper function for map-reduce style querying.
|
41
|
+
query_and_reduce = structured.query_and_reduce
|
42
|
+
|
43
|
+
# Helper functions for input/output transformations based on
|
44
|
+
# `lf.query` (e.g. jax-on-beam could use these for batch processing)
|
45
|
+
query_prompt = structured.query_prompt
|
46
|
+
query_output = structured.query_output
|
47
|
+
|
36
48
|
source_form = structured.source_form
|
49
|
+
function_gen = structured.function_gen
|
37
50
|
|
38
51
|
from langfun.core import eval # pylint: disable=redefined-builtin
|
39
52
|
from langfun.core import templates
|
@@ -45,15 +58,22 @@ PythonFunction = coding.PythonFunction
|
|
45
58
|
from langfun.core import llms
|
46
59
|
lm_cache = llms.cache.lm_cache
|
47
60
|
|
61
|
+
from langfun.core import agentic
|
62
|
+
Action = agentic.Action
|
63
|
+
Session = agentic.Session
|
64
|
+
|
48
65
|
from langfun.core import memories
|
49
66
|
|
50
67
|
from langfun.core import modalities
|
51
68
|
|
69
|
+
Mime = modalities.Mime
|
70
|
+
MimeType = Mime # For backwards compatibility.
|
52
71
|
Image = modalities.Image
|
53
72
|
Video = modalities.Video
|
54
73
|
PDF = modalities.PDF
|
55
74
|
|
56
|
-
#
|
75
|
+
# Additional error types.
|
76
|
+
MappingError = structured.MappingError
|
57
77
|
SchemaError = structured.SchemaError
|
58
78
|
JsonError = structured.JsonError
|
59
79
|
CodeError = coding.CodeError
|
@@ -64,4 +84,4 @@ CodeError = coding.CodeError
|
|
64
84
|
# pylint: enable=g-import-not-at-top
|
65
85
|
# pylint: enable=g-bad-import-order
|
66
86
|
|
67
|
-
__version__ = "0.
|
87
|
+
__version__ = "0.1.2"
|
@@ -45,6 +45,7 @@ use_context = context
|
|
45
45
|
from langfun.core.component import use_settings
|
46
46
|
|
47
47
|
from langfun.core.component import get_contextual_override
|
48
|
+
from langfun.core.component import context_value
|
48
49
|
|
49
50
|
# Value marker for attribute whose values will be provided from parent
|
50
51
|
# objects or from the `pg.component_context` context manager.
|
@@ -71,16 +72,12 @@ from langfun.core.sampling import random_sample
|
|
71
72
|
|
72
73
|
# Concurrent execute a function with parallel inputs with inheriting current
|
73
74
|
# context's defaults and overrides.
|
75
|
+
from langfun.core.concurrent import RetryEntry
|
74
76
|
from langfun.core.concurrent import concurrent_execute
|
75
77
|
from langfun.core.concurrent import concurrent_map
|
76
78
|
from langfun.core.concurrent import with_context_access
|
77
79
|
from langfun.core.concurrent import with_retry
|
78
80
|
|
79
|
-
# Utility libraries for text formatting.
|
80
|
-
from langfun.core.text_formatting import colored
|
81
|
-
from langfun.core.text_formatting import colored_print as print # pylint: disable=redefined-builtin
|
82
|
-
from langfun.core.text_formatting import colored_template
|
83
|
-
|
84
81
|
# Interface for natural language formattable.
|
85
82
|
from langfun.core.natural_language import NaturalLanguageFormattable
|
86
83
|
|
@@ -94,22 +91,37 @@ from langfun.core.message import MemoryRecord
|
|
94
91
|
# Interface for modality.
|
95
92
|
from langfun.core.modality import Modality
|
96
93
|
from langfun.core.modality import ModalityRef
|
94
|
+
from langfun.core.modality import ModalityError
|
97
95
|
|
98
96
|
# Interfaces for languge models.
|
99
97
|
from langfun.core.language_model import LanguageModel
|
100
98
|
from langfun.core.language_model import LMSample
|
101
99
|
from langfun.core.language_model import LMSamplingOptions
|
100
|
+
from langfun.core.language_model import LMSamplingUsage
|
101
|
+
from langfun.core.language_model import UsageNotAvailable
|
102
|
+
from langfun.core.language_model import UsageSummary
|
102
103
|
from langfun.core.language_model import LMSamplingResult
|
103
104
|
from langfun.core.language_model import LMScoringResult
|
104
105
|
from langfun.core.language_model import LMCache
|
105
106
|
from langfun.core.language_model import LMDebugMode
|
106
107
|
|
108
|
+
from langfun.core.language_model import LMError
|
109
|
+
from langfun.core.language_model import RetryableLMError
|
110
|
+
from langfun.core.language_model import RateLimitError
|
111
|
+
from langfun.core.language_model import TemporaryLMError
|
112
|
+
|
113
|
+
# Context manager for tracking usages.
|
114
|
+
from langfun.core.language_model import track_usages
|
115
|
+
|
107
116
|
# Components for building agents.
|
108
117
|
from langfun.core.memory import Memory
|
109
118
|
|
110
119
|
# Utility for console output.
|
111
120
|
from langfun.core import console
|
112
121
|
|
122
|
+
# Utility for event logging.
|
123
|
+
from langfun.core import logging
|
124
|
+
|
113
125
|
# Import internal modules.
|
114
126
|
|
115
127
|
# pylint: enable=g-import-not-at-top
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# Copyright 2024 The Langfun Authors
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
"""Langfun agentic framework.."""
|
15
|
+
|
16
|
+
# pylint: disable=g-bad-import-order
|
17
|
+
# pylint: disable=g-importing-member
|
18
|
+
# pylint: disable=g-import-not-at-top
|
19
|
+
|
20
|
+
from langfun.core.agentic.action import Action
|
21
|
+
from langfun.core.agentic.action import ActionInvocation
|
22
|
+
from langfun.core.agentic.action import Session
|
23
|
+
|
24
|
+
from langfun.core.agentic.action_eval import ActionEval
|
25
|
+
from langfun.core.agentic.action_eval import ActionEvalV1
|
26
|
+
|
27
|
+
|
28
|
+
# pylint: enable=g-bad-import-order
|
29
|
+
# pylint: enable=g-importing-member
|
30
|
+
# pylint: enable=g-import-not-at-top
|