mirror of
https://github.com/Hopiu/llm.git
synced 2026-03-17 05:00:25 +00:00
parent
740a8e8344
commit
14a91efbad
4 changed files with 8 additions and 13 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
|
@ -11,6 +11,7 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
|
||||
pydantic: ["1.10.2", ">=2.0.0"]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
|
|
@ -22,6 +23,7 @@ jobs:
|
|||
- name: Install dependencies
|
||||
run: |
|
||||
pip install -e '.[test]'
|
||||
pip install pydantic==${{ matrix.pydantic }}
|
||||
- name: Run tests
|
||||
run: |
|
||||
pytest
|
||||
|
|
|
|||
|
|
@ -868,7 +868,7 @@ def load_template(name):
|
|||
return Template(name=name, prompt=loaded)
|
||||
loaded["name"] = name
|
||||
try:
|
||||
return Template.model_validate(loaded)
|
||||
return Template(**loaded)
|
||||
except pydantic.ValidationError as ex:
|
||||
msg = "A validation error occurred:\n"
|
||||
msg += render_errors(ex.errors())
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class Response(ABC):
|
|||
"prompt_json": self._prompt_json,
|
||||
"options_json": {
|
||||
key: value
|
||||
for key, value in self.prompt.options.model_dump().items()
|
||||
for key, value in dict(self.prompt.options).items()
|
||||
if value is not None
|
||||
},
|
||||
"response": self.text(),
|
||||
|
|
|
|||
|
|
@ -51,14 +51,7 @@ def test_openai_options_min_max(mocked_models):
|
|||
for option, [min_val, max_val] in options.items():
|
||||
result = runner.invoke(cli, ["-m", "chatgpt", "-o", option, "-10"])
|
||||
assert result.exit_code == 1
|
||||
assert (
|
||||
result.output
|
||||
== f"Error: {option}\n Input should be greater than or equal to {min_val}\n"
|
||||
)
|
||||
|
||||
result = runner.invoke(cli, ["-m", "chatgpt", "-o", option, "10"])
|
||||
assert result.exit_code == 1
|
||||
assert (
|
||||
result.output
|
||||
== f"Error: {option}\n Input should be less than or equal to {max_val}\n"
|
||||
)
|
||||
assert f"greater than or equal to {min_val}" in result.output
|
||||
result2 = runner.invoke(cli, ["-m", "chatgpt", "-o", option, "10"])
|
||||
assert result2.exit_code == 1
|
||||
assert f"less than or equal to {max_val}" in result2.output
|
||||
|
|
|
|||
Loading…
Reference in a new issue