Resend Chat request with authentication (#87)

Currently with arcade chat, when we send a request that requires tool
authentication, it sends the message then, waits for authentication,
then resends the current chat history. However we resend the
authntication link as the latest message instead of resending the
message that prompted the authentication link.

OpenAI ignores this and continues, however Anthropic errors because it
sees the history as

-User message {Get me sams last 5 tweets}
-Assistant message {Please go to this URL and authorize the action: }

instead of 
-User message {Get me sams last 5 tweets}
-Assistant message {Please go to this URL and authorize the action: }
-User message {Get me sams last 5 tweets}

Having an assistant message as the latest message in a request is
invalid for anthropic
This commit is contained in:
Sterling Dreyer 2024-10-04 11:00:53 -07:00 committed by GitHub
parent 799d376ae5
commit 2625be80bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -267,6 +267,7 @@ def chat(
wait_for_authorization_completion(client, tool_authorization)
# re-run the chat request now that authorization is complete
try:
history.pop()
chat_result = handle_chat_interaction(
client, model, history, user_email, stream
)