diff --git a/simplemind/models.py b/simplemind/models.py index 50d931d..1f92757 100644 --- a/simplemind/models.py +++ b/simplemind/models.py @@ -13,6 +13,9 @@ class SMBaseModel(BaseModel): def __str__(self): return f"<{self.__class__.__name__} {self.model_dump_json()}>" + def __repr__(self): + return str(self) + class Message(SMBaseModel): role: str @@ -51,4 +54,7 @@ class Conversation(SMBaseModel): ) -> Message: """Send the conversation to the LLM.""" provider = find_provider(llm_provider or self.llm_provider) - return provider.send_conversation(self) + response = provider.send_conversation(self) + + self.add_message(role="assistant", text=response.text, meta=response.meta) + return response diff --git a/t.py b/t.py index ff34b99..c799eb0 100644 --- a/t.py +++ b/t.py @@ -2,6 +2,7 @@ import simplemind as sm conversation = sm.create_conversation() conversation.add_message(role="user", text="Hello, how are you? Do you like poetry?") -r = conversation.send(llm_provider="anthropic") +r = conversation.send(llm_provider="openai") print(r.text) +print(conversation.messages)