Skip to content

Commit 71b160d

Browse files
committed
fix: match newline characters and trim whitespace in prompt
Fixes a bug where only the first line of the prompt was matched, so multi-line prompts are now recognized and handled properly. Also fixes a bug where the first line being empty results in an empty prompt. Signed-off-by: Edward Ly <[email protected]>
1 parent 110684c commit 71b160d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def lifespan(app: FastAPI):
3333

3434
def ai_talk_bot_process_request(message: TalkBotMessage, nc: NextcloudApp):
3535
message_text = message.object_content["message"]
36-
prompt = re.search(r"@assistant\s(.*)", message_text, re.IGNORECASE)
36+
prompt = re.search(r"@assistant\s+(.*)\s*", message_text, re.IGNORECASE | re.DOTALL)
3737

3838
if prompt is None:
3939
return

0 commit comments

Comments
 (0)