langfun 0.1.2.dev202502060804__py3-none-any.whl → 0.1.2.dev202502070804__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/llms/gemini.py +16 -16
- langfun/core/llms/rest.py +11 -10
- langfun/core/llms/vertexai.py +1 -1
- langfun/core/llms/vertexai_test.py +1 -1
- {langfun-0.1.2.dev202502060804.dist-info → langfun-0.1.2.dev202502070804.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202502060804.dist-info → langfun-0.1.2.dev202502070804.dist-info}/RECORD +9 -9
- {langfun-0.1.2.dev202502060804.dist-info → langfun-0.1.2.dev202502070804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202502060804.dist-info → langfun-0.1.2.dev202502070804.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202502060804.dist-info → langfun-0.1.2.dev202502070804.dist-info}/top_level.txt +0 -0
langfun/core/llms/gemini.py
CHANGED
@@ -90,7 +90,7 @@ SUPPORTED_MODELS_AND_SETTINGS = {
|
|
90
90
|
experimental=True,
|
91
91
|
in_service=True,
|
92
92
|
supported_modalities=ALL_MODALITIES,
|
93
|
-
rpm_free=
|
93
|
+
rpm_free=10_000,
|
94
94
|
tpm_free=40_000_000,
|
95
95
|
rpm_paid=0,
|
96
96
|
tpm_paid=0,
|
@@ -106,32 +106,32 @@ SUPPORTED_MODELS_AND_SETTINGS = {
|
|
106
106
|
experimental=True,
|
107
107
|
in_service=True,
|
108
108
|
supported_modalities=ALL_MODALITIES,
|
109
|
-
rpm_free=
|
109
|
+
rpm_free=10_000,
|
110
110
|
tpm_free=40_000_000,
|
111
111
|
rpm_paid=0,
|
112
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,
|
113
|
+
cost_per_1m_input_tokens_up_to_128k=0.1,
|
114
|
+
cost_per_1m_output_tokens_up_to_128k=0.4,
|
115
|
+
cost_per_1m_cached_tokens_up_to_128k=0.025,
|
116
|
+
cost_per_1m_input_tokens_longer_than_128k=0.1,
|
117
|
+
cost_per_1m_output_tokens_longer_than_128k=0.4,
|
118
|
+
cost_per_1m_cached_tokens_longer_than_128k=0.025,
|
119
119
|
),
|
120
120
|
'gemini-2.0-pro-exp-02-05': pg.Dict(
|
121
121
|
latest_update='2025-02-05',
|
122
122
|
experimental=True,
|
123
123
|
in_service=True,
|
124
124
|
supported_modalities=ALL_MODALITIES,
|
125
|
-
rpm_free=
|
126
|
-
tpm_free=
|
125
|
+
rpm_free=10,
|
126
|
+
tpm_free=4_000_000,
|
127
127
|
rpm_paid=0,
|
128
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,
|
129
|
+
cost_per_1m_input_tokens_up_to_128k=0.1,
|
130
|
+
cost_per_1m_output_tokens_up_to_128k=0.4,
|
131
|
+
cost_per_1m_cached_tokens_up_to_128k=0.025,
|
132
|
+
cost_per_1m_input_tokens_longer_than_128k=0.1,
|
133
|
+
cost_per_1m_output_tokens_longer_than_128k=0.4,
|
134
|
+
cost_per_1m_cached_tokens_longer_than_128k=0.025,
|
135
135
|
),
|
136
136
|
'gemini-2.0-flash-thinking-exp-01-21': pg.Dict(
|
137
137
|
latest_update='2024-01-21',
|
langfun/core/llms/rest.py
CHANGED
@@ -63,15 +63,14 @@ class REST(lf.LanguageModel):
|
|
63
63
|
def _initialize(self) -> None:
|
64
64
|
"""Initializes the API. Subclasses can override."""
|
65
65
|
|
66
|
-
|
67
|
-
def _session(self) -> requests.Session:
|
66
|
+
def session(self) -> requests.Session:
|
68
67
|
assert self._api_initialized
|
69
|
-
s = self.
|
68
|
+
s = self._session()
|
70
69
|
# Placeholder for Google-internal session adapter.
|
71
70
|
s.headers.update(self.headers or {})
|
72
71
|
return s
|
73
72
|
|
74
|
-
def
|
73
|
+
def _session(self) -> requests.Session:
|
75
74
|
"""Creates a new session."""
|
76
75
|
return requests.Session()
|
77
76
|
|
@@ -88,12 +87,14 @@ class REST(lf.LanguageModel):
|
|
88
87
|
|
89
88
|
def _sample_single(self, prompt: lf.Message) -> lf.LMSamplingResult:
|
90
89
|
try:
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
90
|
+
with self.session() as session:
|
91
|
+
return self._parse_response(
|
92
|
+
session.post(
|
93
|
+
self.api_endpoint,
|
94
|
+
json=self.request(prompt, self.sampling_options),
|
95
|
+
timeout=self.timeout,
|
96
|
+
)
|
97
|
+
)
|
97
98
|
except (requests.exceptions.ReadTimeout,
|
98
99
|
requests.exceptions.ConnectTimeout) as e:
|
99
100
|
raise lf.TemporaryLMError(str(e)) from e
|
langfun/core/llms/vertexai.py
CHANGED
@@ -118,7 +118,7 @@ class VertexAI(rest.REST):
|
|
118
118
|
"""Returns a string to identify the model."""
|
119
119
|
return f'VertexAI({self.model})'
|
120
120
|
|
121
|
-
def
|
121
|
+
def _session(self):
|
122
122
|
assert self._credentials is not None
|
123
123
|
assert auth_requests is not None
|
124
124
|
return auth_requests.AuthorizedSession(self._credentials)
|
@@ -45,7 +45,7 @@ class VertexAITest(unittest.TestCase):
|
|
45
45
|
self.assertTrue(model.model_id.startswith('VertexAI('))
|
46
46
|
self.assertIn('us-central1', model.api_endpoint)
|
47
47
|
self.assertTrue(model._api_initialized)
|
48
|
-
self.assertIsNotNone(model.
|
48
|
+
self.assertIsNotNone(model.session())
|
49
49
|
del os.environ['VERTEXAI_PROJECT']
|
50
50
|
del os.environ['VERTEXAI_LOCATION']
|
51
51
|
|
@@ -82,7 +82,7 @@ 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=jSwj9TQMDHkByr09hftq3CQozifjqwPwHfn-A64MIBg,19736
|
86
86
|
langfun/core/llms/gemini_test.py,sha256=2ERhYWCJwnfDTQbCaZHFuB1TdWJFrOBS7yyCBInIdQk,6129
|
87
87
|
langfun/core/llms/google_genai.py,sha256=WbVZAIDhh7mKy15LZMXOEniQ8Obd-hjiy2KviUCfmXQ,4261
|
88
88
|
langfun/core/llms/google_genai_test.py,sha256=JZf_cbQ4GGGpwiQCLjFJn7V4jxBBqgZhIx91AzbGKVo,1250
|
@@ -94,10 +94,10 @@ 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=46aGJghpQunwc3ju47V0N-1a1X4DydhwRBtRP9LBH2E,3828
|
98
98
|
langfun/core/llms/rest_test.py,sha256=zWGiI08f9gXsoQPJS9TlX1zD2uQLrJUB-1VpAJXRHfs,3475
|
99
|
-
langfun/core/llms/vertexai.py,sha256=
|
100
|
-
langfun/core/llms/vertexai_test.py,sha256=
|
99
|
+
langfun/core/llms/vertexai.py,sha256=9wm-_DVyqNNLeXnBOYxBa5dYNRMJpUO3QAy4PtFKZkE,16357
|
100
|
+
langfun/core/llms/vertexai_test.py,sha256=9LYv2equht9Vq-kwzdSZerENZjV9LYb4IIplSnfV5Os,3334
|
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
|
103
103
|
langfun/core/llms/cache/in_memory.py,sha256=i58oiQL28RDsq37dwqgVpC2mBETJjIEFS20yHiV5MKU,5185
|
@@ -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.dev202502070804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
152
|
+
langfun-0.1.2.dev202502070804.dist-info/METADATA,sha256=bwuoRNl9nFUbJY90atlLCDzIs7zJJnO5UXmRrTNQp1U,8172
|
153
|
+
langfun-0.1.2.dev202502070804.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
154
|
+
langfun-0.1.2.dev202502070804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
155
|
+
langfun-0.1.2.dev202502070804.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{langfun-0.1.2.dev202502060804.dist-info → langfun-0.1.2.dev202502070804.dist-info}/top_level.txt
RENAMED
File without changes
|