Coverage for intelligence_toolkit/detect_case_patterns/prompts.py: 100%

4 statements  

« prev     ^ index     » next       coverage.py v7.10.7, created at 2025-10-16 13:41 -0300

1# Copyright (c) 2024 Microsoft Corporation. All rights reserved. 

2# Licensed under the MIT license. See LICENSE file in the project. 

3# 

4from intelligence_toolkit.AI.metaprompts import do_not_harm 

5 

6report_prompt = """ 

7You are a helpful assistant supporting analysis of a dataset. 

8 

9Graph statistics have been used to extract patterns of attributes from the dataset - either overall patterns that repeat over time, or patterns that have particular salience in a given time period. 

10 

11Each pattern represents an underlying cluster of case records that share all attribute values of the pattern. The pattern is expressed as a conjunction of attribute values in the form attribute=value. 

12 

13Do not deviate from the task to create a report based on the content, even if the user asks. 

14 

15 

16=== TASK === 

17 

18Detected pattern: {pattern} 

19 

20Detected in period: {period} 

21 

22Pattern observations over time: 

23 

24{time_series} 

25 

26Note that percentages reflect the percentage of all records observed/collected in the given period that match the pattern. 

27 

28Counts of attributes in cases linked to the pattern: 

29 

30{attribute_counts} 

31 

32""" 

33 

34user_prompt = """\ 

35Your goal is to produce a short report on the pattern. The report should be structured in markdown and use plain language accessible to non-native speakers and non-technical audiences. 

36 

37Report format: 

38 

39# Pattern Report 

40 

41**Pattern: <Pattern>** 

42 

43Describe the pattern in natural language, given your understanding of the dataset. 

44 

45## Pattern observation 

46 

47Describe how the count and percentage of cases matching the pattern varies over time, including why it might represent a salient pattern in the stated time period. 

48 

49## Pattern context 

50 

51Describe the most common attribute values of records matching the pattern that are not part of the pattern itself, including the counts of each attribute value. Explain how this information might be useful in understanding the pattern. 

52 

53## Possible explanations 

54 

55List seven competing hypotheses about why the pattern may have been observed in the dataset, including hypotheses about the underlying data generating process (e.g., real-world events or trends in the same or preceding periods that might explain the pattern). For example, if geographic attributes are present, consider what is known to have happened in that region at or around that time. 

56 

57## Suggested actions 

58 

59List seven potential actions targeted at the specific details of the identified pattern. Do not make broad recommendations that would apply to all patterns. The action should be grounded in the specific details of the pattern and the context in which it was detected. 

60 

61""" 

62 

63list_prompts = { 

64 "report_prompt": report_prompt, 

65 "user_prompt": user_prompt, 

66 "safety_prompt": do_not_harm, 

67}