mirror of
https://github.com/Hopiu/llm.git
synced 2026-04-25 23:44:48 +00:00
attachments= keyword argument, tests pass again - refs #587
This commit is contained in:
parent
a9bc1c7329
commit
286cf9fcd9
3 changed files with 19 additions and 7 deletions
|
|
@ -521,7 +521,7 @@ def chat(
|
|||
raise click.ClickException(str(ex))
|
||||
if prompt.strip() in ("exit", "quit"):
|
||||
break
|
||||
response = conversation.prompt(prompt, system, **validated_options)
|
||||
response = conversation.prompt(prompt, system=system, **validated_options)
|
||||
# System prompt only sent for the first message:
|
||||
system = None
|
||||
for chunk in response:
|
||||
|
|
|
|||
|
|
@ -85,11 +85,18 @@ class Prompt:
|
|||
options: "Options" = field(default_factory=dict)
|
||||
|
||||
def __init__(
|
||||
self, prompt, model, attachments, system=None, prompt_json=None, options=None
|
||||
self,
|
||||
prompt,
|
||||
model,
|
||||
*,
|
||||
attachments=None,
|
||||
system=None,
|
||||
prompt_json=None,
|
||||
options=None
|
||||
):
|
||||
self.prompt = prompt
|
||||
self.model = model
|
||||
self.attachments = list(attachments)
|
||||
self.attachments = list(attachments or [])
|
||||
self.system = system
|
||||
self.prompt_json = prompt_json
|
||||
self.options = options or {}
|
||||
|
|
@ -105,7 +112,8 @@ class Conversation:
|
|||
def prompt(
|
||||
self,
|
||||
prompt: Optional[str],
|
||||
*attachments: Attachment,
|
||||
*,
|
||||
attachments: Attachment = None,
|
||||
system: Optional[str] = None,
|
||||
stream: bool = True,
|
||||
**options
|
||||
|
|
@ -386,7 +394,8 @@ class Model(ABC, _get_key_mixin):
|
|||
def prompt(
|
||||
self,
|
||||
prompt: str,
|
||||
*attachments: Attachment,
|
||||
*,
|
||||
attachments: Attachment = None,
|
||||
system: Optional[str] = None,
|
||||
stream: bool = True,
|
||||
**options
|
||||
|
|
@ -396,7 +405,7 @@ class Model(ABC, _get_key_mixin):
|
|||
raise ValueError(
|
||||
"This model does not support attachments, but some were provided"
|
||||
)
|
||||
for attachment in attachments:
|
||||
for attachment in attachments or []:
|
||||
attachment_type = attachment.resolve_type()
|
||||
if attachment_type not in self.attachment_types:
|
||||
raise ValueError(
|
||||
|
|
|
|||
|
|
@ -23,7 +23,10 @@ def test_chat_basic(mock_model, logs_db):
|
|||
mock_model.enqueue(["one world"])
|
||||
mock_model.enqueue(["one again"])
|
||||
result = runner.invoke(
|
||||
llm.cli.cli, ["chat", "-m", "mock"], input="Hi\nHi two\nquit\n"
|
||||
llm.cli.cli,
|
||||
["chat", "-m", "mock"],
|
||||
input="Hi\nHi two\nquit\n",
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert result.output == (
|
||||
|
|
|
|||
Loading…
Reference in a new issue