mirror of
https://github.com/kennethreitz/simplemind.git
synced 2026-06-05 22:50:18 +00:00
33e53562ae
This commit refactors the `create_conversation` function in `simplemind/__init__.py` to use a more descriptive variable name (`conv`) for the conversation object. It also updates the `add_plugin` method to use the new variable name (`conv`) instead of `conversation`. In `simplemind/models.py`, the `prepend_system_message` method now accepts an optional `meta` parameter. The method also adds a system message to the conversation by prepending it to the list of messages. Additionally, the `add_message` method in `simplemind/models.py` has been modified to include type annotations and a default value for the `role` parameter. The method now requires the `text` parameter to be provided explicitly. A new test file, `tests/test_conversations.py`, has been added to the repository. This file contains a test case for the `generate_data` function, which tests the functionality of different LLM providers. Lastly, the test files `tests/test_generate_data.py` and `tests/test_generate_text.py` have been modified to remove the unused `Amazon` provider from the list of test cases.
29 lines
564 B
Python
29 lines
564 B
Python
import pytest
|
|
|
|
from simplemind.providers import Anthropic, Gemini, OpenAI, Groq, Ollama, Amazon
|
|
|
|
import simplemind as sm
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"provider_cls",
|
|
[
|
|
Anthropic,
|
|
Gemini,
|
|
OpenAI,
|
|
Groq,
|
|
Ollama,
|
|
# Amazon
|
|
],
|
|
)
|
|
def test_generate_data(provider_cls):
|
|
conv = sm.create_conversation(
|
|
llm_model=provider_cls.DEFAULT_MODEL, llm_provider=provider_cls.NAME
|
|
)
|
|
|
|
conv.add_message(text="hey")
|
|
data = conv.send()
|
|
|
|
assert isinstance(data.text, str)
|
|
assert len(data.text) > 0
|