From 0772884b06fc9c81db8188fdae3bdfe083cfac54 Mon Sep 17 00:00:00 2001 From: Pierrick HYMBERT Date: Tue, 20 Feb 2024 22:55:29 +0100 Subject: [PATCH] server: tests: add a constant seed in completion request --- examples/server/tests/features/server.feature | 2 +- examples/server/tests/features/steps/steps.py | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/examples/server/tests/features/server.feature b/examples/server/tests/features/server.feature index 35b4244d3..968e288d0 100644 --- a/examples/server/tests/features/server.feature +++ b/examples/server/tests/features/server.feature @@ -1,7 +1,7 @@ Feature: llama.cpp server Background: Server startup - Given a server listening on localhost:8080 with 2 slots + Given a server listening on localhost:8080 with 2 slots and 42 as seed Then the server is starting Then the server is healthy diff --git a/examples/server/tests/features/steps/steps.py b/examples/server/tests/features/steps/steps.py index 72857c45e..400b3c126 100644 --- a/examples/server/tests/features/steps/steps.py +++ b/examples/server/tests/features/steps/steps.py @@ -7,11 +7,12 @@ import requests from behave import step -@step(u"a server listening on {server_fqdn}:{server_port} with {n_slots} slots") -def step_server_config(context, server_fqdn, server_port, n_slots): +@step(u"a server listening on {server_fqdn}:{server_port} with {n_slots} slots and {seed} as seed") +def step_server_config(context, server_fqdn, server_port, n_slots, seed): context.server_fqdn = server_fqdn context.server_port = int(server_port) context.n_slots = int(n_slots) + context.seed = int(seed) context.base_url = f'http://{context.server_fqdn}:{context.server_port}' context.completions = [] @@ -154,6 +155,7 @@ def request_completion(context, prompt, n_predict=None): response = requests.post(f'{context.base_url}/completion', json={ "prompt": prompt, "n_predict": int(n_predict) if n_predict is not None else 4096, + "seed": context.seed }) assert response.status_code == 200 context.completions.append(response.json()) @@ -173,7 +175,8 @@ def oai_chat_completions(context, user_prompt): ], model=context.model, max_tokens=context.max_tokens, - stream=context.enable_streaming + stream=context.enable_streaming, + seed = context.seed ) if context.enable_streaming: completion_response = {