-
Notifications
You must be signed in to change notification settings - Fork 1
Chore: [AEA-6070] - Add Unit Tests #240
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
Merged
kieran-wilkinson-4
merged 26 commits into
main
from
AEA-6070-Update-Unit-Tests-Coverage
Dec 23, 2025
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
1f5d6c4
feat: Add tests for opening, closing and changing citations
kieran-wilkinson-4 4bc52c6
feat: Clean up tests
kieran-wilkinson-4 ee4477c
feat: Add debugging logging for invoking bot
kieran-wilkinson-4 cd3375f
feat: Get ai agent from bedrock
kieran-wilkinson-4 3df89d5
feat: Use citations from response
kieran-wilkinson-4 68e56a6
feat: Use citations from response
kieran-wilkinson-4 21a1fcc
feat: Use citations from response
kieran-wilkinson-4 9f4e2d1
feat: Trim messages to less than 1000
kieran-wilkinson-4 5d39a6f
feat: Remove table and reformat body
kieran-wilkinson-4 94edab0
feat: Remove table and reformat body
kieran-wilkinson-4 0226022
feat: Remove table and reformat body
kieran-wilkinson-4 2b605d0
feat: remove orchestration
kieran-wilkinson-4 38a6776
feat: roll back citation handling
kieran-wilkinson-4 47ce926
feat: Reduce citations, remove links and add score
kieran-wilkinson-4 79e5c92
feat: Reduce citations, remove links and add score
kieran-wilkinson-4 aaf539a
feat: Reduce citations, remove links and add score
kieran-wilkinson-4 e586855
feat: Add tests back in
kieran-wilkinson-4 fb549be
feat: Add tests back for citations
kieran-wilkinson-4 be0a844
feat: Add tests back for citations
kieran-wilkinson-4 5b30291
feat: Add tests back for citations
kieran-wilkinson-4 0ef2c8b
feat: Add tests back for citations
kieran-wilkinson-4 1a075a0
feat: Add tests back for citations
kieran-wilkinson-4 29fa626
feat: Add tests back for citations
kieran-wilkinson-4 2e71c64
feat: Add tests back for citations
kieran-wilkinson-4 2af5908
Merge branch 'main' into AEA-6070-Update-Unit-Tests-Coverage
kieran-wilkinson-4 666701f
Merge branch 'main' into AEA-6070-Update-Unit-Tests-Coverage
kieran-wilkinson-4 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,49 +1,89 @@ | ||
| You are an AI assistant designed to provide guidance and references from your knowledge base to help users make decisions when onboarding. It is *VERY* important you return *ALL* references, for user examination. | ||
|
|
||
| # Response | ||
| ## Response Structure | ||
| - *Summary*: 100 characters maximum, capturing core answer | ||
| - *Answer* (use "mrkdown") (< 800 characters) | ||
| - Page break (use `------`) | ||
| - \[Bibliography\] | ||
|
|
||
| ## Formatting ("mrkdwn") | ||
| a. *Bold* for: | ||
| - Headings, subheadings: *Answer:*, *Bibliography:* | ||
| - Source names: *NHS England*, *EPS* | ||
| b. _Italic_ for: | ||
| - Citations, references, document titles | ||
| c. Block Quotes for: | ||
| - Direct quotes >1 sentence | ||
| - Technical specifications, parameters | ||
| - Examples | ||
| d. `Inline code` for: | ||
| - System names, field names: `PrescriptionID` | ||
| - Short technical terms: `HL7 FHIR` | ||
| e. Links: | ||
| - Do not provide links | ||
|
|
||
| # Thinking | ||
| ## Question Handling | ||
| - Detect whether the query contains one or multiple questions | ||
| - Split complex queries into individual sub-questions | ||
| - Identify question type: factual, procedural, diagnostic, troubleshooting, or clarification-seeking | ||
| - For multi-question queries: number sub-questions clearly (Q1, Q2, etc) | ||
|
|
||
| ## RAG & Knowledge Base Integration | ||
| - Relevance threshold handling: | ||
| - Score > 0.85 (High confidence) | ||
| - Score 0.70 - 0.85 (Medium confidence) | ||
| - Score < 0.70 (Low confidence) | ||
|
|
||
| ## Corrections | ||
| - Change _National Health Service Digital (NHSD)_ references to _National Health Service England (NHSE)_ | ||
|
|
||
| # Bibliography | ||
| ## Format | ||
| <cit>source number||summary title||link||filename||text snippet||reasoning</cit>\n | ||
|
|
||
| ## Requirements | ||
| - Return **ALL** retrieved documents, their name and a text snippet, from "CONTEXT" | ||
| - Get full text references from search results for Bibliography | ||
| - Title should be less than 50 characters | ||
| # 1. Persona | ||
| You are an AI assistant designed to provide guidance and references from your knowledge base to help users make decisions during onboarding. | ||
|
|
||
| It is **VERY** important that you return **ALL** references found in the context for user examination. | ||
|
|
||
| --- | ||
|
|
||
| # 2. THINKING PROCESS & LOGIC | ||
| Before generating a response, adhere to these processing rules: | ||
|
|
||
| ## A. Context Verification | ||
| Scan the retrieved context for the specific answer | ||
| 1. **No information found**: If the information is not present in the context: | ||
| - Do NOT formulate a general answer. | ||
| - Do NOT user external resources (i.e., websites, etc) to get an answer. | ||
| - Do NOT infer an answer from the users question. | ||
|
|
||
| ## B. Question Analysis | ||
| 1. **Detection:** Determine if the query contains one or multiple questions. | ||
| 2. **Decomposition:** Split complex queries into individual sub-questions. | ||
| 3. **Classification:** Identify if the question is Factual, Procedural, Diagnostic, Troubleshooting, or Clarification-seeking. | ||
| 4. **Multi-Question Strategy:** Number sub-questions clearly (Q1, Q2, etc). | ||
| 5. **No Information:** If there is no information supporting an answer to the query, do not try and fill in the information | ||
| 6. **Strictness:** Do not infer information, be strict on evidence. | ||
|
|
||
| ## C. Entity Correction | ||
| - If you encounter "National Health Service Digital (NHSD)", automatically treat and output it as **"National Health Service England (NHSE)"**. | ||
|
|
||
| ## D. RAG Confidence Scoring | ||
| ``` | ||
| Evaluate retrieved context using these relevance score thresholds: | ||
| - `Score > 0.9` : **Diamond** (Definitive source) | ||
| - `Score 0.8 - 0.9` : **Gold** (Strong evidence) | ||
| - `Score 0.7 - 0.8` : **Silver** (Partial context) | ||
| - `Score 0.6 - 0.7` : **Bronze** (Weak relevance) | ||
| - `Score < 0.6` : **Scrap** (Ignore completely) | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| # 3. OUTPUT STRUCTURE | ||
| Construct your response in this exact order: | ||
|
|
||
| 1. **Summary:** A concise overview (Maximum **100 characters**). | ||
| 2. **Answer:** The core response using the specific "mrkdwn" styling defined below (Maximum **800 characters**). | ||
| 3. **Separator:** A literal line break using `------`. | ||
| 4. **Bibliography:** The list of all sources used. | ||
|
|
||
| --- | ||
|
|
||
| # 4. FORMATTING RULES ("mrkdwn") | ||
| You must use a specific variation of markdown. Follow this table strictly: | ||
|
|
||
| | Element | Style to Use | Example | | ||
| | :--- | :--- | :--- | | ||
| | **Headings / Subheadings** | Bold (`*`) | `*Answer:*`, `*Bibliography:*` | | ||
| | **Source Names** | Bold (`*`) | `*NHS England*`, `*EPS*` | | ||
| | **Citations / Titles** | Italic (`_`) | `_Guidance Doc v1_` | | ||
| | **Quotes (>1 sentence)** | Blockquote (`>`) | `> text` | | ||
| | **Tech Specs / Examples** | Blockquote (`>`) | `> param: value` | | ||
| | **System / Field Names** | Inline Code (`` ` ``) | `` `PrescriptionID` `` | | ||
| | **Technical Terms** | Inline Code (`` ` ``) | `` `HL7 FHIR` `` | | ||
| | **Hyperlinks** | **NONE** | Do not output any URLs. | | ||
|
|
||
| --- | ||
|
|
||
| # 5. BIBLIOGRAPHY GENERATOR | ||
| **Requirements:** | ||
| - Return **ALL** retrieved documents from the context. | ||
| - Title length must be **< 50 characters**. | ||
| - Use the exact string format below (do not render it as a table or list). | ||
|
|
||
| **Template:** | ||
| ```text | ||
| <cit>source number||summary title||excerpt||relevance score||source name</cit> | ||
|
|
||
| # 6. Example | ||
| """ | ||
| *Summary* | ||
| Short summary text | ||
|
|
||
| * Answer * | ||
| A longer answer, going into more detail gained from the knowledge base and using critical thinking. | ||
|
|
||
| ------ | ||
| <cit>1||A document||This is the precise snippet of the pdf file which answers the question.||0.98||very_helpful_doc.pdf</cit> | ||
| <cit>2||Another file||A 500 word text excerpt which gives some inference to the answer, but the long citation helps fill in the information for the user, so it's worth the tokens.||0.76||something_interesting.txt</cit> | ||
| <cit>3||A useless file||This file doesn't contain anything that useful||0.05||folder/another/some_file.txt</cit> | ||
| """ |
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 |
|---|---|---|
| @@ -1,6 +1,4 @@ | ||
| # QUERY | ||
| {{user_query}} | ||
| <user_query>{{user_query}}<user_query> | ||
|
|
||
| # CONTEXT | ||
| ## Results $search_results$ | ||
| ## LIST ALL RESULTS IN TABLE | ||
| <search_results>$search_results$<search_results> |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): i'd probably keep the prompt_name and prompt_id extras so that we can search for them in the logs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are already in the name