langfun 0.1.2.dev202409110804__py3-none-any.whl → 0.1.2.dev202409120804__py3-none-any.whl
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/core/component.py +1 -1
- langfun/core/eval/base.py +1 -1
- langfun/core/llms/google_genai.py +4 -4
- langfun/core/llms/google_genai_test.py +27 -25
- langfun/core/structured/schema.py +2 -12
- {langfun-0.1.2.dev202409110804.dist-info → langfun-0.1.2.dev202409120804.dist-info}/METADATA +4 -4
- {langfun-0.1.2.dev202409110804.dist-info → langfun-0.1.2.dev202409120804.dist-info}/RECORD +10 -10
- {langfun-0.1.2.dev202409110804.dist-info → langfun-0.1.2.dev202409120804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202409110804.dist-info → langfun-0.1.2.dev202409120804.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202409110804.dist-info → langfun-0.1.2.dev202409120804.dist-info}/top_level.txt +0 -0
langfun/core/component.py
CHANGED
@@ -73,7 +73,7 @@ class Component(pg.Object):
|
|
73
73
|
field.value.set_default(attr_value)
|
74
74
|
additional_fields.append(field)
|
75
75
|
if additional_fields:
|
76
|
-
|
76
|
+
cls.update_schema(additional_fields)
|
77
77
|
|
78
78
|
def _on_bound(self):
|
79
79
|
super()._on_bound()
|
langfun/core/eval/base.py
CHANGED
@@ -941,7 +941,7 @@ class Evaluation(Evaluable):
|
|
941
941
|
|
942
942
|
fields = list(cls.__schema__.values())
|
943
943
|
fields.insert(0, (self.completion_prompt_field, pg.typing.Str()))
|
944
|
-
|
944
|
+
cls.update_schema(fields, extend=False)
|
945
945
|
|
946
946
|
def _maybe_adjust_examples_for_completion(
|
947
947
|
self,
|
@@ -27,18 +27,18 @@ try:
|
|
27
27
|
import google.generativeai as genai # pylint: disable=g-import-not-at-top
|
28
28
|
BlobDict = genai.types.BlobDict
|
29
29
|
GenerativeModel = genai.GenerativeModel
|
30
|
-
Completion = genai.types
|
30
|
+
Completion = getattr(genai.types, 'Completion', Any)
|
31
|
+
ChatResponse = getattr(genai.types, 'ChatResponse', Any)
|
32
|
+
GenerateContentResponse = getattr(genai.types, 'GenerateContentResponse', Any)
|
31
33
|
GenerationConfig = genai.GenerationConfig
|
32
|
-
GenerateContentResponse = genai.types.GenerateContentResponse
|
33
|
-
ChatResponse = genai.types.ChatResponse
|
34
34
|
except ImportError:
|
35
35
|
genai = None
|
36
36
|
BlobDict = Any
|
37
37
|
GenerativeModel = Any
|
38
38
|
Completion = Any
|
39
|
+
ChatResponse = Any
|
39
40
|
GenerationConfig = Any
|
40
41
|
GenerateContentResponse = Any
|
41
|
-
ChatResponse = Any
|
42
42
|
|
43
43
|
|
44
44
|
@lf.use_init_args(['model'])
|
@@ -192,39 +192,41 @@ class GenAITest(unittest.TestCase):
|
|
192
192
|
def test_call_with_legacy_completion_model(self):
|
193
193
|
orig_get_model = genai.get_model
|
194
194
|
genai.get_model = mock_get_model
|
195
|
-
orig_generate_text = genai
|
196
|
-
|
195
|
+
orig_generate_text = getattr(genai, 'generate_text', None)
|
196
|
+
if orig_generate_text is not None:
|
197
|
+
genai.generate_text = mock_generate_text
|
197
198
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
199
|
+
lm = google_genai.Palm2(api_key='test_key')
|
200
|
+
self.maxDiff = None
|
201
|
+
self.assertEqual(
|
202
|
+
lm('hello', temperature=2.0, top_k=20).text,
|
203
|
+
(
|
204
|
+
"hello to models/text-bison-001 with {'temperature': 2.0, "
|
205
|
+
"'top_k': 20, 'top_p': None, 'candidate_count': 1, "
|
206
|
+
"'max_output_tokens': None, 'stop_sequences': None}"
|
207
|
+
),
|
208
|
+
)
|
209
|
+
genai.generate_text = orig_generate_text
|
208
210
|
genai.get_model = orig_get_model
|
209
|
-
genai.generate_text = orig_generate_text
|
210
211
|
|
211
212
|
def test_call_with_legacy_chat_model(self):
|
212
213
|
orig_get_model = genai.get_model
|
213
214
|
genai.get_model = mock_get_model
|
214
|
-
orig_chat = genai
|
215
|
-
|
215
|
+
orig_chat = getattr(genai, 'chat', None)
|
216
|
+
if orig_chat is not None:
|
217
|
+
genai.chat = mock_chat
|
216
218
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
219
|
+
lm = google_genai.Palm2_IT(api_key='test_key')
|
220
|
+
self.maxDiff = None
|
221
|
+
self.assertEqual(
|
222
|
+
lm('hello', temperature=2.0, top_k=20).text,
|
223
|
+
(
|
224
|
+
"hello to models/chat-bison-001 with {'temperature': 2.0, "
|
225
|
+
"'top_k': 20, 'top_p': None, 'candidate_count': 1}"
|
226
|
+
),
|
227
|
+
)
|
228
|
+
genai.chat = orig_chat
|
226
229
|
genai.get_model = orig_get_model
|
227
|
-
genai.chat = orig_chat
|
228
230
|
|
229
231
|
|
230
232
|
if __name__ == '__main__':
|
@@ -262,7 +262,7 @@ def class_dependencies(
|
|
262
262
|
)
|
263
263
|
|
264
264
|
# Add members as dependencies.
|
265
|
-
for field in
|
265
|
+
for field in pg.schema(vs.cls).values():
|
266
266
|
_fill_dependencies(field.value, include_subclasses)
|
267
267
|
_add_dependency(vs.cls)
|
268
268
|
|
@@ -390,7 +390,7 @@ def class_definition(
|
|
390
390
|
) -> str:
|
391
391
|
"""Returns the Python class definition."""
|
392
392
|
out = io.StringIO()
|
393
|
-
schema =
|
393
|
+
schema = pg.schema(cls)
|
394
394
|
eligible_bases = []
|
395
395
|
for base_cls in cls.__bases__:
|
396
396
|
if base_cls is not object:
|
@@ -913,13 +913,3 @@ class Unknown(pg.Object, pg.typing.CustomTyping):
|
|
913
913
|
|
914
914
|
|
915
915
|
UNKNOWN = Unknown()
|
916
|
-
|
917
|
-
|
918
|
-
def _pg_schema(cls: Type[Any]) -> pg.Schema:
|
919
|
-
"""Returns PyGlove schema for the constructor of a class."""
|
920
|
-
schema = getattr(cls, '__schema__', None)
|
921
|
-
if schema is None:
|
922
|
-
schema = pg.symbolic.callable_schema(
|
923
|
-
cls.__init__, auto_typing=True, auto_doc=True, remove_self=True
|
924
|
-
)
|
925
|
-
return schema
|
{langfun-0.1.2.dev202409110804.dist-info → langfun-0.1.2.dev202409120804.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: langfun
|
3
|
-
Version: 0.1.2.
|
3
|
+
Version: 0.1.2.dev202409120804
|
4
4
|
Summary: Langfun: Language as Functions.
|
5
5
|
Home-page: https://github.com/google/langfun
|
6
6
|
Author: Langfun Authors
|
@@ -21,11 +21,11 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
21
|
Classifier: Topic :: Software Development :: Libraries
|
22
22
|
Description-Content-Type: text/markdown
|
23
23
|
License-File: LICENSE
|
24
|
-
Requires-Dist: pyglove>=0.4.5.
|
24
|
+
Requires-Dist: pyglove>=0.4.5.dev202409110000
|
25
25
|
Requires-Dist: jinja2>=3.1.2
|
26
26
|
Requires-Dist: requests>=2.31.0
|
27
27
|
Provides-Extra: all
|
28
|
-
Requires-Dist: pyglove>=0.4.5.
|
28
|
+
Requires-Dist: pyglove>=0.4.5.dev202409110000; extra == "all"
|
29
29
|
Requires-Dist: jinja2>=3.1.2; extra == "all"
|
30
30
|
Requires-Dist: requests>=2.31.0; extra == "all"
|
31
31
|
Requires-Dist: termcolor==1.1.0; extra == "all"
|
@@ -80,7 +80,7 @@ Requires-Dist: tqdm>=4.64.1; extra == "ui"
|
|
80
80
|
[](https://codecov.io/gh/google/langfun)
|
81
81
|

|
82
82
|
|
83
|
-
[**Installation**](#install) | [**Getting started**](#hello-langfun) | [**Tutorial**](https://colab.research.google.com/github/google/langfun/blob/main/docs/notebooks/langfun101.ipynb)
|
83
|
+
[**Installation**](#install) | [**Getting started**](#hello-langfun) | [**Tutorial**](https://colab.research.google.com/github/google/langfun/blob/main/docs/notebooks/langfun101.ipynb)
|
84
84
|
|
85
85
|
## Introduction
|
86
86
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
langfun/__init__.py,sha256=mCES7t3R7Z-ZQYvG38-yrVqZubrXNfGCa8tI5HGB7mE,2274
|
2
2
|
langfun/core/__init__.py,sha256=r86kuy-BiJIveqnXx5OklUUXtMG3q79nWRBum6zFOCQ,4835
|
3
|
-
langfun/core/component.py,sha256=
|
3
|
+
langfun/core/component.py,sha256=nxF4UD7NLduPjrf4IAtysMAIg3IChfoQHjY77vC8f_E,10263
|
4
4
|
langfun/core/component_test.py,sha256=q15Xn51cVTu2RKxZ9U5VQgT3bm6RQ4638bKhWBtvW5o,8220
|
5
5
|
langfun/core/concurrent.py,sha256=qZteOkA7jzLt7a5AVmNqDc5ZEvj_hwiLECqGMVYdzSU,27756
|
6
6
|
langfun/core/concurrent_test.py,sha256=ULVrE6JGzsClRBLHAlqLF1A2mfxMO2X0245qYTYQ76o,16943
|
@@ -44,7 +44,7 @@ langfun/core/coding/python/parsing_test.py,sha256=9vAWF484kWIm6JZq8NFiMgKUDhXV-d
|
|
44
44
|
langfun/core/coding/python/permissions.py,sha256=1QWGHvzL8MM0Ok_auQ9tURqZHtdOfJaDpBzZ29GUE-c,2544
|
45
45
|
langfun/core/coding/python/permissions_test.py,sha256=w5EDb8QxpxgJyZkojyzVWQvDfg366zn99-g__6TbPQ0,2699
|
46
46
|
langfun/core/eval/__init__.py,sha256=Ogdr9OtTywhhLPHi3AZzOD2mXX2oyaHWflrSTMm96uA,1899
|
47
|
-
langfun/core/eval/base.py,sha256=
|
47
|
+
langfun/core/eval/base.py,sha256=xDZQ3lu5oJaPDZCE5-QbBEajq--HRU64GVKb3xB64aI,74738
|
48
48
|
langfun/core/eval/base_test.py,sha256=VEraWaRybSxOCOcZrZouNkiroDEPR6uyFBJoAz-1pQg,26930
|
49
49
|
langfun/core/eval/matching.py,sha256=9GX8HfO9jKxgNLAivgy5K88Xhoh6Z7Pptq65pe7vht8,9762
|
50
50
|
langfun/core/eval/matching_test.py,sha256=f7iVyXH5KGJBWt4Wp14Bt9J3X59A6Ayfog9MbuFvPew,5532
|
@@ -57,8 +57,8 @@ langfun/core/llms/anthropic.py,sha256=Gon3fOi31RhZFgNd0ijyTnKnUdp9hrWrCoSXyO4UaL
|
|
57
57
|
langfun/core/llms/anthropic_test.py,sha256=T-swuMkfnlgs8Fpif4rtXs579exGk0TsbLMirXDZCkg,5533
|
58
58
|
langfun/core/llms/fake.py,sha256=gCHBYBLvBCsC78HI1hpoqXCS-p1FMTgY1P1qh_sGBPk,3070
|
59
59
|
langfun/core/llms/fake_test.py,sha256=sIl_Mg7nFVjaN7AJhYCpA_qzDJpSnJzkazepGXpfQQg,7338
|
60
|
-
langfun/core/llms/google_genai.py,sha256=
|
61
|
-
langfun/core/llms/google_genai_test.py,sha256=
|
60
|
+
langfun/core/llms/google_genai.py,sha256=btUIfWteBoj8Jl0j8d3e8hyI6p3Biq4rldlQYctVQfg,10936
|
61
|
+
langfun/core/llms/google_genai_test.py,sha256=zw14sgWmk0P_irHyb7vpPy1WAuLEE0PmyfiFElu03sA,7686
|
62
62
|
langfun/core/llms/groq.py,sha256=pqtyOZ_1_OJMOg8xATWT_B_SVbuT9nMRf4VkH9GzW8g,6308
|
63
63
|
langfun/core/llms/groq_test.py,sha256=GYF_Qtq5S1H1TrKH38t6_lkdroqT7v-joYLDKnmS9e0,5274
|
64
64
|
langfun/core/llms/llama_cpp.py,sha256=9tXQntSCDtjTF3bnyJrAPCr4N6wycy5nXYvp9uduygE,2843
|
@@ -102,7 +102,7 @@ langfun/core/structured/parsing.py,sha256=keoVqEfzAbdULh6GawWFsTQzU91MzJXYFZjXGX
|
|
102
102
|
langfun/core/structured/parsing_test.py,sha256=34wDrXaQ-EYhJLfDL8mX9K53oQMSzh5pVYdKjnESmK8,20895
|
103
103
|
langfun/core/structured/prompting.py,sha256=_U6Z65AwXvVvfaQFCY9GawB_QV9S3u7P7BOU2URABmw,8873
|
104
104
|
langfun/core/structured/prompting_test.py,sha256=SyyBMmw-gwnrnr1MrwkjZiQaMq85kc9MHoYwzCITa10,23266
|
105
|
-
langfun/core/structured/schema.py,sha256=
|
105
|
+
langfun/core/structured/schema.py,sha256=zpK3UqHPgxaHWptMr4I4zd_f22Yn4IFxF655d4O_jmQ,27416
|
106
106
|
langfun/core/structured/schema_generation.py,sha256=U3nRQsqmMZg_qIVDh2fiY3K4JLfsAL1LcKzIFP1iXFg,5316
|
107
107
|
langfun/core/structured/schema_generation_test.py,sha256=RM9s71kMNg2jTePwInkiW9fK1ACN37eyPeF8OII-0zw,2950
|
108
108
|
langfun/core/structured/schema_test.py,sha256=RjYhwTgktQgyqAjzLvo967nTiIK9KWgP-aNGg4e7ihE,25258
|
@@ -119,8 +119,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
119
119
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
120
120
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
121
121
|
langfun/core/templates/selfplay_test.py,sha256=rBW2Qr8yi-aWYwoTwRR-n1peKyMX9QXPZXURjLgoiRs,2264
|
122
|
-
langfun-0.1.2.
|
123
|
-
langfun-0.1.2.
|
124
|
-
langfun-0.1.2.
|
125
|
-
langfun-0.1.2.
|
126
|
-
langfun-0.1.2.
|
122
|
+
langfun-0.1.2.dev202409120804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
123
|
+
langfun-0.1.2.dev202409120804.dist-info/METADATA,sha256=4K_LYV0fVAK6UYIXSgrP56BJ1IyoSOSVTMqEFNHkFyU,8833
|
124
|
+
langfun-0.1.2.dev202409120804.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
125
|
+
langfun-0.1.2.dev202409120804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
126
|
+
langfun-0.1.2.dev202409120804.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{langfun-0.1.2.dev202409110804.dist-info → langfun-0.1.2.dev202409120804.dist-info}/top_level.txt
RENAMED
File without changes
|