langfun 0.1.2.dev202502050804__py3-none-any.whl → 0.1.2.dev202502060804__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/__init__.py +0 -2
- langfun/core/llms/__init__.py +6 -0
- langfun/core/llms/gemini.py +64 -0
- langfun/core/llms/google_genai.py +23 -1
- langfun/core/llms/rest.py +7 -1
- langfun/core/llms/vertexai.py +27 -7
- langfun/core/modalities/mime.py +3 -5
- {langfun-0.1.2.dev202502050804.dist-info → langfun-0.1.2.dev202502060804.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202502050804.dist-info → langfun-0.1.2.dev202502060804.dist-info}/RECORD +12 -12
- {langfun-0.1.2.dev202502050804.dist-info → langfun-0.1.2.dev202502060804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202502050804.dist-info → langfun-0.1.2.dev202502060804.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202502050804.dist-info → langfun-0.1.2.dev202502060804.dist-info}/top_level.txt +0 -0
langfun/core/__init__.py
CHANGED
@@ -121,8 +121,6 @@ from langfun.core import console
|
|
121
121
|
# Utility for event logging.
|
122
122
|
from langfun.core import logging
|
123
123
|
|
124
|
-
# Import internal modules.
|
125
|
-
|
126
124
|
# pylint: enable=g-import-not-at-top
|
127
125
|
# pylint: enable=g-importing-member
|
128
126
|
# pylint: enable=g-bad-import-order
|
langfun/core/llms/__init__.py
CHANGED
@@ -39,6 +39,9 @@ from langfun.core.llms.groq import Groq
|
|
39
39
|
|
40
40
|
# Gemini models.
|
41
41
|
from langfun.core.llms.google_genai import GenAI
|
42
|
+
from langfun.core.llms.google_genai import Gemini2Flash
|
43
|
+
from langfun.core.llms.google_genai import Gemini2ProExp_20250205
|
44
|
+
from langfun.core.llms.google_genai import Gemini2FlashThinkingExp_20250121
|
42
45
|
from langfun.core.llms.google_genai import GeminiFlash2_0ThinkingExp_20241219
|
43
46
|
from langfun.core.llms.google_genai import GeminiFlash2_0Exp
|
44
47
|
from langfun.core.llms.google_genai import GeminiExp_20241206
|
@@ -52,6 +55,9 @@ from langfun.core.llms.google_genai import GeminiFlash1_5_001
|
|
52
55
|
from langfun.core.llms.google_genai import GeminiPro1
|
53
56
|
|
54
57
|
from langfun.core.llms.vertexai import VertexAIGemini
|
58
|
+
from langfun.core.llms.vertexai import VertexAIGemini2Flash
|
59
|
+
from langfun.core.llms.vertexai import VertexAIGemini2ProExp_20250205
|
60
|
+
from langfun.core.llms.vertexai import VertexAIGemini2FlashThinkingExp_20250121
|
55
61
|
from langfun.core.llms.vertexai import VertexAIGeminiFlash2_0ThinkingExp_20241219
|
56
62
|
from langfun.core.llms.vertexai import VertexAIGeminiFlash2_0Exp
|
57
63
|
from langfun.core.llms.vertexai import VertexAIGeminiExp_20241206
|
langfun/core/llms/gemini.py
CHANGED
@@ -85,6 +85,70 @@ SUPPORTED_MODELS_AND_SETTINGS = {
|
|
85
85
|
# NOTE: Please update google_genai.py, vertexai.py, __init__.py when
|
86
86
|
# adding new models.
|
87
87
|
# !!! PLEASE KEEP MODELS SORTED BY RELEASE DATE !!!
|
88
|
+
'gemini-2.0-flash-001': pg.Dict(
|
89
|
+
latest_update='2025-02-05',
|
90
|
+
experimental=True,
|
91
|
+
in_service=True,
|
92
|
+
supported_modalities=ALL_MODALITIES,
|
93
|
+
rpm_free=2000,
|
94
|
+
tpm_free=40_000_000,
|
95
|
+
rpm_paid=0,
|
96
|
+
tpm_paid=0,
|
97
|
+
cost_per_1m_input_tokens_up_to_128k=0,
|
98
|
+
cost_per_1m_output_tokens_up_to_128k=0,
|
99
|
+
cost_per_1m_cached_tokens_up_to_128k=0,
|
100
|
+
cost_per_1m_input_tokens_longer_than_128k=0,
|
101
|
+
cost_per_1m_output_tokens_longer_than_128k=0,
|
102
|
+
cost_per_1m_cached_tokens_longer_than_128k=0,
|
103
|
+
),
|
104
|
+
'gemini-2.0-flash': pg.Dict(
|
105
|
+
latest_update='2025-02-05',
|
106
|
+
experimental=True,
|
107
|
+
in_service=True,
|
108
|
+
supported_modalities=ALL_MODALITIES,
|
109
|
+
rpm_free=2000,
|
110
|
+
tpm_free=40_000_000,
|
111
|
+
rpm_paid=0,
|
112
|
+
tpm_paid=0,
|
113
|
+
cost_per_1m_input_tokens_up_to_128k=0,
|
114
|
+
cost_per_1m_output_tokens_up_to_128k=0,
|
115
|
+
cost_per_1m_cached_tokens_up_to_128k=0,
|
116
|
+
cost_per_1m_input_tokens_longer_than_128k=0,
|
117
|
+
cost_per_1m_output_tokens_longer_than_128k=0,
|
118
|
+
cost_per_1m_cached_tokens_longer_than_128k=0,
|
119
|
+
),
|
120
|
+
'gemini-2.0-pro-exp-02-05': pg.Dict(
|
121
|
+
latest_update='2025-02-05',
|
122
|
+
experimental=True,
|
123
|
+
in_service=True,
|
124
|
+
supported_modalities=ALL_MODALITIES,
|
125
|
+
rpm_free=1000,
|
126
|
+
tpm_free=40_000_000,
|
127
|
+
rpm_paid=0,
|
128
|
+
tpm_paid=0,
|
129
|
+
cost_per_1m_input_tokens_up_to_128k=0,
|
130
|
+
cost_per_1m_output_tokens_up_to_128k=0,
|
131
|
+
cost_per_1m_cached_tokens_up_to_128k=0,
|
132
|
+
cost_per_1m_input_tokens_longer_than_128k=0,
|
133
|
+
cost_per_1m_output_tokens_longer_than_128k=0,
|
134
|
+
cost_per_1m_cached_tokens_longer_than_128k=0,
|
135
|
+
),
|
136
|
+
'gemini-2.0-flash-thinking-exp-01-21': pg.Dict(
|
137
|
+
latest_update='2024-01-21',
|
138
|
+
experimental=True,
|
139
|
+
in_service=True,
|
140
|
+
supported_modalities=ALL_MODALITIES,
|
141
|
+
rpm_free=10,
|
142
|
+
tpm_free=40_000_000,
|
143
|
+
rpm_paid=0,
|
144
|
+
tpm_paid=0,
|
145
|
+
cost_per_1m_input_tokens_up_to_128k=0,
|
146
|
+
cost_per_1m_output_tokens_up_to_128k=0,
|
147
|
+
cost_per_1m_cached_tokens_up_to_128k=0,
|
148
|
+
cost_per_1m_input_tokens_longer_than_128k=0,
|
149
|
+
cost_per_1m_output_tokens_longer_than_128k=0,
|
150
|
+
cost_per_1m_cached_tokens_longer_than_128k=0,
|
151
|
+
),
|
88
152
|
'gemini-2.0-flash-thinking-exp-1219': pg.Dict(
|
89
153
|
latest_update='2024-12-19',
|
90
154
|
experimental=True,
|
@@ -63,10 +63,32 @@ class GenAI(gemini.Gemini):
|
|
63
63
|
)
|
64
64
|
|
65
65
|
|
66
|
+
class Gemini2Flash(GenAI): # pylint: disable=invalid-name
|
67
|
+
"""Gemini Flash 2.0 model launched on 02/05/2025."""
|
68
|
+
|
69
|
+
api_version = 'v1beta'
|
70
|
+
model = 'gemini-2.0-flash'
|
71
|
+
|
72
|
+
|
73
|
+
class Gemini2ProExp_20250205(GenAI): # pylint: disable=invalid-name
|
74
|
+
"""Gemini Flash 2.0 Pro model launched on 02/05/2025."""
|
75
|
+
|
76
|
+
api_version = 'v1beta'
|
77
|
+
model = 'gemini-2.0-pro-exp-02-05'
|
78
|
+
|
79
|
+
|
80
|
+
class Gemini2FlashThinkingExp_20250121(GenAI): # pylint: disable=invalid-name
|
81
|
+
"""Gemini Flash 2.0 Thinking model launched on 01/21/2025."""
|
82
|
+
|
83
|
+
api_version = 'v1beta'
|
84
|
+
model = 'gemini-2.0-flash-thinking-exp-01-21'
|
85
|
+
timeout = None
|
86
|
+
|
87
|
+
|
66
88
|
class GeminiFlash2_0ThinkingExp_20241219(GenAI): # pylint: disable=invalid-name
|
67
89
|
"""Gemini Flash 2.0 Thinking model launched on 12/19/2024."""
|
68
90
|
|
69
|
-
api_version = '
|
91
|
+
api_version = 'v1beta'
|
70
92
|
model = 'gemini-2.0-flash-thinking-exp-1219'
|
71
93
|
timeout = None
|
72
94
|
|
langfun/core/llms/rest.py
CHANGED
@@ -17,6 +17,7 @@ import functools
|
|
17
17
|
from typing import Annotated, Any, Callable
|
18
18
|
|
19
19
|
import langfun.core as lf
|
20
|
+
# Placeholder for Google-internal internet access import.
|
20
21
|
import requests
|
21
22
|
|
22
23
|
|
@@ -65,10 +66,15 @@ class REST(lf.LanguageModel):
|
|
65
66
|
@functools.cached_property
|
66
67
|
def _session(self) -> requests.Session:
|
67
68
|
assert self._api_initialized
|
68
|
-
s =
|
69
|
+
s = self._create_session()
|
70
|
+
# Placeholder for Google-internal session adapter.
|
69
71
|
s.headers.update(self.headers or {})
|
70
72
|
return s
|
71
73
|
|
74
|
+
def _create_session(self) -> requests.Session:
|
75
|
+
"""Creates a new session."""
|
76
|
+
return requests.Session()
|
77
|
+
|
72
78
|
def _on_bound(self):
|
73
79
|
super()._on_bound()
|
74
80
|
self.__dict__.pop('_session', None)
|
langfun/core/llms/vertexai.py
CHANGED
@@ -13,7 +13,6 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
"""Vertex AI generative models."""
|
15
15
|
|
16
|
-
import functools
|
17
16
|
import os
|
18
17
|
from typing import Annotated, Any, Literal
|
19
18
|
|
@@ -119,14 +118,10 @@ class VertexAI(rest.REST):
|
|
119
118
|
"""Returns a string to identify the model."""
|
120
119
|
return f'VertexAI({self.model})'
|
121
120
|
|
122
|
-
|
123
|
-
def _session(self):
|
124
|
-
assert self._api_initialized
|
121
|
+
def _create_session(self):
|
125
122
|
assert self._credentials is not None
|
126
123
|
assert auth_requests is not None
|
127
|
-
|
128
|
-
s.headers.update(self.headers or {})
|
129
|
-
return s
|
124
|
+
return auth_requests.AuthorizedSession(self._credentials)
|
130
125
|
|
131
126
|
|
132
127
|
#
|
@@ -149,6 +144,31 @@ class VertexAIGemini(VertexAI, gemini.Gemini):
|
|
149
144
|
)
|
150
145
|
|
151
146
|
|
147
|
+
class VertexAIGemini2Flash(VertexAIGemini): # pylint: disable=invalid-name
|
148
|
+
"""Gemini Flash 2.0 model launched on 02/05/2025."""
|
149
|
+
|
150
|
+
api_version = 'v1beta'
|
151
|
+
model = 'gemini-2.0-flash-001'
|
152
|
+
location = 'us-central1'
|
153
|
+
|
154
|
+
|
155
|
+
class VertexAIGemini2ProExp_20250205(VertexAIGemini): # pylint: disable=invalid-name
|
156
|
+
"""Gemini Flash 2.0 Pro model launched on 02/05/2025."""
|
157
|
+
|
158
|
+
api_version = 'v1beta'
|
159
|
+
model = 'gemini-2.0-pro-exp-02-05'
|
160
|
+
location = 'us-central1'
|
161
|
+
|
162
|
+
|
163
|
+
class VertexAIGemini2FlashThinkingExp_20250121(VertexAIGemini): # pylint: disable=invalid-name
|
164
|
+
"""Gemini Flash 2.0 Thinking model launched on 01/21/2025."""
|
165
|
+
|
166
|
+
api_version = 'v1beta'
|
167
|
+
model = 'gemini-2.0-flash-thinking-exp-01-21'
|
168
|
+
timeout = None
|
169
|
+
location = 'us-central1'
|
170
|
+
|
171
|
+
|
152
172
|
class VertexAIGeminiFlash2_0ThinkingExp_20241219(VertexAIGemini): # pylint: disable=invalid-name
|
153
173
|
"""Vertex AI Gemini Flash 2.0 Thinking model launched on 12/19/2024."""
|
154
174
|
|
langfun/core/modalities/mime.py
CHANGED
@@ -17,8 +17,9 @@ import base64
|
|
17
17
|
import functools
|
18
18
|
from typing import Annotated, Any, Iterable, Type, Union
|
19
19
|
import langfun.core as lf
|
20
|
+
# Placeholder for Google-internal internet access import.
|
20
21
|
import pyglove as pg
|
21
|
-
import requests
|
22
|
+
import requests # pylint: disable=unused-import
|
22
23
|
|
23
24
|
|
24
25
|
try:
|
@@ -177,10 +178,7 @@ class Mime(lf.Modality):
|
|
177
178
|
def download(cls, uri: str) -> bytes | str:
|
178
179
|
"""Downloads the content of the given URI."""
|
179
180
|
if uri.lower().startswith(('http:', 'https:', 'ftp:')):
|
180
|
-
return requests.get(
|
181
|
-
uri,
|
182
|
-
headers={'User-Agent': 'Mozilla/5.0'},
|
183
|
-
).content
|
181
|
+
return requests.get(uri, headers={'User-Agent': 'Mozilla/5.0'}).content
|
184
182
|
else:
|
185
183
|
content = pg.io.readfile(uri, mode='rb')
|
186
184
|
assert content is not None
|
@@ -1,5 +1,5 @@
|
|
1
1
|
langfun/__init__.py,sha256=fhfPXpHN7GoGqixpFfqhQkYxFs_siP_LhbjZhd3lhio,2497
|
2
|
-
langfun/core/__init__.py,sha256=
|
2
|
+
langfun/core/__init__.py,sha256=HOV4RFypDBmQhXouUA2UEassOuYTol0und3EtSa3D5c,4543
|
3
3
|
langfun/core/component.py,sha256=g1kQM0bryYYYWVDrSMnHfc74wIBbpfe5_B3s-UIP5GE,3028
|
4
4
|
langfun/core/component_test.py,sha256=0CxTgjAud3aj8wBauFhG2FHDqrxCTl4OI4gzQTad-40,9254
|
5
5
|
langfun/core/concurrent.py,sha256=zY-pXqlGqss_GI20tM1gXvyW8QepVPUuFNmutcIdhbI,32760
|
@@ -73,7 +73,7 @@ langfun/core/eval/v2/reporting.py,sha256=7rL9LLmGYnQ5HIjqRqsOMkUlBl4BmFPEL6Vlofq
|
|
73
73
|
langfun/core/eval/v2/reporting_test.py,sha256=UmYSAQvD3AIXsSyWQ-WD2uLtEISYpmBeoKY5u5Qwc8E,5696
|
74
74
|
langfun/core/eval/v2/runners.py,sha256=DKEmSlGXjOXKWFdBhTpLy7tMsBHZHd1Brl3hWIngsSQ,15931
|
75
75
|
langfun/core/eval/v2/runners_test.py,sha256=A37fKK2MvAVTiShsg_laluJzJ9AuAQn52k7HPbfD0Ks,11666
|
76
|
-
langfun/core/llms/__init__.py,sha256=
|
76
|
+
langfun/core/llms/__init__.py,sha256=qoFPJhueF6tuZSfi5QyiXXDhFSqrHQxid1bjb9dJm3Y,8178
|
77
77
|
langfun/core/llms/anthropic.py,sha256=z_DWDpR1VKNzv6wq-9CXLzWdqCDXRKuVFacJNpgBqAs,10826
|
78
78
|
langfun/core/llms/anthropic_test.py,sha256=zZ2eSP8hhVv-RDSWxT7wX-NS5DfGfQmCjS9P0pusAHM,6556
|
79
79
|
langfun/core/llms/compositional.py,sha256=csW_FLlgL-tpeyCOTVvfUQkMa_zCN5Y2I-YbSNuK27U,2872
|
@@ -82,9 +82,9 @@ langfun/core/llms/deepseek.py,sha256=9EbuNrngd5BwpsvsEfkW2XQdq3K23S3-jlI8RbMNZF4
|
|
82
82
|
langfun/core/llms/deepseek_test.py,sha256=dS72i52bwMpCN4dJDvpJI59AnNChpwxS5eYYFrhGh90,1843
|
83
83
|
langfun/core/llms/fake.py,sha256=gCHBYBLvBCsC78HI1hpoqXCS-p1FMTgY1P1qh_sGBPk,3070
|
84
84
|
langfun/core/llms/fake_test.py,sha256=2h13qkwEz_JR0mtUDPxdAhQo7MueXaFSwsD2DIRDW9g,7653
|
85
|
-
langfun/core/llms/gemini.py,sha256=
|
85
|
+
langfun/core/llms/gemini.py,sha256=oYcpQ3I7-c1MeSC7mj9iKtAZTdbWKI9Fzp84drvR5QY,19703
|
86
86
|
langfun/core/llms/gemini_test.py,sha256=2ERhYWCJwnfDTQbCaZHFuB1TdWJFrOBS7yyCBInIdQk,6129
|
87
|
-
langfun/core/llms/google_genai.py,sha256=
|
87
|
+
langfun/core/llms/google_genai.py,sha256=WbVZAIDhh7mKy15LZMXOEniQ8Obd-hjiy2KviUCfmXQ,4261
|
88
88
|
langfun/core/llms/google_genai_test.py,sha256=JZf_cbQ4GGGpwiQCLjFJn7V4jxBBqgZhIx91AzbGKVo,1250
|
89
89
|
langfun/core/llms/groq.py,sha256=oGxyyCi5TtMVu2POdO8pXS7pK4Es56FtqjghZIGYopc,7579
|
90
90
|
langfun/core/llms/groq_test.py,sha256=9aOD3nO4dEoH57B-5iOr5DQjG0vyv1jzFtAe7HfoiNg,1963
|
@@ -94,9 +94,9 @@ langfun/core/llms/openai.py,sha256=bIJae2UDO_uwoZGZRYP58GM4FdP4w9qjQhBIYJyGH34,1
|
|
94
94
|
langfun/core/llms/openai_compatible.py,sha256=MF9JCc0uTPkIK95uvQTMIBXk4z_xKQMZqQHFaVmXwcA,5898
|
95
95
|
langfun/core/llms/openai_compatible_test.py,sha256=0uFYhCiuHo2Wrlgj16-GRG6rW8P6EaHCUguL3jS0QJ8,16708
|
96
96
|
langfun/core/llms/openai_test.py,sha256=m85YjGCvWvV5ZYagjC0FqI0FcqyCEVCbUUs8Wm3iUrc,2475
|
97
|
-
langfun/core/llms/rest.py,sha256=
|
97
|
+
langfun/core/llms/rest.py,sha256=2N-zg9wuB-XeQvISc-xWOBCfBVvjMc4p3LO_rD23z7c,3818
|
98
98
|
langfun/core/llms/rest_test.py,sha256=zWGiI08f9gXsoQPJS9TlX1zD2uQLrJUB-1VpAJXRHfs,3475
|
99
|
-
langfun/core/llms/vertexai.py,sha256=
|
99
|
+
langfun/core/llms/vertexai.py,sha256=zLiHHrm5gpE6DgC5k0cxugD2qui9MF8bhg-4aJDXB24,16364
|
100
100
|
langfun/core/llms/vertexai_test.py,sha256=6eLQOyeL5iGZOIWb39sFcf1TgYD_6TBGYdMO4UIvhf4,3333
|
101
101
|
langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
|
102
102
|
langfun/core/llms/cache/base.py,sha256=rt3zwmyw0y9jsSGW-ZbV1vAfLxQ7_3AVk0l2EySlse4,3918
|
@@ -110,7 +110,7 @@ langfun/core/modalities/audio.py,sha256=qCrVCX690SG0ps-ZfOtNWvHn_CmdJsmxF7GySScW
|
|
110
110
|
langfun/core/modalities/audio_test.py,sha256=yyGEBYqMXmNs_F2dEtj-PX8HE040vqh-YQppsvdxPw4,2025
|
111
111
|
langfun/core/modalities/image.py,sha256=ovcX8NLBNv8WzxAdhQ-u4VQfHVBkWijRj_oiNwhE9lk,1768
|
112
112
|
langfun/core/modalities/image_test.py,sha256=XMgtJXY75R5eo0CZ222D1QUy57_hESnttmCGWwDLt7k,3824
|
113
|
-
langfun/core/modalities/mime.py,sha256=
|
113
|
+
langfun/core/modalities/mime.py,sha256=T00qHntL3uewF_DBVA-sJiV9mPK6bLAuBsg0bWSYKUQ,7919
|
114
114
|
langfun/core/modalities/mime_test.py,sha256=Lg21nKFi--a884gnI7tFS4cHnwByEEhWg4Ugsr-UCbw,5277
|
115
115
|
langfun/core/modalities/ms_office.py,sha256=0PnM6W9SovVfJNd4XCpUfOcGBuvj4hlA1zqPjdsJNFM,3725
|
116
116
|
langfun/core/modalities/ms_office_test.py,sha256=rrDBx51ELAqRaUX6Y6tgg0k3tEFHOlRMfUpeULD7mlo,87868
|
@@ -148,8 +148,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
148
148
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
149
149
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
150
150
|
langfun/core/templates/selfplay_test.py,sha256=Ot__1P1M8oJfoTp-M9-PQ6HUXqZKyMwvZ5f7yQ3yfyM,2326
|
151
|
-
langfun-0.1.2.
|
152
|
-
langfun-0.1.2.
|
153
|
-
langfun-0.1.2.
|
154
|
-
langfun-0.1.2.
|
155
|
-
langfun-0.1.2.
|
151
|
+
langfun-0.1.2.dev202502060804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
152
|
+
langfun-0.1.2.dev202502060804.dist-info/METADATA,sha256=tw5p6p7Pp2I6CbNWAJx1EcB-umB-X10YeiJnw8LS65o,8172
|
153
|
+
langfun-0.1.2.dev202502060804.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
154
|
+
langfun-0.1.2.dev202502060804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
155
|
+
langfun-0.1.2.dev202502060804.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{langfun-0.1.2.dev202502050804.dist-info → langfun-0.1.2.dev202502060804.dist-info}/top_level.txt
RENAMED
File without changes
|