@@ -28,7 +28,11 @@ async def test_ok(self, faker: faker.Faker) -> None:
2828 200 ,
2929 json = ChatCompletionsNotStreamingResponse (
3030 choices = [
31- OneNotStreamingChoice (message = ChatCompletionsMessage (role = "assistant" , content = expected_result ))
31+ OneNotStreamingChoice (
32+ message = ChatCompletionsMessage (
33+ role = any_llm_client .MessageRole .assistant , content = expected_result
34+ )
35+ )
3236 ]
3337 ).model_dump (mode = "json" ),
3438 )
@@ -55,11 +59,11 @@ async def test_fails_without_alternatives(self) -> None:
5559class TestOpenAIRequestLLMPartialResponses :
5660 async def test_ok (self , faker : faker .Faker ) -> None :
5761 generated_messages : typing .Final = [
58- OneStreamingChoiceDelta (role = " assistant" ),
62+ OneStreamingChoiceDelta (role = any_llm_client . MessageRole . assistant ),
5963 OneStreamingChoiceDelta (content = "H" ),
6064 OneStreamingChoiceDelta (content = "i" ),
6165 OneStreamingChoiceDelta (content = " t" ),
62- OneStreamingChoiceDelta (role = " assistant" , content = "here" ),
66+ OneStreamingChoiceDelta (role = any_llm_client . MessageRole . assistant , content = "here" ),
6367 OneStreamingChoiceDelta (),
6468 OneStreamingChoiceDelta (content = ". How is you" ),
6569 OneStreamingChoiceDelta (content = "r day?" ),
@@ -171,12 +175,17 @@ class TestOpenAIMessageAlternation:
171175 ],
172176 [],
173177 ),
174- ([any_llm_client .SystemMessage ("Be nice" )], [ChatCompletionsMessage (role = "user" , content = "Be nice" )]),
178+ (
179+ [any_llm_client .SystemMessage ("Be nice" )],
180+ [ChatCompletionsMessage (role = any_llm_client .MessageRole .user , content = "Be nice" )],
181+ ),
175182 (
176183 [any_llm_client .UserMessage ("Hi there" ), any_llm_client .AssistantMessage ("Hi! How can I help you?" )],
177184 [
178- ChatCompletionsMessage (role = "user" , content = "Hi there" ),
179- ChatCompletionsMessage (role = "assistant" , content = "Hi! How can I help you?" ),
185+ ChatCompletionsMessage (role = any_llm_client .MessageRole .user , content = "Hi there" ),
186+ ChatCompletionsMessage (
187+ role = any_llm_client .MessageRole .assistant , content = "Hi! How can I help you?"
188+ ),
180189 ],
181190 ),
182191 (
@@ -186,13 +195,15 @@ class TestOpenAIMessageAlternation:
186195 any_llm_client .AssistantMessage ("Hi! How can I help you?" ),
187196 ],
188197 [
189- ChatCompletionsMessage (role = "user" , content = "Hi there" ),
190- ChatCompletionsMessage (role = "assistant" , content = "Hi! How can I help you?" ),
198+ ChatCompletionsMessage (role = any_llm_client .MessageRole .user , content = "Hi there" ),
199+ ChatCompletionsMessage (
200+ role = any_llm_client .MessageRole .assistant , content = "Hi! How can I help you?"
201+ ),
191202 ],
192203 ),
193204 (
194205 [any_llm_client .SystemMessage ("Be nice" ), any_llm_client .UserMessage ("Hi there" )],
195- [ChatCompletionsMessage (role = " user" , content = "Be nice\n \n Hi there" )],
206+ [ChatCompletionsMessage (role = any_llm_client . MessageRole . user , content = "Be nice\n \n Hi there" )],
196207 ),
197208 (
198209 [
@@ -210,14 +221,16 @@ class TestOpenAIMessageAlternation:
210221 any_llm_client .UserMessage ("Hmmm..." ),
211222 ],
212223 [
213- ChatCompletionsMessage (role = " user" , content = "Be nice" ),
224+ ChatCompletionsMessage (role = any_llm_client . MessageRole . user , content = "Be nice" ),
214225 ChatCompletionsMessage (
215- role = " assistant" ,
226+ role = any_llm_client . MessageRole . assistant ,
216227 content = "Hi!\n \n I'm your answer to everything.\n \n How can I help you?" ,
217228 ),
218- ChatCompletionsMessage (role = "user" , content = "Hi there\n \n Why is the sky blue?" ),
219- ChatCompletionsMessage (role = "assistant" , content = "Well..." ),
220- ChatCompletionsMessage (role = "user" , content = "Hmmm..." ),
229+ ChatCompletionsMessage (
230+ role = any_llm_client .MessageRole .user , content = "Hi there\n \n Why is the sky blue?"
231+ ),
232+ ChatCompletionsMessage (role = any_llm_client .MessageRole .assistant , content = "Well..." ),
233+ ChatCompletionsMessage (role = any_llm_client .MessageRole .user , content = "Hmmm..." ),
221234 ],
222235 ),
223236 ],
@@ -237,6 +250,6 @@ def test_without_alternation(self) -> None:
237250 assert client ._prepare_messages ( # noqa: SLF001
238251 [any_llm_client .SystemMessage ("Be nice" ), any_llm_client .UserMessage ("Hi there" )]
239252 ) == [
240- ChatCompletionsMessage (role = " system" , content = "Be nice" ),
241- ChatCompletionsMessage (role = " user" , content = "Hi there" ),
253+ ChatCompletionsMessage (role = any_llm_client . MessageRole . system , content = "Be nice" ),
254+ ChatCompletionsMessage (role = any_llm_client . MessageRole . user , content = "Hi there" ),
242255 ]
0 commit comments