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

Iris: Change Pyris response type #7352

Closed
wants to merge 3 commits into from

Conversation

MichaelOwenDyer
Copy link
Contributor

@MichaelOwenDyer MichaelOwenDyer commented Oct 10, 2023

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) database calls.
  • I followed the coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I added pre-authorization annotations according to the guidelines and checked the course groups for all new REST Calls (security).
  • I documented the Java code using JavaDoc style.

Client

No client changes

Motivation and Context

Up until now, Pyris and Artemis have been unnecessarily coupled, in that Pyris' responses were always of the type IrisMessage, and Artemis would always deserialize them as such. However, this is an inflexible approach, as it only allows for one single AI-generated variable to be returned per call to Pyris, always the one named "response". This is inflexible. Guidance templates can have an arbitrary number of generations, and it is desirable behavior that you are also able to receive all of these generated values back from Pyris. Therefore I have adapted both Pyris and Artemis to communicate in more general types, while maintaining the current use-case of only having one response.

Note: This change depends on Pyris sending the updated response type as well! This will not work with the current deployment of Pyris.
See corresponding Pyris PR: ls1intum/Pyris#34

Description

  • Updated the structure of IrisMessageResponseDTO. Instead of an IrisMessage it now contains a JsonNode content which represents an arbitrary content response from Pyris, for instance a list of JSON objects (which is very possible to generate with a guidance template).
  • Added a method in IrisChatSessionService and IrisHestiaSessionService to reconstruct this arbitrary JSON into an IrisMessage for the existing use-case. The method for Hestia is identical, but @Hialus has said this is dead code anyway and will be changed in the future in one of his PRs. For now it is just there for compilation.
  • Adapted the test cases correspondingly

Steps for Testing

Prerequisites:

  1. Log in to Artemis
  2. Navigate to the exercise
  3. Make sure Iris still responds like normal to your chat input

Review Progress

Performance Review

  • I (as a reviewer) confirm that the client changes (in particular related to REST calls and UI responsiveness) are implemented with a very good performance
  • I (as a reviewer) confirm that the server changes (in particular related to database calls) are implemented with a very good performance

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Exam Mode Test

  • Test 1
  • Test 2

Test Coverage

Screenshots

@MichaelOwenDyer MichaelOwenDyer requested a review from a team as a code owner October 10, 2023 16:48
@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) labels Oct 10, 2023
Copy link
Member

@Hialus Hialus left a comment

Choose a reason for hiding this comment

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

Code looks mostly good. I just found one possible edge case that could cause problems.

Comment on lines 11 to 16
/**
* Create a new IrisMessageResponseDTO. Jackson uses this constructor to create the object.
* This is necessary because Jackson was not throwing an exception when the response from Iris did not contain
* the expected fields, which resulted in a NullPointerException when trying to access the fields.
* Not sure if this is a bug in Jackson or if it is intended behavior, either way this is a workaround.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Could you maybe mention your findings in the next dev meeting? Especially DTOs should be validated by Jackson, so maybe we can find a better solution, as your way kinda defeats the simpleness of records.

@krusche krusche deleted the fix/iris-response-type branch April 22, 2024 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Pull requests that update Java code. (Added Automatically!) tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants