Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Sep 30, 2024
1 parent cfc8c2e commit 9a37c02
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions integrations/llama_cpp/tests/test_chat_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,17 @@ def get_current_temperature(self, location):
@pytest.fixture
def generator(self, model_path, capsys):
gguf_model_path = (
"https://huggingface.co/bartowski/functionary-small-v3.1-GGUF/blob/main/functionary-small-v3.1-Q4_K_M.gguf"
"https://huggingface.co/meetkai/functionary-small-v2.4-GGUF/resolve/main/functionary-small-v2.4.Q4_0.gguf"
)
filename = "functionary-small-v3.1-Q4_K_M.gguf"
filename = "functionary-small-v2.4.Q4_0.gguf"
download_file(gguf_model_path, str(model_path / filename), capsys)
model_path = str(model_path / filename)
hf_tokenizer_path = "meetkai/functionary-small-v2.4-GGUF"
generator = LlamaCppChatGenerator(
model=model_path,
n_ctx=8192,
n_batch=512,
generation_kwargs={"max_tokens": 256},
model_kwargs={
"chat_format": "functionary-v2",
"hf_tokenizer_path": hf_tokenizer_path,
Expand Down Expand Up @@ -399,15 +400,15 @@ def test_function_call_and_execute(self, generator):
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["location"],
},
},
}
]

response = generator.run(messages=messages, generation_kwargs={"tools": tools})
tool_choice = {"type": "function", "function": {"name": "get_current_temperature"}}
response = generator.run(messages=messages, generation_kwargs={"tools": tools, "tool_choice": tool_choice})

available_functions = {
"get_current_temperature": self.get_current_temperature,
Expand All @@ -417,6 +418,7 @@ def test_function_call_and_execute(self, generator):
assert len(response["replies"]) > 0

first_reply = response["replies"][0]
print(first_reply)
assert "tool_calls" in first_reply.meta
tool_calls = first_reply.meta["tool_calls"]

Expand Down

0 comments on commit 9a37c02

Please sign in to comment.