Skip to content

Commit

Permalink
fix: bad type conversion (Chainlit#1693)
Browse files Browse the repository at this point in the history
* fix: bad type conversion
  • Loading branch information
willydouhard authored Jan 13, 2025
1 parent 534b73a commit 4f67278
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions backend/chainlit/data/literalai.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
class LiteralToChainlitConverter:
@classmethod
def steptype_to_steptype(cls, step_type: Optional[StepType]) -> TrueStepType:
if step_type in ["user_message", "assistant_message", "system_message"]:
return "undefined"
return cast(TrueStepType, step_type or "undefined")

@classmethod
Expand Down
10 changes: 6 additions & 4 deletions backend/tests/data/test_literalai.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,16 @@ async def test_update_step(

def test_steptype_to_steptype():
assert (
LiteralToChainlitConverter.steptype_to_steptype("user_message") == "undefined"
LiteralToChainlitConverter.steptype_to_steptype("user_message")
== "user_message"
)
assert (
LiteralToChainlitConverter.steptype_to_steptype("assistant_message")
== "undefined"
== "assistant_message"
)
assert (
LiteralToChainlitConverter.steptype_to_steptype("system_message") == "undefined"
LiteralToChainlitConverter.steptype_to_steptype("system_message")
== "system_message"
)
assert LiteralToChainlitConverter.steptype_to_steptype("tool") == "tool"
assert LiteralToChainlitConverter.steptype_to_steptype(None) == "undefined"
Expand Down Expand Up @@ -990,7 +992,7 @@ def test_step_to_step():
assert isinstance(chainlit_step, Step)
assert chainlit_step.id == "test_step_id"
assert chainlit_step.thread_id == "test_thread_id"
assert chainlit_step.type == "undefined"
assert chainlit_step.type == "user_message"
assert chainlit_step.name == "Test Step"
assert chainlit_step.input == "test input"
assert chainlit_step.output == "test output"
Expand Down

0 comments on commit 4f67278

Please sign in to comment.