Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: chat regenerate and proceed #26

Closed
wants to merge 6 commits into from
Closed

Conversation

Seidko
Copy link
Member

@Seidko Seidko commented Dec 9, 2022

implements #22

@Seidko Seidko linked an issue Dec 9, 2022 that may be closed by this pull request
@Seidko
Copy link
Member Author

Seidko commented Dec 9, 2022

The commands to trigger variant and continue are temporary now. If you have any ideas, please leave comments.

@Seidko Seidko requested a review from MaikoTan December 9, 2022 03:39
Copy link
Member

@MaikoTan MaikoTan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments

src/api.ts Outdated
@@ -46,13 +46,13 @@ class ChatGPT {
* @param message - The plaintext message to send.
* @param opts.conversationId - Optional ID of the previous message in a conversation
*/
async sendMessage(conversation: Conversation): Promise<Required<Conversation>> {
async sendMessage(conversation: Conversation, action: string): Promise<Required<Conversation>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
async sendMessage(conversation: Conversation, action: string): Promise<Required<Conversation>> {
async sendMessage(conversation: Conversation, action: 'next' | 'variant' | 'continue'): Promise<Required<Conversation>> {

Would be better for the typing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you can consider to put action into Conversation type as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary. Because I think conversation represents the context of the chat, and I don't think action is part of the chat context, so I put it in the parameters of sendMessage.

@@ -37,7 +37,7 @@ export const Config: Schema<Config> = Schema.intersect([
}),
])

const conversations = new Map<string, { messageId: string; conversationId: string }>()
const conversations = new Map<string, Conversation>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really good to use type Conversation here, as we don't save messages in the map.
If you stick with a type, you can split them into two types, but I argue with that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is your specific idea? My idea is to use the Conversation type here and save it in a Map. I can't think of any other idea at the moment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just to revert this type would be good to me.
Otherwise you should write something like:

export interface Conversation {
  messageId: string
  conversationId: string
}

export interface ConversationMessage extends Conversation {
  message: string
}

That would be much much redundant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how do I save the chat context, which is necessary in the implementation of variant?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or

Suggested change
const conversations = new Map<string, Conversation>()
const conversations = new Map<string, Omit<Conversation, 'message'>>()

while Omit is a built-in type of typescript.

src/index.ts Outdated Show resolved Hide resolved
src/index.ts Outdated Show resolved Hide resolved
@Seidko Seidko marked this pull request as draft December 9, 2022 08:28
@Seidko
Copy link
Member Author

Seidko commented Dec 9, 2022

The backend of OpenAI is really hard to deal with. 🤯

Copy link
Member

@MaikoTan MaikoTan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for hanging a long time before reply.
Is this PR still usable?

@@ -37,7 +37,7 @@ export const Config: Schema<Config> = Schema.intersect([
}),
])

const conversations = new Map<string, { messageId: string; conversationId: string }>()
const conversations = new Map<string, Conversation>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or

Suggested change
const conversations = new Map<string, Conversation>()
const conversations = new Map<string, Omit<Conversation, 'message'>>()

while Omit is a built-in type of typescript.

Comment on lines +101 to +102
let request: Conversation = conversations.get(key)
let action: ChatGPT.Action = input in actions ? actions[input] : 'next'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also always use const, unless you really really need to change it in runtime, otherwise keep it immutable.

@Seidko
Copy link
Member Author

Seidko commented Feb 1, 2023

Sorry 😂 I was concerned that ChatGPT might start charging in the future so I haven't planned to continue this PR. I don't know what Maiko thinks, I'd like to hear your opinion.

@MaikoTan
Copy link
Member

MaikoTan commented Feb 1, 2023

Maiko thinks that we should make it usable at least even with a subscription. So may you continue working on this?

@Seidko
Copy link
Member Author

Seidko commented Feb 1, 2023

Okay 🤣 I have to admit I'm a bit lazy to do it because the captcha is really annoying. I will try to continue this PR, but I don't sure whether I can make it well.

@Seidko
Copy link
Member Author

Seidko commented Mar 24, 2023

I want to completely refactor this plugin, so there is no need to keep this PR open, so I'm closing it now.

@Seidko Seidko closed this Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat: Support variant and continue
2 participants