Skip to content

Commit

Permalink
allow curly brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
George Burton committed Sep 10, 2024
1 parent f54f5ae commit 89d7d62
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion django_app/redbox_app/redbox_core/consumers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def parse_page_number(obj: int | list[int] | None) -> list[int]:
raise ValueError(msg, type(obj))


def escape_curly_brackets(text: str):
return text.replace("{", "{{").replace("{", "}}")


class ChatConsumer(AsyncWebsocketConsumer):
full_reply: ClassVar = []
citations: ClassVar = []
Expand Down Expand Up @@ -100,7 +104,11 @@ async def llm_conversation(self, selected_files: Sequence[File], session: Chat,
s3_keys=[f.unique_name for f in selected_files],
user_uuid=user.id,
chat_history=[
ChainChatMessage(role=message.role, text=message.text) for message in message_history[:-1]
ChainChatMessage(
role=message.role,
text=escape_curly_brackets(message.text),
)
for message in message_history[:-1]
],
ai_settings=ai_settings,
),
Expand Down

0 comments on commit 89d7d62

Please sign in to comment.