Skip to content

Commit d79e1f1

Browse files
committed
fix: inference-mock code review changes
Signed-off-by: Emilio Garcia <i.am.emilio@gmail.com>
1 parent 42b46f5 commit d79e1f1

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ missing-member-max-choices=1
627627
mixin-class-rgx=.*[Mm]ixin
628628

629629
# List of decorators that change the signature of a decorated function.
630-
signature-mutators=unittest.mock.patch,unittest.mock.patch.object
630+
signature-mutators=unittest.mock.patch,unittest.mock.patch.object,click.decorators.option
631631

632632

633633
[VARIABLES]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Below is a list of the in-house GitHub actions stored in this repository:
2121
| [launch-ec2-runner-with-fallback](./actions/launch-ec2-runner-with-fallback/launch-ec2-runner-with-fallback.md) | Used launch an EC2 instance in AWS, either as a spot instance or a dedicated instance. If your preferred availability zone lacks availability for your instance type, "backup" availability zones will be tried. | <ul><li>Insufficient capacity in AWS (i.e., AWS lacks availablility for your desired EC2 instance type in your preferred availability zone)</li><li>Cost savings (i.e., You want to try launching your EC2 runner as a spot instance first)</li></ul> |
2222
| [validate-notebooks](./actions/launch-ec2-runner-with-fallback/launch-ec2-runner-with-fallback.md) | Used to validate `.ipynb` files | <ul><li>I maintain a collection of `.ipynb` files and run ci jobs to test them. I would like to quickly verify that the files are formatted correctly before spinning up more complex or expensive CI jobs to test those notebooks.</li></ul>
2323
| [update-constraints](./actions/update-constraints/update-constraints.md) | Used to update `constraints-dev.txt` file | <ul><li>I pin all project dependencies in CI using `constraints-dev.txt` file. I would like to monitor new dependency releases and periodically post PRs to move pins forward.</li></ul>
24-
| [inference-mock](./actions/inference-mock/README.md) | Used to mock LLM calls | <ul><li>I have a notebook that I want to test that makes an LLM call, but I dont need to rely heavily on an LLM and don't need to run a real inference server for this test.</li></ul> |
24+
| [inference-mock](./actions/inference-mock/README.md) | Used to mock LLM calls | <ul><li>I have a notebook that I want to test that makes an LLM call, but I don't need to rely heavily on an LLM and don't need to run a real inference server for this test.</li></ul> |
2525

2626
## ❓ How to Use One or More In-House GitHub Actions
2727

actions/inference-mock/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Overview
44

55
Inference Mock is a tool that creates a flask server that runs as a background process. OpenAI comptabile calls can be made to its completions API.
6-
Based on how the server is configured, it will send a set of programmed resposnes back.
6+
Based on how the server is configured, it will send a set of programmed responses back.
77

88
## When to Use it?
99

actions/inference-mock/app.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,15 @@ def completions():
2323
if not data or "prompt" not in data:
2424
raise exceptions.BadRequest("prompt is empty or None")
2525

26-
prompt_debug_str = data["prompt"][:90] + "..."
26+
prompt = data.get('prompt')
27+
prompt_debug_str = prompt
28+
if len(prompt) > 90:
29+
prompt_debug_str = data["prompt"][:90] + "..."
30+
2731
app.logger.debug(
2832
f"{request.method} {request.url} {data['model']} {prompt_debug_str}"
2933
)
3034

31-
prompt = data.get("prompt")
3235
chat_response = strategies.find_match(
3336
prompt
3437
) # handle prompt and generate correct response
@@ -52,7 +55,7 @@ def start_server(config):
5255
# get config
5356
yaml_data = yaml.safe_load(config)
5457
if not isinstance(yaml_data, dict):
55-
raise ValueError("config file format is invalid")
58+
raise ValueError(f"config file {config} must be a set of key-value pairs")
5659

5760
conf = Config(**yaml_data)
5861

@@ -72,4 +75,4 @@ def start_server(config):
7275

7376

7477
if __name__ == "__main__":
75-
start_server() # pylint: disable=no-value-for-parameter
78+
start_server()

0 commit comments

Comments
 (0)