KudoAI / chatgpt.js

🤖 A powerful, open source client-side JavaScript library for ChatGPT
https://chatgpt.js.org
MIT License
1.92k stars 143 forks source link

label each conversation like `chatgpt-conversation-1` #25

Closed mefengl closed 1 year ago

mefengl commented 1 year ago

chatgpt-conversation-1

chatgpt-conversation-1-prompt

chatgpt-conversation-1-response-1

chatgpt-conversation-1-response-2

adamlui commented 1 year ago

btw your existing ID assignment to elements don't always work because DOM finishes loading + changes after lib loads. Also if other scripts are using those variable names, it will break both scripts (that's why I enclose in IIFE to keep variables scoped and prevent global pollution, coder needs to decide what to name var's instead of breaking scripts + they can use get() in their own mutation observers to avoid DOM problem)

mefengl commented 1 year ago

Yes, cause the buttons or elements showing or not is depend on the status, this repo can update the id dynamic when the status change or only give the get() function.

So write the get() function for this issue first instead of labelling

adamlui commented 1 year ago

Yes and in future we can implement status checking but the variable assignment would need to be chatgpt.buttonName format, and we keep get(buttonName) for those who want to do it their own way

adamlui commented 1 year ago

I wrote getResponse(pos) (https://github.com/chatgptjs/chatgpt.js/commit/90d975f5ba971ac65bc8cde54c2c70e745d3ccc9)

To use,

chatgpt.getResponse(3) // get 3rd response
chatgpt.getResponse('33rd') // get 33rd response
chatgpt.getResponse('thirteen') // get 13th response
adamlui commented 1 year ago

...but for words it doesn't do 'thirty-three' yet (otherwise the logic gets too unnecessarily long for a chatgpt lib)

mefengl commented 1 year ago

You may be a fan of ruby on rails causes you provide many ways to do one thing. To me, I may only add getResponseNumber(3)

mefengl commented 1 year ago

...but for words it doesn't do 'thirty-three' yet (otherwise the logic gets too unnecessarily long for a chatgpt lib)

You know what, if we like, we can let chatgpt decide how to call which function, then even getResponse('the one after 32') will work

but that may be too slow

adamlui commented 1 year ago

You may be a fan of ruby on rails causes you provide many ways to do one thing. To me, I may only add getResponseNumber(3)

I am not a fan of ruby on rails because it is a hipster language. I indeed like to provide flexibility because i always have target user in mind (in this case, lazy coder who doesn't read docs)

adamlui commented 1 year ago

...but for words it doesn't do 'thirty-three' yet (otherwise the logic gets too unnecessarily long for a chatgpt lib)

You know what, if we like, we can let chatgpt decide how to call which function, then even getResponse('the one after 32') will work

but that may be too slow

Wait that's a good idea, chatgpt seems to remembers its responses but I'm not sure if it indexes

adamlui commented 1 year ago

I just tested it, sometimes it doesn't go far back enough and sometimes it provides a similar but different response

mefengl commented 1 year ago

You may be a fan of ruby on rails causes you provide many ways to do one thing. To me, I may only add getResponseNumber(3)

I am not a fan of ruby on rails because it is a hipster language. I indeed like to provide flexibility because i always have target user in mind (in this case, lazy coder who doesn't read docs)

then the way to do this maybe provide types/chatgptjs

I don't think we need to worry about coders too much since we use ChatGPT eventually

adamlui commented 1 year ago

then the way to do this maybe provide types/chatgptjs

What's types/chatgptjs

I don't think we need to worry about coders too much since we use ChatGPT eventually

wdym?

mefengl commented 1 year ago

We provide TypeScript type definitions for ChatGPTJS, similar to how @types/jquery provides types for jQuery on npm. These types serve as documentation within the code.

I don't think we need to worry about coders too much since we use ChatGPT eventually

In other words, if developers don't read external documentation, they can still use ChatGPT effectively.

adamlui commented 1 year ago

We provide TypeScript type definitions for ChatGPTJS, similar to how @types/jquery provides types for jQuery on npm. These types serve as documentation within the code.

Ok if you want to do that go ahead, then i will see what you mean and expand on it

I don't think we need to worry about coders too much since we use ChatGPT eventually

In other words, if developers don't read external documentation, they can still use ChatGPT effectively.

You mean use chatgpt.js effectively to build chatgpt apps, if they use types? Or you mean the coders you know (and yourself) use ChatGPT to write code instead of reading docs?

mefengl commented 1 year ago

You mean use chatgpt.js effectively to build chatgpt apps, if they use types? Or you mean the coders you know (and yourself) use ChatGPT to write code instead of reading docs?

second meaning

mefengl commented 1 year ago

Ok if you want to do that go ahead, then i will see what you mean and expand on it

Exploring this is not a priority for me at the moment. My main concern is that I cannot determine if the feature works without implementing it in an actual project. Therefore, I plan to create multiple repositories to test this one and develop interesting projects while fixing and adding features to chatgptjs.

adamlui commented 1 year ago

You mean use chatgpt.js effectively to build chatgpt apps, if they use types? Or you mean the coders you know (and yourself) use ChatGPT to write code instead of reading docs?

second meaning

So you guys use bot to write code so I don't have to worry about making chatgpt.js easy to use? How would bot know how to use chatgpt.js?

adamlui commented 1 year ago

while fixing and adding features to chatgptjs

There's nothing broken in chagptjs (it was only your added var declarations that users cannot access) because I don't write broken code

mefengl commented 1 year ago

I'm just daydreaming.

We still need to write docs for bots to read by the way

adamlui commented 1 year ago

I will be writing docs for human to read, you mean chatgpt will read them and teach lazy coders?

mefengl commented 1 year ago

There's nothing broken in chagptjs (it was only your added var declarations that users cannot access) because I don't write broken code

Nothing broken doesn't mean it is easy to use, we can always make it better

mefengl commented 1 year ago

I will be writing docs for human to read, you mean chatgpt will read them and teach lazy coders?

Until openai uses the latest data to retrain chatgpt

adamlui commented 1 year ago

There's nothing broken in chagptjs (it was only your added var declarations that users cannot access) because I don't write broken code

Nothing broken doesn't mean it is easy to use, we can always make it better

It's hard to use for you? Can you give examples

adamlui commented 1 year ago

I will be writing docs for human to read, you mean chatgpt will read them and teach lazy coders?

Until openai uses the latest data to retrain chatgpt

OpenAI already has GPT-4 for paid members that uses new data, but is that what you meant by "We still need to write docs for bots to read by the way" ? You want ChatGPT to read it so lazy coders don't have to?

mefengl commented 1 year ago

It's hard to use for you?

The effectiveness of the functions varies. While the get functions are great, the event emitter and status management could use improvement.

Don't worry too much about this; we're just getting started.

mefengl commented 1 year ago

OpenAI already has GPT-4 for paid members that uses new data, but is that what you meant by "We still need to write docs for bots to read by the way" ? You want ChatGPT to read it so lazy coders don't have to?

It doesn't matter whether I want it or not; it will end up like this. Just like now, I won't go to see the jQuery documentation anymore. (Also, the data for chatgpt4 is still not the latest.)

adamlui commented 1 year ago

The effectiveness of the functions varies. While the get functions are great, the event emitter and status management could use improvement.

I haven't had time to even examine what your two functions do, I am working on abstracting things to auto-populate more functions + make it easier (that's why get() is great) so I can finally write docs for a to qualify for js.org domain

mefengl commented 1 year ago

To me, they are more like better than none, and I can make them better (when I really use them)

adamlui commented 1 year ago

It doesn't matter whether I want it or not; it will end up like this. Just like now, I won't go to see the jQuery documentation anymore. (Also, the data for chatgpt4 is still not the latest.)

I get it now. I wanted to write docs for human so I can finally launch a website, you wanted the docs for ChatGPT training but this lib is a little baby that ChatGPT will not take seriously until I activate my super marketing

adamlui commented 1 year ago

...but that will cum in the future do not worry

mefengl commented 1 year ago

You don't need to write docs for ChatGPT; human docs and codes will teach it how to use this

adamlui commented 1 year ago

You said you want docs for bot to read, then gave example that's how you research jQuery. I'm saying ChatGPT learned jQuery from user discussion, but no one uses this yet and it has to be really big for ChatGPT to train on user data

adamlui commented 1 year ago

...and the bigness is not guaranteed, but I am an expert at marketing (but will not start until the lib is comprehensive)

adamlui commented 1 year ago

(better than nothing is good for progress to reach a level that a release would benefit public)

mefengl commented 1 year ago

Yeah, it's like, talk is cheap, show me the code,

I will be away for quite a while, QwQ, have many jobs to do

adamlui commented 1 year ago

Computer jobs?

mefengl commented 1 year ago

yep

adamlui commented 1 year ago

For status check what are you using it for? Would a coder not benefit enough with a very simple getStatus() in their own function that checks each time their own function runs? I don't see why it has to keep checking

adamlui commented 1 year ago

This is a library of functions that users are meant to use in their own code to save typing, needs like retrieving status before coder does own stuff is satisfied by a single getStatus() definition

adamlui commented 1 year ago

Their benefit from using this library is to save typing, this is not like userscripts where it has to constantly monitor and do things with timer functions etc

mefengl commented 1 year ago

For eventEmitter, the user can write listener when it's idle, and finished.

That needs to store old status

There are also other ways to achieve this, such as observing dom change

adamlui commented 1 year ago

Can you give example how you would use this in your own script

adamlui commented 1 year ago

You seem to be telling me the ways I already achieve this in my scripts. But I would not expect a library to do this for me, because libraries are not designed to do that (think about jQuery, you use it to save typing)

adamlui commented 1 year ago

If I use chatgpt.js in my scripts, I would still write observers and use chatgpt.getStatus(), I'm not expecting or understanding how a lib would replace my need to write my own observer

mefengl commented 1 year ago

if so, then the status and eventEmitter part can be deleted, I maybe try to build another layer base on this repo

adamlui commented 1 year ago

For example, if I want my script to do something when bot is done typing, without lib, I monitor for the change in specific element. With a lib, I still have to monitor for that change, but I would look for a lib function that retrieves specified element in my own observer, then when it finally exists, my function can proceed.

mefengl commented 1 year ago

https://github.com/mefengl/chatgpt-twice/blob/master/script.js like in this code, I need to use setInterval to check, but if have a repo to do this for me, I can just write a listener for onDidGenerated

adamlui commented 1 year ago

if so, then the status and eventEmitter part can be deleted, I maybe try to build another layer base on this repo

That's a good idea and it can be the first use case of chatgpt.js

adamlui commented 1 year ago

https://github.com/mefengl/chatgpt-twice/blob/master/script.js like in this code, I need to use setInterval to check, but if have a repo to do this for me, I can just write a listener for onDidGenerated

For the URL mentioning this lib in the code, you should put chatgptjs.org

adamlui commented 1 year ago

But now I see how you use status check, I can come up with a solution but that will be after I rush to build a site with docs (requirement to launch on js.org)