Skip to content

Commit 81f159b

Browse files
committed
test: add integration tests for light models, command-r-plus, multi-turn, and system message
1 parent bac195c commit 81f159b

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

tests/test_oci_client.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,77 @@ def test_command_a_chat(self):
348348
)
349349
self.assertIsNotNone(response.message)
350350

351+
def test_embed_english_light_v3(self):
352+
"""Test embed-english-light-v3.0 returns 384-dim vectors."""
353+
response = self.client.embed(
354+
model="embed-english-light-v3.0",
355+
texts=["Hello world"],
356+
input_type="search_document",
357+
)
358+
self.assertIsNotNone(response.embeddings.float_)
359+
self.assertEqual(len(response.embeddings.float_[0]), 384)
360+
361+
def test_embed_multilingual_light_v3(self):
362+
"""Test embed-multilingual-light-v3.0 returns 384-dim vectors."""
363+
response = self.client.embed(
364+
model="embed-multilingual-light-v3.0",
365+
texts=["Bonjour le monde"],
366+
input_type="search_document",
367+
)
368+
self.assertIsNotNone(response.embeddings.float_)
369+
self.assertEqual(len(response.embeddings.float_[0]), 384)
370+
371+
def test_embed_search_query_input_type(self):
372+
"""Test embed with search_query input_type (distinct from search_document)."""
373+
response = self.client.embed(
374+
model="embed-english-v3.0",
375+
texts=["What is the capital of France?"],
376+
input_type="search_query",
377+
)
378+
self.assertIsNotNone(response.embeddings.float_)
379+
self.assertEqual(len(response.embeddings.float_[0]), 1024)
380+
381+
def test_command_r_plus_chat(self):
382+
"""Test command-r-plus-08-2024 via V1 client."""
383+
v1_client = cohere.OciClient(
384+
oci_region=os.getenv("OCI_REGION", "us-chicago-1"),
385+
oci_compartment_id=os.getenv("OCI_COMPARTMENT_ID"),
386+
oci_profile=os.getenv("OCI_PROFILE", "DEFAULT"),
387+
)
388+
response = v1_client.chat(
389+
model="command-r-plus-08-2024",
390+
message="What is 2+2? Answer with just the number.",
391+
)
392+
self.assertIsNotNone(response.text)
393+
self.assertIn("4", response.text)
394+
395+
def test_v2_multi_turn_chat(self):
396+
"""Test V2 chat with conversation history (multi-turn)."""
397+
response = self.client.chat(
398+
model="command-a-03-2025",
399+
messages=[
400+
{"role": "user", "content": "My name is Alice."},
401+
{"role": "assistant", "content": "Nice to meet you, Alice!"},
402+
{"role": "user", "content": "What is my name?"},
403+
],
404+
)
405+
self.assertIsNotNone(response.message)
406+
content = response.message.content[0].text
407+
self.assertIn("Alice", content)
408+
409+
def test_v2_system_message(self):
410+
"""Test V2 chat with a system message."""
411+
response = self.client.chat(
412+
model="command-a-03-2025",
413+
messages=[
414+
{"role": "system", "content": "You are a helpful assistant. Always respond in exactly 3 words."},
415+
{"role": "user", "content": "Say hello."},
416+
],
417+
)
418+
self.assertIsNotNone(response.message)
419+
self.assertIsNotNone(response.message.content[0].text)
420+
421+
351422
class TestOciClientTransformations(unittest.TestCase):
352423
"""Unit tests for OCI request/response transformations (no OCI credentials required)."""
353424

0 commit comments

Comments
 (0)