Skip to content
Snippets Groups Projects
Unverified Commit 7e959cc8 authored by Rodrigo Nogueira's avatar Rodrigo Nogueira Committed by GitHub
Browse files

Add system prompt (#11325)

* add system prompt workaround

* remove workaround flag

* fix lint
parent d34e5a8b
No related branches found
No related tags found
No related merge requests found
...@@ -45,11 +45,6 @@ class Maritalk(LLM): ...@@ -45,11 +45,6 @@ class Maritalk(LLM):
description="Nucleus sampling parameter controlling the size of" description="Nucleus sampling parameter controlling the size of"
" the probability mass considered for sampling.", " the probability mass considered for sampling.",
) )
system_message_workaround: bool = Field(
default=True,
description="Whether to include a workaround for system"
" message by adding it as a user message.",
)
_endpoint: str = PrivateAttr("https://chat.maritaca.ai/api/chat/inference") _endpoint: str = PrivateAttr("https://chat.maritaca.ai/api/chat/inference")
...@@ -79,13 +74,21 @@ class Maritalk(LLM): ...@@ -79,13 +74,21 @@ class Maritalk(LLM):
@llm_chat_callback() @llm_chat_callback()
def chat(self, messages: Sequence[ChatMessage], **kwargs: Any) -> ChatResponse: def chat(self, messages: Sequence[ChatMessage], **kwargs: Any) -> ChatResponse:
# Prepare the data payload for the Maritalk API # Prepare the data payload for the Maritalk API
formatted_messages = [ formatted_messages = []
{ for msg in messages:
"role": "user" if msg.role == MessageRole.USER else "assistant", if msg.role == MessageRole.SYSTEM:
"content": msg.content, # Add system message as a user message
} formatted_messages.append({"role": "user", "content": msg.content})
for msg in messages # Follow it by an assistant message acknowledging it, to maintain conversation flow
] formatted_messages.append({"role": "assistant", "content": "ok"})
else:
# Format user and assistant messages as before
formatted_messages.append(
{
"role": "user" if msg.role == MessageRole.USER else "assistant",
"content": msg.content,
}
)
data = { data = {
"messages": formatted_messages, "messages": formatted_messages,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment