callbacked / keyless-gpt-wrapper-api

A Free OpenAI-compatible API designed to interact with models like GPT-4o, Claude 3 Haiku, Mixtral 8x7b & Llama 3 70b through DuckDuckGo's AI Chat.
https://callbacked.github.io/keyless-gpt-wrapper-api/
21 stars 2 forks source link

TODO: Go Rewrite #7

Open callbacked opened 3 weeks ago

callbacked commented 3 weeks ago

go is cool and awesome

kth8 commented 3 weeks ago

I saw this project from Reddit and it looks pretty cools. I tested this using Open WebUI and it worked well although the speed is noticeably slower compared to using duck.ai directly. I fed your code in my AI and got this after some prompting. It doesn't work exactly right as content gets printed out from the sever instead of to the client but atleast it's able to get a response https://gist.github.com/kth8/f9f660583484243d9ff071ec46a994b7

curl -s http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{"model": "keyless-gpt-4o-mini", "messages": [{"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"}]}' | jq .
{
  "id": "1c2fd1e8-f076-4b2a-897e-1e7a8a3ed604",
  "object": "chat.completion",
  "created": 1730203855,
  "model": "keyless-gpt-4o-mini",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": ""
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 2,
    "completion_tokens": 0,
    "total_tokens": 2
  }
}
2024/10/29 12:10:48 Server is running on port 8080...
2024/10/29 12:10:55 Received chat completion request for conversation 1c2fd1e8-f076-4b2a-897e-1e7a8a3ed604
2024/10/29 12:10:55 DuckDuckGo response status code: 200
2024/10/29 12:10:55 DuckDuckGo response body: data: {"role":"assistant","message":"","created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: {"message":"How","created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: {"message":" can","created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: {"message":" I","created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: {"message":" assist","created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: {"message":" you","created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: {"message":" today","created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: {"message":"?","created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: {"created":1730203855,"id":"chatcmpl-ANfLj1zJJNNAXkl22NU1dN7G8HrNU","action":"success","model":"gpt-4o-mini-2024-07-18"}

data: [DONE
callbacked commented 3 weeks ago

Wow, the code looks promising. For the time being I will look into performance optimizations to the current python code to see if I can speed some things up. Right now, I intend on tackling the issue of fetching the model names automatically, because I have them hardcoded, and if DuckDuckGo ever decides to add/update new models to their site, the API wrapper will break. Gonna prioritize that first.

Got a busy week ahead of me sadly, so I'll leave this for the weekend.

kth8 commented 3 weeks ago

I remembered this project tgpt is written in Go and also connects to DuckDuckGo's AI Chat so perhaps you can take a look at their implementation and use it as another reference when the time comes.