langfun 0.0.2.dev20240627__py3-none-any.whl → 0.0.2.dev20240629__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.
Potentially problematic release.
This version of langfun might be problematic. Click here for more details.
- langfun/core/language_model.py +5 -2
- langfun/core/language_model_test.py +6 -6
- langfun/core/llms/__init__.py +2 -0
- langfun/core/llms/vertexai.py +16 -1
- {langfun-0.0.2.dev20240627.dist-info → langfun-0.0.2.dev20240629.dist-info}/METADATA +1 -1
- {langfun-0.0.2.dev20240627.dist-info → langfun-0.0.2.dev20240629.dist-info}/RECORD +9 -9
- {langfun-0.0.2.dev20240627.dist-info → langfun-0.0.2.dev20240629.dist-info}/LICENSE +0 -0
- {langfun-0.0.2.dev20240627.dist-info → langfun-0.0.2.dev20240629.dist-info}/WHEEL +0 -0
- {langfun-0.0.2.dev20240627.dist-info → langfun-0.0.2.dev20240629.dist-info}/top_level.txt +0 -0
langfun/core/language_model.py
CHANGED
@@ -84,20 +84,23 @@ class LMSamplingUsage(pg.Object):
|
|
84
84
|
prompt_tokens: int
|
85
85
|
completion_tokens: int
|
86
86
|
total_tokens: int
|
87
|
+
num_requests: int = 1
|
87
88
|
|
88
89
|
def __add__(self, other: 'LMSamplingUsage') -> 'LMSamplingUsage':
|
89
90
|
return LMSamplingUsage(
|
90
91
|
prompt_tokens=self.prompt_tokens + other.prompt_tokens,
|
91
92
|
completion_tokens=self.completion_tokens + other.completion_tokens,
|
92
93
|
total_tokens=self.total_tokens + other.total_tokens,
|
94
|
+
num_requests=self.num_requests + other.num_requests,
|
93
95
|
)
|
94
96
|
|
95
97
|
|
96
98
|
class UsageNotAvailable(LMSamplingUsage):
|
97
99
|
"""Usage information not available."""
|
98
|
-
prompt_tokens: pg.typing.Int(0).freeze()
|
100
|
+
prompt_tokens: pg.typing.Int(0).freeze() # pytype: disable=invalid-annotation
|
99
101
|
completion_tokens: pg.typing.Int(0).freeze() # pytype: disable=invalid-annotation
|
100
102
|
total_tokens: pg.typing.Int(0).freeze() # pytype: disable=invalid-annotation
|
103
|
+
num_requests: pg.typing.Int(1).freeze() # pytype: disable=invalid-annotation
|
101
104
|
|
102
105
|
def __bool__(self) -> bool:
|
103
106
|
return False
|
@@ -726,7 +729,7 @@ class _UsageTracker:
|
|
726
729
|
def __init__(self, model_ids: set[str] | None):
|
727
730
|
self.model_ids = model_ids
|
728
731
|
self.usages = {
|
729
|
-
m: LMSamplingUsage(0, 0, 0) for m in model_ids
|
732
|
+
m: LMSamplingUsage(0, 0, 0, 0) for m in model_ids
|
730
733
|
} if model_ids else {}
|
731
734
|
|
732
735
|
def track(self, model_id: str, usage: LMSamplingUsage):
|
@@ -598,18 +598,18 @@ class LanguageModelTest(unittest.TestCase):
|
|
598
598
|
list(concurrent.concurrent_map(call_lm, ['hi', 'hello']))
|
599
599
|
|
600
600
|
self.assertEqual(usages2, {
|
601
|
-
'model2': lm_lib.LMSamplingUsage(100, 100, 200),
|
601
|
+
'model2': lm_lib.LMSamplingUsage(100, 100, 200, 1),
|
602
602
|
})
|
603
603
|
self.assertEqual(usages3, {
|
604
|
-
'model1': lm_lib.LMSamplingUsage(100 * 4, 100 * 4, 200 * 4),
|
604
|
+
'model1': lm_lib.LMSamplingUsage(100 * 4, 100 * 4, 200 * 4, 4),
|
605
605
|
})
|
606
606
|
self.assertEqual(usages4, {
|
607
|
-
'model1': lm_lib.LMSamplingUsage(100 * 4, 100 * 4, 200 * 4),
|
608
|
-
'model2': lm_lib.LMSamplingUsage(100, 100, 200),
|
607
|
+
'model1': lm_lib.LMSamplingUsage(100 * 4, 100 * 4, 200 * 4, 4),
|
608
|
+
'model2': lm_lib.LMSamplingUsage(100, 100, 200, 1),
|
609
609
|
})
|
610
610
|
self.assertEqual(usages1, {
|
611
|
-
'model1': lm_lib.LMSamplingUsage(100 * 5, 100 * 5, 200 * 5),
|
612
|
-
'model2': lm_lib.LMSamplingUsage(100, 100, 200),
|
611
|
+
'model1': lm_lib.LMSamplingUsage(100 * 5, 100 * 5, 200 * 5, 5),
|
612
|
+
'model2': lm_lib.LMSamplingUsage(100, 100, 200, 1),
|
613
613
|
})
|
614
614
|
|
615
615
|
|
langfun/core/llms/__init__.py
CHANGED
@@ -94,8 +94,10 @@ from langfun.core.llms.groq import GroqGemma7B_IT
|
|
94
94
|
|
95
95
|
from langfun.core.llms.vertexai import VertexAI
|
96
96
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5
|
97
|
+
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5_0514
|
97
98
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1_5_0409
|
98
99
|
from langfun.core.llms.vertexai import VertexAIGeminiFlash1_5
|
100
|
+
from langfun.core.llms.vertexai import VertexAIGeminiFlash1_5_0514
|
99
101
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1
|
100
102
|
from langfun.core.llms.vertexai import VertexAIGeminiPro1Vision
|
101
103
|
from langfun.core.llms.vertexai import VertexAIPalm2
|
langfun/core/llms/vertexai.py
CHANGED
@@ -24,6 +24,8 @@ import pyglove as pg
|
|
24
24
|
|
25
25
|
|
26
26
|
SUPPORTED_MODELS_AND_SETTINGS = {
|
27
|
+
'gemini-1.5-pro-001': pg.Dict(api='gemini', rpm=5),
|
28
|
+
'gemini-1.5-flash-001': pg.Dict(api='gemini', rpm=5),
|
27
29
|
'gemini-1.5-pro-preview-0514': pg.Dict(api='gemini', rpm=5),
|
28
30
|
'gemini-1.5-pro-preview-0409': pg.Dict(api='gemini', rpm=5),
|
29
31
|
'gemini-1.5-flash-preview-0514': pg.Dict(api='gemini', rpm=5),
|
@@ -330,12 +332,19 @@ _PDF = [
|
|
330
332
|
class VertexAIGeminiPro1_5(VertexAI): # pylint: disable=invalid-name
|
331
333
|
"""Vertex AI Gemini 1.5 Pro model."""
|
332
334
|
|
335
|
+
model = 'gemini-1.5-pro-001'
|
336
|
+
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
337
|
+
|
338
|
+
|
339
|
+
class VertexAIGeminiPro1_5_0514(VertexAI): # pylint: disable=invalid-name
|
340
|
+
"""Vertex AI Gemini 1.5 Pro preview model."""
|
341
|
+
|
333
342
|
model = 'gemini-1.5-pro-preview-0514'
|
334
343
|
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
335
344
|
|
336
345
|
|
337
346
|
class VertexAIGeminiPro1_5_0409(VertexAI): # pylint: disable=invalid-name
|
338
|
-
"""Vertex AI Gemini 1.5 Pro model."""
|
347
|
+
"""Vertex AI Gemini 1.5 Pro preview model."""
|
339
348
|
|
340
349
|
model = 'gemini-1.5-pro-preview-0409'
|
341
350
|
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
@@ -343,6 +352,12 @@ class VertexAIGeminiPro1_5_0409(VertexAI): # pylint: disable=invalid-name
|
|
343
352
|
|
344
353
|
class VertexAIGeminiFlash1_5(VertexAI): # pylint: disable=invalid-name
|
345
354
|
"""Vertex AI Gemini 1.5 Flash model."""
|
355
|
+
model = 'gemini-1.5-flash-001'
|
356
|
+
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
357
|
+
|
358
|
+
|
359
|
+
class VertexAIGeminiFlash1_5_0514(VertexAI): # pylint: disable=invalid-name
|
360
|
+
"""Vertex AI Gemini 1.5 Flash preview model."""
|
346
361
|
|
347
362
|
model = 'gemini-1.5-flash-preview-0514'
|
348
363
|
supported_modalities = _PDF + _IMAGE_TYPES + _AUDIO_TYPES + _VIDEO_TYPES
|
@@ -8,8 +8,8 @@ langfun/core/console.py,sha256=bk5rNPNm9rMGW5YT2HixxU04p2umnoabn5SDz6Dqe88,2317
|
|
8
8
|
langfun/core/console_test.py,sha256=5SYJdxpJGLgdSSQqqMPoA1X6jpsLD8rgcyk-EgI65oE,1077
|
9
9
|
langfun/core/langfunc.py,sha256=RvIcRjIq0jWYRu1xim-FYe4HSrt97r3GMBO_PuagUmw,11060
|
10
10
|
langfun/core/langfunc_test.py,sha256=lyt-UzkD8972cxZwzCkps0_RMLeSsOBrcUFIW-fB6us,8653
|
11
|
-
langfun/core/language_model.py,sha256=
|
12
|
-
langfun/core/language_model_test.py,sha256=
|
11
|
+
langfun/core/language_model.py,sha256=tHB2otsHx-EM4TaDNgXZ-qvnhJXNJKuK2-OdseQzGdI,23948
|
12
|
+
langfun/core/language_model_test.py,sha256=TlNmVUfBfDQZzIiiBqCBTrxgcoyj2qNp3kONvmr2pX4,21273
|
13
13
|
langfun/core/logging.py,sha256=FyZRxUy2TTF6tWLhQCRpCvfH55WGUdNgQjUTK_SQLnY,5320
|
14
14
|
langfun/core/logging_test.py,sha256=qvm3RObYP3knO2PnXR9evBRl4gH621GnjnwywbGbRfg,1833
|
15
15
|
langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
|
@@ -52,7 +52,7 @@ langfun/core/eval/patching.py,sha256=R0s2eAd1m97exQt06dmUL0V_MBG0W2Hxg7fhNB7cXW0
|
|
52
52
|
langfun/core/eval/patching_test.py,sha256=8kCd54Egjju22FMgtJuxEsrXkW8ifs-UUBHtrCG1L6w,4775
|
53
53
|
langfun/core/eval/scoring.py,sha256=1J7IATo-8FXUR0SBqk9icztHiM0lWkBFcWUo-vUURgQ,6376
|
54
54
|
langfun/core/eval/scoring_test.py,sha256=O8olHbrUEg60gMxwOkWzKBJZpZoUlmVnBANX5Se2SXM,4546
|
55
|
-
langfun/core/llms/__init__.py,sha256=
|
55
|
+
langfun/core/llms/__init__.py,sha256=3OA4uQczFEKHoIUcWDO3myesdeDISLUWJ8fjp6zjGww,4551
|
56
56
|
langfun/core/llms/anthropic.py,sha256=Gon3fOi31RhZFgNd0ijyTnKnUdp9hrWrCoSXyO4UaLw,7316
|
57
57
|
langfun/core/llms/anthropic_test.py,sha256=T-swuMkfnlgs8Fpif4rtXs579exGk0TsbLMirXDZCkg,5533
|
58
58
|
langfun/core/llms/fake.py,sha256=Dd7-6ka9pFf3fcWZyczamjOqQ91MOI-m7We3Oc9Ffmo,2927
|
@@ -67,7 +67,7 @@ langfun/core/llms/openai.py,sha256=0z9qIH9FlWj9VWUnhOX321T6JHO-vjY2IozT7OVI4GY,1
|
|
67
67
|
langfun/core/llms/openai_test.py,sha256=3muDTnW7UBOSHq694Fi2bofqhe8Pkj0Tl8IShoLCTOM,15525
|
68
68
|
langfun/core/llms/rest.py,sha256=laopuq-zD8V-3Y6eFDngftHEbE66VlUkCD2-rvvRaLU,3388
|
69
69
|
langfun/core/llms/rest_test.py,sha256=NZ3Nf0XQVpT9kLP5cBVo_yBHLI7vWTYhWQxYEJVMGs4,3472
|
70
|
-
langfun/core/llms/vertexai.py,sha256=
|
70
|
+
langfun/core/llms/vertexai.py,sha256=OH7z10FW5Xer08NZ7MGwSbXB3TcxwhNj3B5sZGnDq3I,11950
|
71
71
|
langfun/core/llms/vertexai_test.py,sha256=G18BG36h5KvmX2zutDTLjtYCRjTuP_nWIFm4FMnLnyY,7651
|
72
72
|
langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
|
73
73
|
langfun/core/llms/cache/base.py,sha256=cFfYvOIUae842pncqCAsRvqXCk2AnAsRYVx0mcIoAeY,3338
|
@@ -117,8 +117,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
117
117
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
118
118
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
119
119
|
langfun/core/templates/selfplay_test.py,sha256=rBW2Qr8yi-aWYwoTwRR-n1peKyMX9QXPZXURjLgoiRs,2264
|
120
|
-
langfun-0.0.2.
|
121
|
-
langfun-0.0.2.
|
122
|
-
langfun-0.0.2.
|
123
|
-
langfun-0.0.2.
|
124
|
-
langfun-0.0.2.
|
120
|
+
langfun-0.0.2.dev20240629.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
121
|
+
langfun-0.0.2.dev20240629.dist-info/METADATA,sha256=a8CBmosl7t2AvpjeT4rU_dt8hi05PNgiLc9302UzzhY,3550
|
122
|
+
langfun-0.0.2.dev20240629.dist-info/WHEEL,sha256=mguMlWGMX-VHnMpKOjjQidIo1ssRlCFu4a4mBpz1s2M,91
|
123
|
+
langfun-0.0.2.dev20240629.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
124
|
+
langfun-0.0.2.dev20240629.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|