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

Image handling is currently broken #156

Merged
merged 8 commits into from
Aug 13, 2024
Merged

Image handling is currently broken #156

merged 8 commits into from
Aug 13, 2024

Conversation

jaresty
Copy link
Collaborator

@jaresty jaresty commented Aug 12, 2024

  • When you fetch the image source it formats the messages
  • If you try to extract them as text at that point, images will not be processed at all
  • In order to process images you have to keep the messages intact from source extraction through to insertion

- When you fetch the image source it formats the messages
- If you try to extract them as text at that point, images will not be processed at all
- In order to process images you have to keep the messages intact from source extraction through to insertion
@@ -138,27 +138,22 @@ def gpt_apply_prompt(prompt: str, source: str = "", destination: str = ""):

text_to_process: GPTMessageItem = actions.user.gpt_get_source_text(source)

# If after creating the message there wasn't anything in the text_to_process, set it to None so
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This check was blocking images from being processed

@@ -212,72 +207,75 @@ def gpt_insert_response(
# Skip inserting the response if the user is just viewing the thread in the window
actions.user.confirmation_gui_refresh_thread()

message_text_no_images = extract_message(gpt_message)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Extract message currently returns text so if there's an image here it will return an empty string

@@ -40,6 +40,11 @@ def disable_thread(cls):
@classmethod
def push_context(cls, context: GPTMessageItem):
"""Add the selected text to the stored context"""
if context.get("type") != "text":
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This ensures that images don't get inserted into the system messages since that would cause an error

- since only some destination support images, it makes sense to handle them in a separate case
- this will now print an error message of someone tries to 'pass clip to window' with an image in their clipboard
GPT/gpt.py Outdated Show resolved Hide resolved
Copy link
Owner

@C-Loftus C-Loftus left a comment

Choose a reason for hiding this comment

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

Made two quick edits. If the user wanted to append to the thread, we want to refresh the GUI. The gui refresh function won't do anything if it is closed so its fine either way.

thanks for help cleaning this up

@jaresty jaresty merged commit afb96b2 into main Aug 13, 2024
5 checks passed
@jaresty jaresty deleted the fix-image-bugs branch August 13, 2024 01:07
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.

2 participants