Skip to content

Commit 8913020

Browse files
authored
Merge pull request #271 from FullStackWithLawrence/next
refactor: remove legacy yaml config file
2 parents e9e47b2 + 7a11955 commit 8913020

File tree

8 files changed

+29
-312
lines changed

8 files changed

+29
-312
lines changed

api/terraform/python/openai_api/lambda_openai_function/function_refers_to.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,12 @@
55
"""
66
import json
77

8-
import requests
9-
import yaml
108
from openai_api.common.const import PYTHON_ROOT
119
from openai_api.lambda_openai_function.natural_language_processing import does_refer_to
1210
from openai_api.lambda_openai_function.refers_to import RefersTo
1311
from openai_api.lambda_openai_function.refers_to import config as refers_to_config
1412

1513

16-
with open(PYTHON_ROOT + "/openai_api/lambda_openai_function/lambda_config.yaml", "r", encoding="utf-8") as file:
17-
lambda_config = yaml.safe_load(file)
18-
19-
2014
def search_terms_are_in_messages(messages: list, search_terms: list = None, search_pairs: list = None) -> bool:
2115
"""
2216
Return True the user has mentioned Lawrence McDaniel or FullStackWithLawrence
@@ -40,11 +34,11 @@ def search_terms_are_in_messages(messages: list, search_terms: list = None, sear
4034
return False
4135

4236

43-
def customized_prompt(messages: list) -> list:
37+
def customized_prompt(config: RefersTo, messages: list) -> list:
4438
"""Return a prompt for Lawrence McDaniel"""
4539
custom_prompt = {
4640
"role": "system",
47-
"content": lambda_config["system_prompt"],
41+
"content": config.system_prompt,
4842
}
4943

5044
for i, message in enumerate(messages):
@@ -57,7 +51,7 @@ def customized_prompt(messages: list) -> list:
5751

5852
# pylint: disable=too-many-return-statements
5953
def get_additional_info(inquiry_type: str) -> str:
60-
"""Return select info from lambda_config.yaml"""
54+
"""Return select info from custom config object"""
6155

6256
for config in refers_to_config:
6357
try:

api/terraform/python/openai_api/lambda_openai_function/lambda_config.yaml

-204
This file was deleted.

api/terraform/python/openai_api/lambda_openai_function/lambda_handler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def handler(event, context):
8181
messages=messages, search_terms=config.search_terms.strings, search_pairs=config.search_terms.pairs
8282
):
8383
model = "gpt-3.5-turbo-1106"
84-
messages = customized_prompt(messages=messages)
84+
messages = customized_prompt(config=config, messages=messages)
8585
tools = info_tool_factory(config=config)
8686
break
8787

api/terraform/python/openai_api/lambda_openai_function/tests/mock_data/config/everlasting-gobbstopper.json

-63
This file was deleted.

api/terraform/python/openai_api/lambda_openai_function/tests/mock_data/config/everlasting-gobbstopper.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
search_terms:
33
strings:
44
- everlasting gobstopper
5-
- everlasting gob stopper
5+
- everlasting gobstoppers
6+
- everlasting gobstopper's
67
pairs:
78
- - everlasting
89
- gobstopper
910
- - everlasting
10-
- gob stopper
11+
- gobstoppers
1112
function_description: Get additional information about the Everlasting Gobstopper product created by Willy Wonka Chocolate Factory. Information includes sales promotions, coupon codes, company contact information and biographical background on the company founder.
1213
system_prompt: >
1314
You are a helpful marketing agent for the [Everlasting Gobstopper Company](https://everlasting-gobstoppers.com).

api/terraform/python/openai_api/lambda_openai_function/tests/mock_data/json/prompt_about_lawrence.json renamed to api/terraform/python/openai_api/lambda_openai_function/tests/mock_data/json/prompt_about_everlasting_gobstoppers.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
{
1212
"role": "user",
13-
"content": "have you ever heard of lawrence mcdaniel?"
13+
"content": "have you ever heard of everlasting gobstoppers?"
1414
}
1515
]
1616
}

0 commit comments

Comments
 (0)