gateway icon indicating copy to clipboard operation
gateway copied to clipboard

Anthropic only uses Last System Message

Open jpulec opened this issue 1 year ago • 2 comments

What Happened?

The way Portkey is set up, when sending multiple system messages to anthropic, only the last message is sent.

What Should Have Happened?

I'd propose that a better solution, since anthropic only allows a single system message to be provided, would be to concatenate all the provided system messages together, instead of only sending the last one.

If this seems reasonable, I can write the code for it.

Relevant Code Snippet

Note how system message is just wholesale overwritten in every iteration of param,messages:

https://github.com/Portkey-AI/gateway/blob/fe0899bbf1a0f65f8f751aca8fca1b0a4409acb4/src/providers/anthropic/chatComplete.ts#L174-L186

Your Twitter/LinkedIn

@jamespulec

jpulec avatar Jul 11 '24 20:07 jpulec

Thank you @jpulec - this seems interesting and useful. Tagging @VisargD / @roh26it who can give the final go.

vrushankportkey avatar Jul 12 '24 04:07 vrushankportkey

Hi @jpulec - Sounds like the right approach, can you raise a PR for this. Would be happy to merge this.

roh26it avatar Jul 29 '24 11:07 roh26it