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

Chatgpt as realtime stream response ? #14

Open
eix128 opened this issue May 17, 2023 · 4 comments
Open

Chatgpt as realtime stream response ? #14

eix128 opened this issue May 17, 2023 · 4 comments

Comments

@eix128
Copy link

eix128 commented May 17, 2023

Hi , how can i get ChatGPT realtime response like on openai website.
This api awaits for response so much long time.

And how can i get current session id of webrequest ?
I mean i ask many questions on 1 session.

@Barqawiz
Copy link
Collaborator

I am going to create a new project item to address your first point to support streaming.

The second point. it is not clear but please open another issue for it with clarification as will assign this issue to streaming development.

@eix128
Copy link
Author

eix128 commented Jun 21, 2023

Well , i mean when i ask a question to chatgpt , it will initiate a session.
So when i ask second question , it also gets the first questions data.

Example :

I entered first my error :

Me:
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table egitmen_dersler drop foreign key FKsnhnfh73svhpbno5xa5sqb4l3" via JDBC Statement

Chatgpt :
The exception you are encountering, org.hibernate.tool.schema.spi.CommandAcceptanceException, indicates an error occurred while executing a Data Definition Language (DDL) statement via a JDBC statement in Hibernate. Specifically, the error message suggests that there was a problem with executing the following DDL statement:

Me:
how to solve the issue on jpa side ?

Chatgpt:

To solve the issue on the JPA side, you can try the following steps:

Verify the entity mappings: Ensure that the JPA entity associated with the table egitmen_dersler has the correct mapping for the foreign key relationship. Make sure that the @joincolumn or @jointable annotations are correctly specified, matching the foreign key constraint name FKsnhnfh73svhpbno5xa5sqb4l3.

Check the cascade options: If there are cascading relationships defined in the entity mappings, review the cascade options to ensure they are appropriate for your use case. If necessary, adjust the cascade options to match your desired behavior when deleting or updating related entities.

If i directly pass 2nd question to chatgpt as webservice , it doesnt know which issue i have.
So i need some way to pass session like data to webservice.So it will answer to second related question.

So we need something like session or chat initialization.

@Barqawiz
Copy link
Collaborator

Barqawiz commented Jun 21, 2023

Openai backend does not support the session id, but you can send the messages history as part of the call. This way the model will be aware of the ongoing conversation.

Example:

This is the way to initiate the first conversaion:

Chatbot bot = new Chatbot(openaiKey, SupportedChatModels.openai);
String mode = "You are a helpful astronomy assistant.";
ChatModelInput input = new ChatGPTInput.Builder(mode).addUserMessage("what is the space between moon and earth").build();
// the model responses
List<String> resValues =  bot.chat(input);

You can add the model response to the history, then add your new message:

input.addMessage(new ChatGPTMessage("<replace with the model response>", "assistant"))
input.addUserMessage("<replace with your new message>")

Now when you send the input to the chatbot, it will be aware of the conversation history:

List<String> resValues =  bot.chat(input);

@eix128
Copy link
Author

eix128 commented Sep 29, 2023

you can checkout this library:
https://github.com/Grt1228/chatgpt-java
but its chinese.
It would be good if we can add this to this library.
It supports plugins use and stream

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

No branches or pull requests

2 participants