No description
Find a file
2023-10-08 15:32:07 +00:00
examples Version 0.3.0 2023-10-08 12:15:59 +00:00
src Fixed crash when userscript request the prompt but there's no more 2023-10-08 15:32:07 +00:00
tests init 2023-08-17 12:27:50 +00:00
.gitignore init 2023-08-17 12:27:50 +00:00
changelog.md Fixed crash when userscript request the prompt but there's no more 2023-10-08 15:32:07 +00:00
config.nims working on 2023-08-21 17:31:49 +00:00
dirtyGpt.nimble Renamed project from dirtygpt to dirtyGpt 2023-10-08 12:18:26 +00:00
license init 2023-08-17 12:27:50 +00:00
readme.md Added Greasemonkey extension recommendation 2023-10-08 12:22:43 +00:00

Google Bard Logo

DirtyGPT

A dirty and free way to use ChatGPT in Nim

About - How it works? - Installation - Usage - License

About

Prompt in ChatGPT web using Nim!

See this lib working at cligpt

How it works?

When you create a new instance of DirtyGPT, an http web server starts asynchronously, it accept multiple websocket connections and when you query the prompt in lib, the server will add your prompt to the queue, and the connected userscripts will request a prompt. When the server sends the prompt to a client (userscript), it saves the client ID in prompt and if for some reason the client disconnects, the items bound to that client ID will be cleaned and wait to be asked, in higher priority than others.

The client userscript controls the ChatGPT webpage, when it receives the prompt, it fills up the input and clicks in the button to send. When AI is answering, the button changes, when it returns to their original form, the userscript reads the output HTML, converts it to Markdown and sends back to server (lib). Then it's available to another prompt, the loop will request the next one.

Installation

Install the lib with Nimble:

nimble install dirtygpt

And at installation end you'll see something like this:

[...]

Please, don't forget to install the client userscript in your browser: ~/.nimble/pkgs2/dirtygpt-version-hash/userscript.user.js

Install the provided Javascript userscript path in a userscript manager in your browser, like Greasemonkey (Violentmonkey doesn't works, the browser blocks you to open localhost WS)

Usage

After installed the library and userscript, make sure that you have an open tab with ChatGPT logged in.

The usage is simple:

prompt.nim

import std/asyncdispatch
import pkg/dirtygpt

let gpt = newDirtyGpt()

echo waitFor gpt.prompt "Hello, are you Google Bard?"

stop gpt

stdout

No, I'm not Google Bard. I'm ChatGPT, an AI language model created by OpenAI. While both Google Bard and I are AI language models designed to generate text-based responses, we come from different organizations and have different underlying technologies. How can I assist you today?

TODO

  • Add pinging because connectedClients is just updated when exceeds timeout

License

This piece of software is libre, licensed over the MIT license. Feel free to use!