Skip to content
This repository has been archived by the owner on Feb 3, 2025. It is now read-only.
/ dirtygpt Public archive

A dirty and free way to use ChatGPT in Nim

License

Notifications You must be signed in to change notification settings

thisago/dirtygpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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!

About

A dirty and free way to use ChatGPT in Nim

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages