1- from steamship import PluginInstance
1+ from steamship import PluginInstance , File
22from steamship .base import Client
33
44from tests .client .helpers import _steamship
88
99_TEST_EMBEDDER = "test-embedder"
1010
11+ def count_embeddings (file : File ):
12+ embeddings = 0
13+ for block in file .blocks :
14+ for tag in block .tags :
15+ if tag .kind == 'text' and tag .name == 'embedding' :
16+ embeddings += 1
17+ return embeddings
1118
1219def basic_embeddings (steamship : Client , pluginInstance : str ):
13- e1 = steamship .embed (["This is a test" ], pluginInstance = pluginInstance )
14- e1b = steamship .embed (["Banana" ], pluginInstance = pluginInstance )
15- assert (len (e1 .data .embeddings ) == 1 )
16- assert (len (e1 .data .embeddings [0 ]) > 1 )
20+ e1 = steamship .tag ("This is a test" , pluginInstance = pluginInstance )
21+ e1b = steamship .tag ("Banana" , pluginInstance = pluginInstance )
22+ e1 .wait ()
23+ e1b .wait ()
24+ assert (count_embeddings (e1 .data .file ) == 1 )
25+ assert (count_embeddings (e1b .data .file ) == 1 )
26+ assert (len (e1 .data .file .blocks [0 ].tags [0 ].value ['embedding' ]) > 1 )
1727
18- e2 = steamship .embed (["This is a test" ], pluginInstance = pluginInstance )
19- assert (len (e2 .data .embeddings ) == 1 )
20- assert (len (e2 .data .embeddings [0 ]) == len (e1 .data .embeddings [0 ]))
28+ e2 = steamship .tag ("This is a test" , pluginInstance = pluginInstance )
29+ e2 .wait ()
30+ assert (count_embeddings (e2 .data .file ) == 1 )
31+ assert (len (e2 .data .file .blocks [0 ].tags [0 ].value ['embedding' ]) == len (e1 .data .file .blocks [0 ].tags [0 ].value ['embedding' ]))
2132
22- e4 = steamship .embed (["This is a test" ], pluginInstance = pluginInstance )
23- assert (len (e4 .data .embeddings ) == 1 )
33+ e4 = steamship .tag ("This is a test" , pluginInstance = pluginInstance )
34+ e4 .wait ()
35+ assert (count_embeddings (e4 .data .file ) == 1 )
2436
2537
2638def test_basic_embeddings ():
@@ -38,8 +50,8 @@ def basic_embedding_search(steamship: Client, pluginInstance: str):
3850 ]
3951 query = "Who should I talk to about new employee setup?"
4052 results = steamship .embed_and_search (query , docs , pluginInstance = pluginInstance )
41- assert (len (results .data .hits ) == 1 )
42- assert (results .data .hits [0 ].value == "Jonathan can help you with new employee onboarding" )
53+ assert (len (results .data .items ) == 1 )
54+ assert (results .data .items [0 ]. value .value == "Jonathan can help you with new employee onboarding" )
4355
4456
4557def test_basic_embedding_search ():
0 commit comments