langfun 0.0.2.dev20240419__py3-none-any.whl → 0.0.2.dev20240420__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/__init__.py +6 -2
- langfun/core/llms/anthropic.py +22 -3
- langfun/core/llms/openai.py +33 -13
- langfun/core/llms/openai_test.py +13 -11
- {langfun-0.0.2.dev20240419.dist-info → langfun-0.0.2.dev20240420.dist-info}/METADATA +1 -1
- {langfun-0.0.2.dev20240419.dist-info → langfun-0.0.2.dev20240420.dist-info}/RECORD +9 -9
- {langfun-0.0.2.dev20240419.dist-info → langfun-0.0.2.dev20240420.dist-info}/LICENSE +0 -0
- {langfun-0.0.2.dev20240419.dist-info → langfun-0.0.2.dev20240420.dist-info}/WHEEL +0 -0
- {langfun-0.0.2.dev20240419.dist-info → langfun-0.0.2.dev20240420.dist-info}/top_level.txt +0 -0
langfun/core/llms/__init__.py
CHANGED
@@ -35,8 +35,12 @@ from langfun.core.llms.google_genai import Palm2_IT
|
|
35
35
|
from langfun.core.llms.openai import OpenAI
|
36
36
|
|
37
37
|
from langfun.core.llms.openai import Gpt4Turbo
|
38
|
-
from langfun.core.llms.openai import
|
39
|
-
from langfun.core.llms.openai import
|
38
|
+
from langfun.core.llms.openai import Gpt4Turbo_20240409
|
39
|
+
from langfun.core.llms.openai import Gpt4TurboPreview
|
40
|
+
from langfun.core.llms.openai import Gpt4TurboPreview_0125
|
41
|
+
from langfun.core.llms.openai import Gpt4TurboPreview_1106
|
42
|
+
from langfun.core.llms.openai import Gpt4VisionPreview
|
43
|
+
from langfun.core.llms.openai import Gpt4VisionPreview_1106
|
40
44
|
from langfun.core.llms.openai import Gpt4
|
41
45
|
from langfun.core.llms.openai import Gpt4_0613
|
42
46
|
from langfun.core.llms.openai import Gpt4_32K
|
langfun/core/llms/anthropic.py
CHANGED
@@ -26,9 +26,12 @@ import requests
|
|
26
26
|
|
27
27
|
SUPPORTED_MODELS_AND_SETTINGS = {
|
28
28
|
# See https://docs.anthropic.com/claude/docs/models-overview
|
29
|
-
'claude-3-opus-20240229': pg.Dict(max_tokens=4096, max_concurrency=
|
30
|
-
'claude-3-sonnet-20240229': pg.Dict(max_tokens=4096, max_concurrency=
|
29
|
+
'claude-3-opus-20240229': pg.Dict(max_tokens=4096, max_concurrency=16),
|
30
|
+
'claude-3-sonnet-20240229': pg.Dict(max_tokens=4096, max_concurrency=16),
|
31
31
|
'claude-3-haiku-20240307': pg.Dict(max_tokens=4096, max_concurrency=16),
|
32
|
+
'claude-2.1': pg.Dict(max_tokens=4096, max_concurrency=16),
|
33
|
+
'claude-2.0': pg.Dict(max_tokens=4096, max_concurrency=16),
|
34
|
+
'claude-instant-1.2': pg.Dict(max_tokens=4096, max_concurrency=16),
|
32
35
|
}
|
33
36
|
|
34
37
|
|
@@ -55,7 +58,7 @@ class Anthropic(lf.LanguageModel):
|
|
55
58
|
See https://docs.anthropic.com/claude/reference/messages_post
|
56
59
|
"""
|
57
60
|
|
58
|
-
model: Annotated[
|
61
|
+
model: pg.typing.Annotated[
|
59
62
|
pg.typing.Enum(
|
60
63
|
pg.MISSING_VALUE, list(SUPPORTED_MODELS_AND_SETTINGS.keys())
|
61
64
|
),
|
@@ -210,6 +213,7 @@ class Anthropic(lf.LanguageModel):
|
|
210
213
|
|
211
214
|
class Claude3(Anthropic):
|
212
215
|
"""Base class for Claude 3 models. 200K input tokens and 4K output tokens."""
|
216
|
+
multimodal = True
|
213
217
|
|
214
218
|
|
215
219
|
class Claude3Opus(Claude3):
|
@@ -228,3 +232,18 @@ class Claude3Haiku(Claude3):
|
|
228
232
|
"""Anthropic's most compact model."""
|
229
233
|
|
230
234
|
model = 'claude-3-haiku-20240307'
|
235
|
+
|
236
|
+
|
237
|
+
class Claude2(Anthropic):
|
238
|
+
"""Predecessor to Claude 3 with 100K context window.."""
|
239
|
+
model = 'claude-2.0'
|
240
|
+
|
241
|
+
|
242
|
+
class Claude21(Anthropic):
|
243
|
+
"""Updated Claude 2 model with improved accuracy and 200K context window."""
|
244
|
+
model = 'claude-2.1'
|
245
|
+
|
246
|
+
|
247
|
+
class ClaudeInstant(Anthropic):
|
248
|
+
"""Cheapest small and fast model, 100K context window."""
|
249
|
+
model = 'claude-instant-1.2'
|
langfun/core/llms/openai.py
CHANGED
@@ -31,10 +31,13 @@ SUPPORTED_MODELS_AND_SETTINGS = [
|
|
31
31
|
# The concurrent requests is estimated by TPM/RPM from
|
32
32
|
# https://platform.openai.com/account/limits
|
33
33
|
# GPT-4 Turbo models.
|
34
|
-
('gpt-4-turbo
|
35
|
-
('gpt-4-
|
36
|
-
('gpt-4-
|
37
|
-
('gpt-4-
|
34
|
+
('gpt-4-turbo', 8), # GPT-4 Turbo with Vision
|
35
|
+
('gpt-4-turbo-2024-04-09', 8), # GPT-4-Turbo with Vision, 04/09/2024
|
36
|
+
('gpt-4-turbo-preview', 8), # GPT-4 Turbo Preview
|
37
|
+
('gpt-4-0125-preview', 8), # GPT-4 Turbo Preview, 01/25/2024
|
38
|
+
('gpt-4-1106-preview', 8), # GPT-4 Turbo Preview, 11/06/2023
|
39
|
+
('gpt-4-vision-preview', 8), # GPT-4 Turbo Vision Preview.
|
40
|
+
('gpt-4-1106-vision-preview', 8), # GPT-4 Turbo Vision Preview, 11/06/2023
|
38
41
|
# GPT-4 models.
|
39
42
|
('gpt-4', 4),
|
40
43
|
('gpt-4-0613', 4),
|
@@ -284,26 +287,43 @@ class Gpt4(OpenAI):
|
|
284
287
|
|
285
288
|
|
286
289
|
class Gpt4Turbo(Gpt4):
|
287
|
-
"""GPT-4 Turbo with 128K context window
|
288
|
-
model = 'gpt-4-turbo
|
290
|
+
"""GPT-4 Turbo with 128K context window. Knowledge up to Dec. 2023."""
|
291
|
+
model = 'gpt-4-turbo'
|
292
|
+
multimodal = True
|
289
293
|
|
290
294
|
|
291
|
-
class
|
292
|
-
"""GPT-4 Turbo with
|
293
|
-
model = 'gpt-4-
|
295
|
+
class Gpt4Turbo_20240409(Gpt4Turbo): # pylint:disable=invalid-name
|
296
|
+
"""GPT-4 Turbo with 128K context window. Knowledge up to Dec. 2023."""
|
297
|
+
model = 'gpt-4-turbo-2024-04-09'
|
294
298
|
multimodal = True
|
295
299
|
|
296
300
|
|
297
|
-
class
|
298
|
-
"""GPT-4 Turbo with
|
301
|
+
class Gpt4TurboPreview(Gpt4):
|
302
|
+
"""GPT-4 Turbo Preview with 128k context window. Knowledge up to Dec. 2023."""
|
303
|
+
model = 'gpt-4-turbo-preview'
|
304
|
+
|
305
|
+
|
306
|
+
class Gpt4TurboPreview_0125(Gpt4TurboPreview): # pylint: disable=invalid-name
|
307
|
+
"""GPT-4 Turbo Preview with 128k context window. Knowledge up to Dec. 2023."""
|
299
308
|
model = 'gpt-4-0125-preview'
|
300
309
|
|
301
310
|
|
302
|
-
class
|
303
|
-
"""GPT-4 Turbo
|
311
|
+
class Gpt4TurboPreview_1106(Gpt4TurboPreview): # pylint: disable=invalid-name
|
312
|
+
"""GPT-4 Turbo Preview with 128k context window. Knowledge up to Apr. 2023."""
|
304
313
|
model = 'gpt-4-1106-preview'
|
305
314
|
|
306
315
|
|
316
|
+
class Gpt4VisionPreview(Gpt4):
|
317
|
+
"""GPT-4 Turbo vision preview. 128k context window. Knowledge to Apr. 2023."""
|
318
|
+
model = 'gpt-4-vision-preview'
|
319
|
+
multimodal = True
|
320
|
+
|
321
|
+
|
322
|
+
class Gpt4VisionPreview_1106(Gpt4): # pylint: disable=invalid-name
|
323
|
+
"""GPT-4 Turbo vision preview. 128k context window. Knowledge to Apr. 2023."""
|
324
|
+
model = 'gpt-4-1106-vision-preview'
|
325
|
+
|
326
|
+
|
307
327
|
class Gpt4_0613(Gpt4): # pylint:disable=invalid-name
|
308
328
|
"""GPT-4 @20230613. 8K context window. Knowledge up to 9-2021."""
|
309
329
|
model = 'gpt-4-0613'
|
langfun/core/llms/openai_test.py
CHANGED
@@ -157,17 +157,19 @@ class OpenaiTest(unittest.TestCase):
|
|
157
157
|
def test_call_chat_completion_vision(self):
|
158
158
|
with mock.patch('openai.ChatCompletion.create') as mock_chat_completion:
|
159
159
|
mock_chat_completion.side_effect = mock_chat_completion_query_vision
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
160
|
+
lm_1 = openai.Gpt4Turbo(api_key='test_key')
|
161
|
+
lm_2 = openai.Gpt4VisionPreview(api_key='test_key')
|
162
|
+
for lm in (lm_1, lm_2):
|
163
|
+
self.assertEqual(
|
164
|
+
lm(
|
165
|
+
lf.UserMessage(
|
166
|
+
'hello {{image}}',
|
167
|
+
image=lf_modalities.Image.from_uri('https://fake/image')
|
168
|
+
),
|
169
|
+
sampling_options=lf.LMSamplingOptions(n=2)
|
170
|
+
),
|
171
|
+
'Sample 0 for message: https://fake/image',
|
172
|
+
)
|
171
173
|
|
172
174
|
def test_sample_completion(self):
|
173
175
|
with mock.patch('openai.Completion.create') as mock_completion:
|
@@ -46,8 +46,8 @@ langfun/core/eval/matching.py,sha256=aqNlYrlav7YmsB7rUlsdfoi1RLA5CYqn2RGPxRlPc78
|
|
46
46
|
langfun/core/eval/matching_test.py,sha256=FFHYD7IDuKe5RMjkx74ksukiwUhO5a_SS340JaIPMws,4898
|
47
47
|
langfun/core/eval/scoring.py,sha256=aKeanBJf1yO3Q9JEtgPWoiZk_3M_GiqwXVXX7x_g22w,6172
|
48
48
|
langfun/core/eval/scoring_test.py,sha256=YH1cIxBWtfdKcAV9Fh10vLkV5J-gxk8b6nxW4Z2u5pk,4024
|
49
|
-
langfun/core/llms/__init__.py,sha256=
|
50
|
-
langfun/core/llms/anthropic.py,sha256=
|
49
|
+
langfun/core/llms/__init__.py,sha256=c_9lVKzFjnxHKgRjY_dUiJzBmW1jWALy3mtYv0uMyl0,2953
|
50
|
+
langfun/core/llms/anthropic.py,sha256=p-tjttvithBg2b4tgxIS2F-Zk5AYAh5e-lW-8e1p4wc,7865
|
51
51
|
langfun/core/llms/anthropic_test.py,sha256=OuLDxeiPRdqsfKILS0R6jJLTRs3-1KCIotPPr7IbIDU,5502
|
52
52
|
langfun/core/llms/fake.py,sha256=b-Xk5IPTbUt-elsyzd_i3n1tqzc_kgETXrEvgJruSMk,2824
|
53
53
|
langfun/core/llms/fake_test.py,sha256=ZlDQgL41EX3eYTfBQNp2nB2LciqCmtoHgCsGvW4XhwI,4184
|
@@ -55,8 +55,8 @@ langfun/core/llms/google_genai.py,sha256=n8zyJwh9UCTgb6-8LyvmjVNFGZQ4-zfzZ0ulkhH
|
|
55
55
|
langfun/core/llms/google_genai_test.py,sha256=_UcGTfl16-aDUlEWFC2W2F8y9jPUs53RBYA6MOCpGXw,7525
|
56
56
|
langfun/core/llms/llama_cpp.py,sha256=Y_KkMUf3Xfac49koMUtUslKl3h-HWp3-ntq7Jaa3bdo,2385
|
57
57
|
langfun/core/llms/llama_cpp_test.py,sha256=ZxC6defGd_HX9SFRU9U4cJiQnBKundbOrchbXuC1Z2M,1683
|
58
|
-
langfun/core/llms/openai.py,sha256=
|
59
|
-
langfun/core/llms/openai_test.py,sha256=
|
58
|
+
langfun/core/llms/openai.py,sha256=Z_pujF3B2QMzWBgOdV67DKAfZ8Wmyeb_6F9BkcGHyaE,12344
|
59
|
+
langfun/core/llms/openai_test.py,sha256=S83nVUq1Za15-rq-tCGOZPGPGByVgk0YdamoO7gnNpw,8270
|
60
60
|
langfun/core/llms/cache/__init__.py,sha256=QAo3InUMDM_YpteNnVCSejI4zOsnjSMWKJKzkb3VY64,993
|
61
61
|
langfun/core/llms/cache/base.py,sha256=cFfYvOIUae842pncqCAsRvqXCk2AnAsRYVx0mcIoAeY,3338
|
62
62
|
langfun/core/llms/cache/in_memory.py,sha256=YfFyJEhLs73cUiB0ZfhMxYpdE8Iuxxw-dvMFwGHTSHw,4742
|
@@ -99,8 +99,8 @@ langfun/core/templates/demonstration.py,sha256=vCrgYubdZM5Umqcgp8NUVGXgr4P_c-fik
|
|
99
99
|
langfun/core/templates/demonstration_test.py,sha256=SafcDQ0WgI7pw05EmPI2S4v1t3ABKzup8jReCljHeK4,2162
|
100
100
|
langfun/core/templates/selfplay.py,sha256=yhgrJbiYwq47TgzThmHrDQTF4nDrTI09CWGhuQPNv-s,2273
|
101
101
|
langfun/core/templates/selfplay_test.py,sha256=DYVrkk7uNKCqJGEHH31HssU2BPuMItU1vJLzfcXIlYg,2156
|
102
|
-
langfun-0.0.2.
|
103
|
-
langfun-0.0.2.
|
104
|
-
langfun-0.0.2.
|
105
|
-
langfun-0.0.2.
|
106
|
-
langfun-0.0.2.
|
102
|
+
langfun-0.0.2.dev20240420.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
103
|
+
langfun-0.0.2.dev20240420.dist-info/METADATA,sha256=R4bRp7OO2PSjDyKe48YvIbMptLTkeqesP98ZxJ17woc,3405
|
104
|
+
langfun-0.0.2.dev20240420.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
105
|
+
langfun-0.0.2.dev20240420.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
106
|
+
langfun-0.0.2.dev20240420.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|