mirror of
https://github.com/Hopiu/llm.git
synced 2026-03-16 20:50:25 +00:00
Allow -o option when calling tools, closes #1233
This commit is contained in:
parent
cbd3aab511
commit
5204a11f33
3 changed files with 27 additions and 1 deletions
|
|
@ -777,7 +777,7 @@ def prompt(
|
|||
if key_ not in validated_options:
|
||||
validated_options[key_] = value
|
||||
|
||||
kwargs = {**validated_options}
|
||||
kwargs = {}
|
||||
|
||||
resolved_attachments = [*attachments, *attachment_types]
|
||||
|
||||
|
|
@ -817,12 +817,16 @@ def prompt(
|
|||
|
||||
if tool_implementations:
|
||||
prompt_method = conversation.chain
|
||||
kwargs["options"] = validated_options
|
||||
kwargs["chain_limit"] = chain_limit
|
||||
if tools_debug:
|
||||
kwargs["after_call"] = _debug_tool_call
|
||||
if tools_approve:
|
||||
kwargs["before_call"] = _approve_tool_call
|
||||
kwargs["tools"] = tool_implementations
|
||||
else:
|
||||
# Merge in options for the .prompt() methods
|
||||
kwargs.update(validated_options)
|
||||
|
||||
try:
|
||||
if async_:
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class MockModel(llm.Model):
|
|||
model_id = "mock"
|
||||
attachment_types = {"image/png", "audio/wav"}
|
||||
supports_schema = True
|
||||
supports_tools = True
|
||||
|
||||
class Options(llm.Options):
|
||||
max_tokens: Optional[int] = Field(
|
||||
|
|
|
|||
|
|
@ -304,6 +304,27 @@ def test_default_tool_llm_version():
|
|||
assert '"output": "{}"'.format(version("llm")) in result.output
|
||||
|
||||
|
||||
def test_cli_tools_with_options():
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli.cli,
|
||||
[
|
||||
"-m",
|
||||
"mock",
|
||||
"-o",
|
||||
"max_tokens",
|
||||
"10",
|
||||
"-T",
|
||||
"llm_version",
|
||||
json.dumps({"tool_calls": [{"name": "llm_version"}]}),
|
||||
],
|
||||
catch_exceptions=False,
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
# It just needs not to crash
|
||||
# https://github.com/simonw/llm/issues/1233
|
||||
|
||||
|
||||
def test_functions_tool_locals():
|
||||
# https://github.com/simonw/llm/issues/1107
|
||||
runner = CliRunner()
|
||||
|
|
|
|||
Loading…
Reference in a new issue