-
Notifications
You must be signed in to change notification settings - Fork 8
Iris: Automatically switch the context of an active conversation
#701
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
Open
Senan04
wants to merge
14
commits into
main
Choose a base branch
from
feature/iris/automatic-context-switching
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b1f3f39
Add suggested context field to chat status updates
Senan04 8eb06f9
Track a pending context switch on the pipeline execution state
Senan04 718ccaa
Add switch_chat_context tool for agent-initiated context switches
Senan04 860cca6
Instruct the agent to switch context in the chat system prompt
Senan04 9923f18
Merge branch 'main' into feature/iris/automatic-context-switching
Senan04 1f8f62b
Add lectures field to CourseDTO
Senan04 19f6bf9
Add lecture list tool for identifying lectures by ID
Senan04 0056617
Scope lecture content retrieval to lecture after context switch
Senan04 869a22c
Validate lecture ID when switching chat context to a lecture
Senan04 9d3ae67
Update chat system prompt for the lecture list tool
Senan04 b528f7c
Cover lecture retrieval scope after a lecture context switch
Senan04 a1060f5
Merge branch 'main' into feature/iris/automatic-context-switching
Senan04 c1a790a
fix(iris): allow lecture list tool without indexed lecture content
Senan04 a44805a
test(iris): add unit tests for lecture list tool availability and gating
Senan04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| from pydantic import BaseModel, ConfigDict, Field | ||
|
|
||
| from iris.pipeline.chat.iris_chat_mode import IrisChatMode | ||
|
|
||
|
|
||
| class SuggestedContextDTO(BaseModel): | ||
| """Context switch requested by the agent during a chat run. | ||
|
|
||
| Carried on the final result status update so Artemis can move the | ||
| session's active context to the entity the student asked about. | ||
| The mode values serialize to the Artemis IrisChatMode enum names. | ||
| """ | ||
|
|
||
| model_config = ConfigDict(populate_by_name=True) | ||
|
|
||
| mode: IrisChatMode | ||
| entity_id: int = Field(alias="entityId") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| """Tool that lists the lectures of the course together with their IDs. | ||
|
|
||
| Lecture content retrieval stays scoped to the active lecture and reports | ||
| lecture names only, so it cannot supply the ID a context switch needs. This | ||
| tool provides the course-wide name to ID mapping instead. | ||
| """ | ||
|
|
||
| from typing import Callable, List, Optional | ||
|
|
||
| from ..domain.data.lecture_dto import PyrisLectureDTO | ||
| from ..web.status.status_update import StatusCallback | ||
|
|
||
|
|
||
| def create_tool_get_lecture_list( | ||
| lectures: Optional[List[PyrisLectureDTO]], callback: StatusCallback | ||
| ) -> Callable[[], List[dict]]: | ||
| """ | ||
| Create a tool that lists the lectures of the course. | ||
|
|
||
| Args: | ||
| lectures: Lectures of the course as sent by Artemis. | ||
| callback: Callback for status updates. | ||
|
|
||
| Returns: | ||
| Callable[[], List[dict]]: Function that returns the list of lectures. | ||
| """ | ||
| del callback | ||
|
|
||
| def get_lecture_list() -> list[dict]: | ||
| """ | ||
| Get the list of lectures in the course, each with its lecture ID, its | ||
| name and the names of its lecture units. | ||
| Use this to find the ID of a lecture, for example before switching the | ||
| chat context to another lecture. Lecture content retrieval only returns | ||
| content of the currently active lecture and never returns lecture IDs, | ||
| so this is the only way to identify another lecture. | ||
| The list covers every lecture of the course; lecture units that are not | ||
| yet released to students are omitted. | ||
|
|
||
| Returns: | ||
| list[dict]: Lecture ID, lecture name and lecture unit names per lecture. | ||
| """ | ||
| return [ | ||
| { | ||
| "lecture_id": lecture.id, | ||
| "lecture_name": lecture.title, | ||
| "lecture_unit_names": [unit.name for unit in lecture.units], | ||
| } | ||
| for lecture in lectures or [] | ||
| ] | ||
|
|
||
| return get_lecture_list |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.