Commit ·
99649f6
1
Parent(s): 7b3dadd
Inject client terminology into system prompt
Browse files- backend/pipeline.py +8 -3
backend/pipeline.py
CHANGED
|
@@ -17,6 +17,7 @@ from sentence_transformers import SentenceTransformer
|
|
| 17 |
|
| 18 |
from config import features_path, domain_for, DISPLAY_NAMES
|
| 19 |
from grader import grade, GradeReport, get_embedder
|
|
|
|
| 20 |
|
| 21 |
log = logging.getLogger(__name__)
|
| 22 |
|
|
@@ -26,9 +27,10 @@ MIN_RETRIEVAL_SCORE = 0.1
|
|
| 26 |
SYSTEM_PROMPT = """\
|
| 27 |
You are a helpful assistant for {client_display} ({domain} domain).
|
| 28 |
Answer the user's question using only the information in the provided context.
|
| 29 |
-
Be concise.
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
@dataclass(slots=True)
|
|
@@ -97,9 +99,12 @@ def _generate(
|
|
| 97 |
domain: str,
|
| 98 |
hf_client: InferenceClient,
|
| 99 |
) -> str:
|
|
|
|
|
|
|
| 100 |
system = SYSTEM_PROMPT.format(
|
| 101 |
client_display=DISPLAY_NAMES.get(client, client),
|
| 102 |
domain=domain,
|
|
|
|
| 103 |
)
|
| 104 |
response = hf_client.chat.completions.create(
|
| 105 |
model=HF_GENERATION_MODEL,
|
|
|
|
| 17 |
|
| 18 |
from config import features_path, domain_for, DISPLAY_NAMES
|
| 19 |
from grader import grade, GradeReport, get_embedder
|
| 20 |
+
from rosetta import client_terms
|
| 21 |
|
| 22 |
log = logging.getLogger(__name__)
|
| 23 |
|
|
|
|
| 27 |
SYSTEM_PROMPT = """\
|
| 28 |
You are a helpful assistant for {client_display} ({domain} domain).
|
| 29 |
Answer the user's question using only the information in the provided context.
|
| 30 |
+
Be concise. If the context does not contain enough information to answer, say so clearly rather than speculating.
|
| 31 |
+
|
| 32 |
+
You MUST use the following terminology. These are the only acceptable terms — do not substitute synonyms:
|
| 33 |
+
{term_list}"""
|
| 34 |
|
| 35 |
|
| 36 |
@dataclass(slots=True)
|
|
|
|
| 99 |
domain: str,
|
| 100 |
hf_client: InferenceClient,
|
| 101 |
) -> str:
|
| 102 |
+
terms = client_terms(client)
|
| 103 |
+
term_list = "\n".join(f"- {v}" for v in terms.values()) if terms else "(none)"
|
| 104 |
system = SYSTEM_PROMPT.format(
|
| 105 |
client_display=DISPLAY_NAMES.get(client, client),
|
| 106 |
domain=domain,
|
| 107 |
+
term_list=term_list,
|
| 108 |
)
|
| 109 |
response = hf_client.chat.completions.create(
|
| 110 |
model=HF_GENERATION_MODEL,
|