From b9df07d74d85756f1d02a6185816ad88f8bcd51c Mon Sep 17 00:00:00 2001 From: b1ek Date: Thu, 11 Apr 2024 23:21:08 +1000 Subject: [PATCH] add article about DDG --- config.toml | 2 +- content/blog/duckduck-ai-chat.md | 61 ++++++++++++++++++++++++++++++++ sass/base.scss | 8 ++++- templates/base.html | 2 +- 4 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 content/blog/duckduck-ai-chat.md diff --git a/config.toml b/config.toml index 99b93d3..64c608d 100644 --- a/config.toml +++ b/config.toml @@ -12,7 +12,7 @@ build_search_index = false [markdown] # Whether to do syntax highlighting # Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola -highlight_code = false +highlight_code = true [extra] # Put all your custom variables here diff --git a/content/blog/duckduck-ai-chat.md b/content/blog/duckduck-ai-chat.md new file mode 100644 index 0000000..9457c11 --- /dev/null +++ b/content/blog/duckduck-ai-chat.md @@ -0,0 +1,61 @@ ++++ +template = 'custom/blog-post.html' + +title = 'duckduckgo ai chat thing' +description = 'its kinda cool' +date = '2024-04-11' +slug = 'duckduckgo-ai-chat' +year = 2024 +month = 4 +day = 11 +lang = 'en' + +[extra] +author = 'b1ek ' ++++ + +so, a few days ago i've noticed that duckduckgo has this weird new "ai chat" option: +![screenshot of duckduckgo page with a red arrow pointing to the "Chat" button](/blog-image/chat-btn.png) + +it allows you to select two models: claude 1.2 and chatgpt 3.5. the last one is widely known, however you can find some info on claude [here](https://www.anthropic.com/news/releasing-claude-instant-1-2) + +as i've always wondered just how real their claims are that your identity is never attached to the models, i've decided to research into the API. + +## chat APIs + +| Disclaimer: The following section is of educational purposes only. Please do not scrape DuckDuckGo's APIs, as it would only hurt the company which honestly cares about your privacy. | +| --- | + +obviously the first thing i wanted to do see if there is a public chat API. i wasn't suprised when i couldn't find info on any of the public duckduckgo APIs(probably because there isn't any), other than [this stackoverflow answer](https://stackoverflow.com/questions/29346239/duckduckgo-api-how-to-get-more-results) + +however i've investigated a bit and turns out that client API is not that complicated as i thought. + +now, first of all you need yo obtain the API token via `GET https://duckduckgo.com/duckchat/v1/status` with a header `x-vqd-accept: 1`. the api token will be in the `x-vqd-4` header. it seems a bit tricky to get the right token without it throwing a `ERR_INVALID_VQD` error later, so its best to copy the request as cURL from your browser. + +it is quite weird actually that it seems to be accepting only genuine browser-generated headers. however they contain little to no identifying data. + +after you got the api key, send a `POST https://duckduckgo.com/duckchat/v1/chat` with a header `x-vqd-4: the-vqd-header-from-previous-request`. + +the payload seems to be of this TS type and encoded via JSON: + +```ts +type ChatPayload { + messages: { content: string, role: 'user' }[], + model: 'claude-instant-1.2' | 'gpt-3.5-turbo-0125' +} +``` + +then the API will return the response word-by-word in a good ol' streamed http response in chunks like this: +```json +\n +data: {"role":"assistant","message":".","created":1712840811713,"id":"compl_8pC9nVX8QJlN92jUtcJR8TgB","action":"success","model":"claude-instant-1.2"} +``` + +also the `/duckchat/v1/chat` request gives you the new VQD which you gotta use for the future requests. + +i guess someone could fashion a cli program to read data from that API and print it out in the console. + +## the verdict +i think its safe to say that no identity data is collected via the chat APIs, other than your IP address, which by itself is not usually enough to identify a user, especially if you're sitting on a public network. + +also if someone from the team who made the API reads this, please tell me if i missed some points, and what the hell does VQD even mean. diff --git a/sass/base.scss b/sass/base.scss index c85b830..93623c0 100644 --- a/sass/base.scss +++ b/sass/base.scss @@ -49,4 +49,10 @@ a, a:visited { &:hover { text-decoration: underline !important; } -} \ No newline at end of file +} + +pre code { + padding: 0.5em 1em; + display: block; +} + diff --git a/templates/base.html b/templates/base.html index 2f38620..a3f9b13 100644 --- a/templates/base.html +++ b/templates/base.html @@ -10,7 +10,7 @@ blek! World