Spaces:
Runtime error
Runtime error
Yap reduction via prompt tweak
Browse files
src/ctp_slack_bot/services/language_model_service.py
CHANGED
@@ -37,12 +37,13 @@ class LanguageModelService(BaseModel):
|
|
37 |
messages = [
|
38 |
{"role": "system", "content": self.settings.SYSTEM_PROMPT},
|
39 |
{"role": "user", "content":
|
40 |
-
f"""Student Question:
|
|
|
41 |
|
42 |
Context from class materials and transcripts:
|
43 |
-
{'\n'.join(chunk.text for chunk in context)}
|
44 |
|
45 |
-
Please answer the Student Question based on the Context from class materials and transcripts. If the context doesn’t contain relevant information, acknowledge that and suggest asking the professor."""}
|
46 |
]
|
47 |
response: ChatCompletion = self._open_ai_client.chat.completions.create(
|
48 |
model=self.settings.CHAT_MODEL,
|
@@ -52,4 +53,3 @@ class LanguageModelService(BaseModel):
|
|
52 |
)
|
53 |
|
54 |
return response.choices[0].message.content
|
55 |
-
# return f"Mock response to “{question}”"
|
|
|
37 |
messages = [
|
38 |
{"role": "system", "content": self.settings.SYSTEM_PROMPT},
|
39 |
{"role": "user", "content":
|
40 |
+
f"""Student Question:
|
41 |
+
{question}
|
42 |
|
43 |
Context from class materials and transcripts:
|
44 |
+
{'\n\n'.join(chunk.text for chunk in context)}
|
45 |
|
46 |
+
Please answer the Student Question based on the Context from class materials and transcripts. If the context doesn’t contain relevant information, acknowledge that and suggest asking the professor. Otherwise, carry on."""}
|
47 |
]
|
48 |
response: ChatCompletion = self._open_ai_client.chat.completions.create(
|
49 |
model=self.settings.CHAT_MODEL,
|
|
|
53 |
)
|
54 |
|
55 |
return response.choices[0].message.content
|
|