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

Support uploading of text and pdf files and citations in the Claude API #485

Closed
Neurrone opened this issue Jan 24, 2025 · 1 comment · Fixed by #498
Closed

Support uploading of text and pdf files and citations in the Claude API #485

Neurrone opened this issue Jan 24, 2025 · 1 comment · Fixed by #498
Assignees

Comments

@Neurrone
Copy link

https://www.anthropic.com/news/introducing-citations-api

@AAClause
Copy link
Member

I've started working on this in #498.
You can test the current build here: https://github.com/SigmaNight/basiliskLLM/actions/runs/12979013600
Citations and custom content aren't supported yet, and I’m still wondering how to implement them.

AAClause added a commit that referenced this issue Feb 1, 2025
clementb49 added a commit that referenced this issue Feb 16, 2025
…citations to Anthropic (#498)

* refactor: support for multiple attachment types

- Refactored conversation tab to handle various attachment types instead of just images.
- Updated GUI labels and methods to reflect attachment handling.
- Implemented parsing of supported attachment formats for file dialog filters.
- Modified engine files to specify supported attachment formats per provider.

* feat(provider_engine): add support for uploading text and PDF files to Anthropic

Fixes #485

* fix(gui): add attachment details display on Enter key press

* chore(provider): add document capability

* feat(conversation_tab): add support for checking attachment formats

Enhanced the 'add_attachments' function to check if the attachment
format is supported by the current provider. If the format is not
supported, a message box is displayed to inform the user about the
unsupported format. This prevents adding unsupported attachment formats
and enhances user feedback.

* refactor(attached_file): remove redundant methods in ImageFile

* Update basilisk/conversation/attached_file.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* style(pre-commit.ci): auto fixes from pre-commit hooks

for more information, see https://pre-commit.ci

* Update basilisk/gui/conversation_tab.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update basilisk/conversation/attached_file.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: remove unused import

* fix(ollama_engine): adjust attachments handling / fixup previous merge commit

* chore(docs): fix indentation in docstring for `map_to_image_file_type()`

* fix: move location field logic in AttachmentFile class

* feat(anthropic_engine): add citation support in stream mode

- Added `citations` field to `Message` class in `conversation_model.py`.
- Implemented citation handling functions (`_handle_citations`, `get_current_citations`, `report_number_of_citations`, `show_citations`) in `conversation_tab.py`.
- Added 'Q' hotkey and context menu option for showing citations in the GUI.
- Extended `ProviderCapability` with `CITATION` for citation processing support.
- Updated `AnthropicEngine` to handle citation-related events in streaming completion responses.
- Enabled citation processing in document attachments for anthropic engine.

* feat(conversation_tab): add location column to attachments and fix copy functionality

- Added "Location" column in `attachments_list` to display attachment locations.
- Updated `on_copy_attachment_location` to copy attachment location.
- Removed unused method `get_dispay_images`.
- Made minor refactoring for clarity and consistency.

* feat(anthropic_engine): add citation support in non-stream mode

- Added `self.report_number_of_citations()` in `ConversationTab` to report the number of citations in the current message.
- Introduced a new private method `_handle_citation` in `AnthropicEngine` to process and handle citation data from API responses, improving modularity and reducing code duplication.
- Updated `completion_response_with_stream` to utilize the `_handle_citation` method for processing citations, simplifying the citation handling structure.
- Refactored `completion_response_without_stream` to collect and join text content, and process citations using the new helper method.

* docs(conversation_tab): revise docstrings to replace "image" with "attachment," reflecting support for multiple file types

* Update basilisk/provider_engine/base_engine.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Update basilisk/gui/conversation_tab.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* style(pre-commit.ci): auto fixes from pre-commit hooks

for more information, see https://pre-commit.ci

* fix(attached_file): correct _missing_ method for AttachmentFileTypes and update docstring

* refactor(attached_file): simplify MIME type retrieval in AttachmentFile

* chore: use the append method for list item

* chore(i18n): add translator comments for improved internationalization support

* refactor(conversation_tab): implement image attachment check method

* chore(anthropic_engine): add TODO comments for future enhancements

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: clementb49 <clement.boussiron@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants