Skip to content

Commit 69ce0c5

Browse files
committed
refactor: ♻️ Solves #259
1 parent 609bc2d commit 69ce0c5

2 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/llm.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,11 @@ def build_prompt(self, current_field):
2929
This method is in charge of the prompt engineering. It creates a specific prompt for each target field.
3030
@params: current_field -> represents the current element of the json that is being prompted.
3131
"""
32-
prompt = f"""
33-
SYSTEM PROMPT:
34-
You are an AI assistant designed to help fillout json files with information extracted from transcribed voice recordings.
35-
You will receive the transcription, and the name of the JSON field whose value you have to identify in the context. Return
36-
only a single string containing the identified value for the JSON field.
37-
If the field name is plural, and you identify more than one possible value in the text, return both separated by a ";".
38-
If you don't identify the value in the provided text, return "-1".
39-
---
40-
DATA:
41-
Target JSON field to find in text: {current_field}
42-
43-
TEXT: {self._transcript_text}
44-
"""
45-
46-
return prompt
32+
prompt_path = os.path.join(os.path.dirname(__file__), "prompt.txt")
33+
with open(prompt_path, "r") as f:
34+
template = f.read()
35+
36+
return template.format(field=current_field, text=self._transcript_text)
4737

4838
def main_loop(self):
4939
timeout = 45

src/prompt.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SYSTEM PROMPT:
2+
You are an AI assistant designed to help fillout json files with information extracted from transcribed voice recordings.
3+
You will receive the transcription, and the name of the JSON field whose value you have to identify in the context. Return
4+
only a single string containing the identified value for the JSON field.
5+
If the field name is plural, and you identify more than one possible value in the text, return both separated by a ";".
6+
If you don't identify the value in the provided text, return "-1".
7+
---
8+
DATA:
9+
Target JSON field to find in text: {field}
10+
11+
TEXT: {text}

0 commit comments

Comments
 (0)