langfun 0.1.2.dev202502110804__py3-none-any.whl → 0.1.2.dev202502120804__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 +6 -2
- langfun/core/language_model.py +365 -22
- langfun/core/language_model_test.py +123 -35
- langfun/core/llms/__init__.py +50 -57
- langfun/core/llms/anthropic.py +434 -163
- langfun/core/llms/anthropic_test.py +20 -1
- langfun/core/llms/deepseek.py +90 -51
- langfun/core/llms/deepseek_test.py +15 -16
- langfun/core/llms/fake.py +6 -0
- langfun/core/llms/gemini.py +480 -390
- langfun/core/llms/gemini_test.py +27 -7
- langfun/core/llms/google_genai.py +80 -50
- langfun/core/llms/google_genai_test.py +11 -4
- langfun/core/llms/groq.py +268 -167
- langfun/core/llms/groq_test.py +9 -3
- langfun/core/llms/openai.py +839 -328
- langfun/core/llms/openai_compatible.py +3 -18
- langfun/core/llms/openai_compatible_test.py +20 -5
- langfun/core/llms/openai_test.py +14 -4
- langfun/core/llms/rest.py +11 -6
- langfun/core/llms/vertexai.py +238 -240
- langfun/core/llms/vertexai_test.py +35 -8
- {langfun-0.1.2.dev202502110804.dist-info → langfun-0.1.2.dev202502120804.dist-info}/METADATA +1 -1
- {langfun-0.1.2.dev202502110804.dist-info → langfun-0.1.2.dev202502120804.dist-info}/RECORD +27 -27
- {langfun-0.1.2.dev202502110804.dist-info → langfun-0.1.2.dev202502120804.dist-info}/LICENSE +0 -0
- {langfun-0.1.2.dev202502110804.dist-info → langfun-0.1.2.dev202502120804.dist-info}/WHEEL +0 -0
- {langfun-0.1.2.dev202502110804.dist-info → langfun-0.1.2.dev202502120804.dist-info}/top_level.txt +0 -0
@@ -20,6 +20,7 @@ from unittest import mock
|
|
20
20
|
from google.auth import exceptions
|
21
21
|
import langfun.core as lf
|
22
22
|
from langfun.core.llms import vertexai
|
23
|
+
import pyglove as pg
|
23
24
|
|
24
25
|
|
25
26
|
class VertexAITest(unittest.TestCase):
|
@@ -28,21 +29,22 @@ class VertexAITest(unittest.TestCase):
|
|
28
29
|
@mock.patch.object(vertexai.VertexAI, 'credentials', new=True)
|
29
30
|
def test_project_and_location_check(self):
|
30
31
|
with self.assertRaisesRegex(ValueError, 'Please specify `project`'):
|
31
|
-
_ = vertexai.
|
32
|
+
_ = vertexai.VertexAIGemini15Pro()._api_initialized
|
32
33
|
|
33
34
|
with self.assertRaisesRegex(ValueError, 'Please specify `location`'):
|
34
|
-
_ = vertexai.
|
35
|
+
_ = vertexai.VertexAIGemini15Pro(
|
36
|
+
project='abc', location=None)._api_initialized
|
35
37
|
|
36
38
|
self.assertTrue(
|
37
|
-
vertexai.
|
39
|
+
vertexai.VertexAIGemini15Pro(
|
38
40
|
project='abc', location='us-central1'
|
39
41
|
)._api_initialized
|
40
42
|
)
|
41
43
|
|
42
44
|
os.environ['VERTEXAI_PROJECT'] = 'abc'
|
43
45
|
os.environ['VERTEXAI_LOCATION'] = 'us-central1'
|
44
|
-
model = vertexai.
|
45
|
-
self.
|
46
|
+
model = vertexai.VertexAIGemini15Pro(location=pg.MISSING_VALUE)
|
47
|
+
self.assertEqual(model.resource_id, 'vertexai://gemini-1.5-pro-002')
|
46
48
|
self.assertIn('us-central1', model.api_endpoint)
|
47
49
|
self.assertTrue(model._api_initialized)
|
48
50
|
self.assertIsNotNone(model.session())
|
@@ -55,11 +57,18 @@ class VertexAIAnthropicTest(unittest.TestCase):
|
|
55
57
|
|
56
58
|
def test_basics(self):
|
57
59
|
with self.assertRaisesRegex(ValueError, 'Please specify `project`'):
|
58
|
-
lm = vertexai.
|
60
|
+
lm = vertexai.VertexAIClaude35Sonnet_20241022()
|
59
61
|
lm('hi')
|
60
62
|
|
61
|
-
model = vertexai.
|
62
|
-
|
63
|
+
model = vertexai.VertexAIClaude35Sonnet_20241022(project='langfun')
|
64
|
+
self.assertEqual(model.resource_id, 'vertexai://claude-3-5-sonnet-20241022')
|
65
|
+
# Map a Anthropic model back to VertexAI model.
|
66
|
+
self.assertTrue(
|
67
|
+
vertexai.VertexAIAnthropic(
|
68
|
+
'claude-3-5-sonnet-20241022', project='langfun'
|
69
|
+
).model,
|
70
|
+
'claude-3-5-sonnet-v2@20241022',
|
71
|
+
)
|
63
72
|
# NOTE(daiyip): For OSS users, default credentials are not available unless
|
64
73
|
# users have already set up their GCP project. Therefore we ignore the
|
65
74
|
# exception here.
|
@@ -99,6 +108,24 @@ class VertexAIAnthropicTest(unittest.TestCase):
|
|
99
108
|
},
|
100
109
|
)
|
101
110
|
|
111
|
+
def test_lm_get(self):
|
112
|
+
self.assertIsInstance(
|
113
|
+
lf.LanguageModel.get('gemini-2.0-flash'),
|
114
|
+
vertexai.VertexAIGemini,
|
115
|
+
)
|
116
|
+
self.assertIsInstance(
|
117
|
+
lf.LanguageModel.get('claude-3-5-sonnet-v2@20241022'),
|
118
|
+
vertexai.VertexAIAnthropic,
|
119
|
+
)
|
120
|
+
self.assertIsInstance(
|
121
|
+
lf.LanguageModel.get('llama-3.1-405b-instruct-maas'),
|
122
|
+
vertexai.VertexAILlama,
|
123
|
+
)
|
124
|
+
self.assertIsInstance(
|
125
|
+
lf.LanguageModel.get('mistral-large-2411'),
|
126
|
+
vertexai.VertexAIMistral,
|
127
|
+
)
|
128
|
+
|
102
129
|
|
103
130
|
if __name__ == '__main__':
|
104
131
|
unittest.main()
|
@@ -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=S6YS15fLy5M3L3qaSa3XhDgku-klUm1LJxFPB-Wl-tY,4596
|
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
|
@@ -8,8 +8,8 @@ langfun/core/console.py,sha256=V_mOiFi9oGh8gLsUeR56pdFDkuvYOpvQt7DY1KUTWTA,2535
|
|
8
8
|
langfun/core/console_test.py,sha256=pBOcuNMJdVELywvroptfcRtJMsegMm3wSlHAL2TdxVk,1679
|
9
9
|
langfun/core/langfunc.py,sha256=G50YgoVZ0y1GFw2ev41MlOqr6qa8YakbvNC0h_E0PiA,11140
|
10
10
|
langfun/core/langfunc_test.py,sha256=fKIAqcSNI_7M6nwoZW77HEam8Oa6vcWhsCNgVJanzb4,8822
|
11
|
-
langfun/core/language_model.py,sha256=
|
12
|
-
langfun/core/language_model_test.py,sha256=
|
11
|
+
langfun/core/language_model.py,sha256=RWTyPXGxcP0hlTuGgKAcdyrYSDAAAbErZb4U7ypRXqg,45669
|
12
|
+
langfun/core/language_model_test.py,sha256=iA5uo7rIj2jAtCYzMzhyNg1fWqE2Onn60bOO58q72C0,36454
|
13
13
|
langfun/core/logging.py,sha256=W3mLEMXdo210Q5OX3a1ZTc4nU-xMy73-IfNKnsA-RFo,8051
|
14
14
|
langfun/core/logging_test.py,sha256=N7-YvSXC8zvnr2SNwWHOykn1CFmqvIuTLDgn41Ku9JU,6642
|
15
15
|
langfun/core/memory.py,sha256=f-asN1F7Vehgdn_fK84v73GrEUOxRtaW934keutTKjk,2416
|
@@ -73,31 +73,31 @@ 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=
|
77
|
-
langfun/core/llms/anthropic.py,sha256=
|
78
|
-
langfun/core/llms/anthropic_test.py,sha256=
|
76
|
+
langfun/core/llms/__init__.py,sha256=gph3HngayM-WExoaoKM-S6Ke7_MRtvEojKoaf9LusJ0,7740
|
77
|
+
langfun/core/llms/anthropic.py,sha256=nov4_EoqDL0_DAW93Eb5p-fHE-AfvzA8Q7PtYfcQdMg,20548
|
78
|
+
langfun/core/llms/anthropic_test.py,sha256=SSK7OTx3gMYE1NMAi_PqQqeNsCkZAcVJvl_OCEOhyzk,7145
|
79
79
|
langfun/core/llms/compositional.py,sha256=csW_FLlgL-tpeyCOTVvfUQkMa_zCN5Y2I-YbSNuK27U,2872
|
80
80
|
langfun/core/llms/compositional_test.py,sha256=4eTnOer-DncRKGaIJW2ZQQMLnt5r2R0UIx_DYOvGAQo,2027
|
81
|
-
langfun/core/llms/deepseek.py,sha256=
|
82
|
-
langfun/core/llms/deepseek_test.py,sha256=
|
83
|
-
langfun/core/llms/fake.py,sha256=
|
81
|
+
langfun/core/llms/deepseek.py,sha256=jvTxdXPr-vH6HNakn_Ootx1heDg8Fen2FUkUW36bpCs,5247
|
82
|
+
langfun/core/llms/deepseek_test.py,sha256=DvROWPlDuow5E1lfoSkhyGt_ELA19JoQoDsTnRgDtTg,1847
|
83
|
+
langfun/core/llms/fake.py,sha256=xmgCkk9y0I4x0IT32SZ9_OT27aLadXH8PRiYNo5VTd4,3265
|
84
84
|
langfun/core/llms/fake_test.py,sha256=2h13qkwEz_JR0mtUDPxdAhQo7MueXaFSwsD2DIRDW9g,7653
|
85
|
-
langfun/core/llms/gemini.py,sha256=
|
86
|
-
langfun/core/llms/gemini_test.py,sha256=
|
87
|
-
langfun/core/llms/google_genai.py,sha256=
|
88
|
-
langfun/core/llms/google_genai_test.py,sha256=
|
89
|
-
langfun/core/llms/groq.py,sha256=
|
90
|
-
langfun/core/llms/groq_test.py,sha256=
|
85
|
+
langfun/core/llms/gemini.py,sha256=95PD90TuR3N8m9L50LHIuCByPTMi2qHaYaCwy7d0qYI,22511
|
86
|
+
langfun/core/llms/gemini_test.py,sha256=ZzQmgB5bxJdtD2nVOz0WQ1zjNCea_jM5Yuqs8kchnGw,6621
|
87
|
+
langfun/core/llms/google_genai.py,sha256=mzUdWAShRzz2k_foUo0eIdNOyHs_xjEtbewqYyuD0k0,4768
|
88
|
+
langfun/core/llms/google_genai_test.py,sha256=NKNtpebArQ9ZR7Qsnhd2prFIpMjleojy6o6VMXkJ1zY,1502
|
89
|
+
langfun/core/llms/groq.py,sha256=S9V10kFo3cgX89qPgt_umq-SpRnxEDLTt_hJmpERfbo,12066
|
90
|
+
langfun/core/llms/groq_test.py,sha256=P4EgexCqsh4K2x11w0UL_vz-YYNaPdQU0WsDAdnTRQ8,2045
|
91
91
|
langfun/core/llms/llama_cpp.py,sha256=Z7P3gc4xeIjc2bX0Ey1y5EUYJVMnMa2Q67PZ9iye9sE,1409
|
92
92
|
langfun/core/llms/llama_cpp_test.py,sha256=wfTO7nmUwL65U2kK9P9fcMt92JjNDuVia4G1E7znf_4,1086
|
93
|
-
langfun/core/llms/openai.py,sha256=
|
94
|
-
langfun/core/llms/openai_compatible.py,sha256=
|
95
|
-
langfun/core/llms/openai_compatible_test.py,sha256=
|
96
|
-
langfun/core/llms/openai_test.py,sha256=
|
97
|
-
langfun/core/llms/rest.py,sha256=
|
93
|
+
langfun/core/llms/openai.py,sha256=_ptVgolpK2atVn6c_7TgO3wHyOvagWtfDMCv2KXv5LY,38553
|
94
|
+
langfun/core/llms/openai_compatible.py,sha256=lhq9_XLVUoGa5AIPXTbqGqWvm2P3dkHFSUQ7XnyLozw,5442
|
95
|
+
langfun/core/llms/openai_compatible_test.py,sha256=I5WWL3lRo-WXnSoUKLkIEjXfwjoiHRX9o0dj0j09jsk,17024
|
96
|
+
langfun/core/llms/openai_test.py,sha256=gwuO6aoa296iM2welWV9ua4KF8gEVGsEPakgbtkWkFQ,2687
|
97
|
+
langfun/core/llms/rest.py,sha256=xdR4ar4y7YkeZTs_BHUyNOdhqoghztMcqyz1f9kTXH8,4054
|
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=UBOt58FHlzwM1EwYBt2ADk7K2AFg7HMdI2aEwQZLAc4,17473
|
100
|
+
langfun/core/llms/vertexai_test.py,sha256=dOprP_uLNmXHYxMoX_hMPMsjKR-e_B5nKHjhlMCQoOQ,4252
|
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.dev202502120804.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
152
|
+
langfun-0.1.2.dev202502120804.dist-info/METADATA,sha256=qY1L92qXnvb7WBDdQ_xQTWQvv4wZq4-TqqhHp1i9wHs,8172
|
153
|
+
langfun-0.1.2.dev202502120804.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
154
|
+
langfun-0.1.2.dev202502120804.dist-info/top_level.txt,sha256=RhlEkHxs1qtzmmtWSwYoLVJAc1YrbPtxQ52uh8Z9VvY,8
|
155
|
+
langfun-0.1.2.dev202502120804.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{langfun-0.1.2.dev202502110804.dist-info → langfun-0.1.2.dev202502120804.dist-info}/top_level.txt
RENAMED
File without changes
|