replicate / llama-chat

A boilerplate for creating a Llama 3 chat app
https://llama3.replicate.dev
Apache License 2.0
827 stars 307 forks source link

Add Cloudflare Turnstile #118

Closed mattt closed 5 months ago

mattt commented 5 months ago

This PR adds a Cloudflare Turnstile challenge on page load to help reduce bot traffic.

From https://developers.cloudflare.com/turnstile/:

Turnstile is Cloudflare’s smart CAPTCHA alternative. It can be embedded into any website without sending traffic through Cloudflare and works without showing visitors a CAPTCHA.

Screenshot 2024-04-26 at 06 46 07

The current modal treatment is a bit heavy-handed, but it works for a proof-of-concept. The dev environment and preview deployment use a hard-coded test key, which always passes after showing the widget.

As an improvement, we should conditionalize the dialog to show only when the widget is showing. If we do that, then users passing an invisible challenges could use the app without noticing any change from how it works today.

vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
llama-chat ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2024 1:58pm
cbh123 commented 5 months ago

Success case (show turnstile):

https://github.com/replicate/llama-chat/assets/14149230/ee909311-5811-47e8-8cf9-0b244d47264e

Success case (invisible):

https://github.com/replicate/llama-chat/assets/14149230/c3d112fc-9ce3-4eeb-b3a9-85e868d5b8f2

Fail case:

https://github.com/replicate/llama-chat/assets/14149230/6ea5ac67-c527-4485-a9b3-c62ac1f1aadc