bioguider 0.2.52__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bioguider/__init__.py +0 -0
- bioguider/agents/__init__.py +0 -0
- bioguider/agents/agent_task.py +92 -0
- bioguider/agents/agent_tools.py +176 -0
- bioguider/agents/agent_utils.py +504 -0
- bioguider/agents/collection_execute_step.py +182 -0
- bioguider/agents/collection_observe_step.py +125 -0
- bioguider/agents/collection_plan_step.py +156 -0
- bioguider/agents/collection_task.py +184 -0
- bioguider/agents/collection_task_utils.py +142 -0
- bioguider/agents/common_agent.py +137 -0
- bioguider/agents/common_agent_2step.py +215 -0
- bioguider/agents/common_conversation.py +61 -0
- bioguider/agents/common_step.py +85 -0
- bioguider/agents/consistency_collection_step.py +102 -0
- bioguider/agents/consistency_evaluation_task.py +57 -0
- bioguider/agents/consistency_evaluation_task_utils.py +14 -0
- bioguider/agents/consistency_observe_step.py +110 -0
- bioguider/agents/consistency_query_step.py +77 -0
- bioguider/agents/dockergeneration_execute_step.py +186 -0
- bioguider/agents/dockergeneration_observe_step.py +154 -0
- bioguider/agents/dockergeneration_plan_step.py +158 -0
- bioguider/agents/dockergeneration_task.py +158 -0
- bioguider/agents/dockergeneration_task_utils.py +220 -0
- bioguider/agents/evaluation_installation_task.py +270 -0
- bioguider/agents/evaluation_readme_task.py +767 -0
- bioguider/agents/evaluation_submission_requirements_task.py +172 -0
- bioguider/agents/evaluation_task.py +206 -0
- bioguider/agents/evaluation_tutorial_task.py +169 -0
- bioguider/agents/evaluation_tutorial_task_prompts.py +187 -0
- bioguider/agents/evaluation_userguide_prompts.py +179 -0
- bioguider/agents/evaluation_userguide_task.py +154 -0
- bioguider/agents/evaluation_utils.py +127 -0
- bioguider/agents/identification_execute_step.py +181 -0
- bioguider/agents/identification_observe_step.py +104 -0
- bioguider/agents/identification_plan_step.py +140 -0
- bioguider/agents/identification_task.py +270 -0
- bioguider/agents/identification_task_utils.py +22 -0
- bioguider/agents/peo_common_step.py +64 -0
- bioguider/agents/prompt_utils.py +253 -0
- bioguider/agents/python_ast_repl_tool.py +69 -0
- bioguider/agents/rag_collection_task.py +130 -0
- bioguider/conversation.py +67 -0
- bioguider/database/code_structure_db.py +500 -0
- bioguider/database/summarized_file_db.py +146 -0
- bioguider/generation/__init__.py +39 -0
- bioguider/generation/benchmark_metrics.py +610 -0
- bioguider/generation/change_planner.py +189 -0
- bioguider/generation/document_renderer.py +157 -0
- bioguider/generation/llm_cleaner.py +67 -0
- bioguider/generation/llm_content_generator.py +1128 -0
- bioguider/generation/llm_injector.py +809 -0
- bioguider/generation/models.py +85 -0
- bioguider/generation/output_manager.py +74 -0
- bioguider/generation/repo_reader.py +37 -0
- bioguider/generation/report_loader.py +166 -0
- bioguider/generation/style_analyzer.py +36 -0
- bioguider/generation/suggestion_extractor.py +436 -0
- bioguider/generation/test_metrics.py +189 -0
- bioguider/managers/benchmark_manager.py +785 -0
- bioguider/managers/evaluation_manager.py +215 -0
- bioguider/managers/generation_manager.py +686 -0
- bioguider/managers/generation_test_manager.py +107 -0
- bioguider/managers/generation_test_manager_v2.py +525 -0
- bioguider/rag/__init__.py +0 -0
- bioguider/rag/config.py +117 -0
- bioguider/rag/data_pipeline.py +651 -0
- bioguider/rag/embedder.py +24 -0
- bioguider/rag/rag.py +138 -0
- bioguider/settings.py +103 -0
- bioguider/utils/code_structure_builder.py +59 -0
- bioguider/utils/constants.py +135 -0
- bioguider/utils/default.gitignore +140 -0
- bioguider/utils/file_utils.py +215 -0
- bioguider/utils/gitignore_checker.py +175 -0
- bioguider/utils/notebook_utils.py +117 -0
- bioguider/utils/pyphen_utils.py +73 -0
- bioguider/utils/python_file_handler.py +65 -0
- bioguider/utils/r_file_handler.py +551 -0
- bioguider/utils/utils.py +163 -0
- bioguider-0.2.52.dist-info/LICENSE +21 -0
- bioguider-0.2.52.dist-info/METADATA +51 -0
- bioguider-0.2.52.dist-info/RECORD +84 -0
- bioguider-0.2.52.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
INDIVIDUAL_TUTORIAL_EVALUATION_SYSTEM_PROMPT = """
|
|
2
|
+
|
|
3
|
+
You are an expert in evaluating the quality of tutorials in software repositories.
|
|
4
|
+
Your task is to analyze the provided tutorial file and generate a structured quality assessment based on the following criteria.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### **Evaluation Criteria**
|
|
8
|
+
|
|
9
|
+
1. **Readability** AND **Error Detection**:
|
|
10
|
+
* **Flesch Reading Ease**: `{flesch_reading_ease}` (A higher score is better, with 60-70 being easily understood by most adults).
|
|
11
|
+
* **Flesch-Kincaid Grade Level**: `{flesch_kincaid_grade}` (Represents the US school-grade level needed to understand the text).
|
|
12
|
+
* **Gunning Fog Index**: `{gunning_fog_index}` (A score above 12 is generally considered too hard for most people).
|
|
13
|
+
* **SMOG Index**: `{smog_index}` (Estimates the years of education needed to understand the text).
|
|
14
|
+
* **Assessment**: Based on these scores, evaluate the overall readability and technical complexity of the language used.
|
|
15
|
+
* **CRITICAL - Error Detection**: You MUST scan for and identify ALL error INSTANCES (not just types):
|
|
16
|
+
- **Typos and spelling errors**: Misspelled words, truncated words (e.g., "analysi" → "analysis", "exampl" → "example")
|
|
17
|
+
* If the SAME typo appears multiple times, LIST EACH OCCURRENCE separately
|
|
18
|
+
- **Malformed links**: URLs missing colons (e.g., "https//..." should be "https://...")
|
|
19
|
+
* Check EVERY link/URL in the document
|
|
20
|
+
- **Markdown/RMarkdown syntax errors**:
|
|
21
|
+
* Missing code fence markers (e.g., missing opening ```)
|
|
22
|
+
* Headers without spaces
|
|
23
|
+
* Broken R chunk syntax (e.g., missing {{r or }})
|
|
24
|
+
* Check ALL code blocks and headers
|
|
25
|
+
- **Bio/domain term errors**: Wrong scientific terms (e.g., "single sell" → "single cell", "genomis" → "genomics")
|
|
26
|
+
* Pay special attention to biology/bioinformatics terminology
|
|
27
|
+
- **Function name errors**: Misspelled function/API names (e.g., "Dat()" → "Date()")
|
|
28
|
+
* Check ALL function calls in code blocks
|
|
29
|
+
- **Inline code formatting**: Missing backticks around code elements
|
|
30
|
+
* Check that all code references use proper backtick formatting
|
|
31
|
+
- **ANY OTHER ANOMALIES**: Trust your judgment - if something looks wrong, report it
|
|
32
|
+
* **IMPORTANT**: Report EVERY INDIVIDUAL ERROR INSTANCE
|
|
33
|
+
- If "analysi" appears 4 times, report it 4 times (with line references if possible)
|
|
34
|
+
- If 5 URLs are malformed, report all 5 individually
|
|
35
|
+
- Do NOT group similar errors - LIST EACH ONE SEPARATELY
|
|
36
|
+
- **NEVER use phrases like**: "multiple occurrences", "and elsewhere", "several instances"
|
|
37
|
+
- **INSTEAD**: List each occurrence as a separate numbered error
|
|
38
|
+
- **DO not** make up errors - only report errors that are actually present in the text
|
|
39
|
+
* **Grade Level** (based on TOTAL error instances, not types):
|
|
40
|
+
- **85-100**: The documentation is exceptionally clear, polished, engaging, and ERROR-FREE (0 errors).
|
|
41
|
+
- **65-84**: The documentation is clear with only minor errors (1-5 total error instances).
|
|
42
|
+
- **45-64**: The documentation has noticeable errors (6-15 total error instances).
|
|
43
|
+
- **0-44**: The documentation has numerous errors (16+ total error instances) making it unprofessional.
|
|
44
|
+
- **Note**: Count EVERY instance - if "analysi" appears 4 times, that's 4 errors, not 1.
|
|
45
|
+
|
|
46
|
+
2. **Coverage**:
|
|
47
|
+
* **Assessment**: [Your evaluation of whether it covers all major steps needed to get started, and dependencies, prerequisites, setup steps, and example usage.]
|
|
48
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
49
|
+
* **Original text:** [Quote a specific line/section from the tutorial.]
|
|
50
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
51
|
+
* **Grade Level**:
|
|
52
|
+
- **85-100**: The documentation covers all major steps needed to get started, and dependencies, prerequisites, setup steps, and example usage.
|
|
53
|
+
- **65-84**: The documentation covers most of the major steps needed to get started, and dependencies, prerequisites, setup steps, and example usage.
|
|
54
|
+
- **45-64**: The documentation covers some of the major steps needed to get started, and dependencies, prerequisites, setup steps, and example usage.
|
|
55
|
+
- **0-44**: The documentation does not cover any of the major steps needed to get started, and dependencies, prerequisites, setup steps, and example usage.
|
|
56
|
+
|
|
57
|
+
3. **Reproducibility**:
|
|
58
|
+
* **Assessment**: [Your evaluation of whether it provides a clear **description** of reproducibility]
|
|
59
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
60
|
+
* **Original text:** [Quote a specific line/section from the tutorial.]
|
|
61
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
62
|
+
* **Grade Level**:
|
|
63
|
+
- **85-100**: The documentation provides a clear and comprehensive guide to the tutorial, with all necessary steps and information provided.
|
|
64
|
+
- **65-84**: The documentation provides a clear and comprehensive guide to the tutorial, with most necessary steps and information provided.
|
|
65
|
+
- **45-64**: The documentation provides a clear and comprehensive guide to the tutorial, with some necessary steps and information provided.
|
|
66
|
+
- **0-44**: The documentation does not provide a clear and comprehensive guide to the tutorial, with no necessary steps and information provided.
|
|
67
|
+
|
|
68
|
+
4. **Structure & Navigation**:
|
|
69
|
+
* **Assessment**: [Your evaluation of whether it provides logical sections (e.g., intro -> setup -> steps -> results -> next), TOC/anchors, estimated time, etc.]
|
|
70
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
71
|
+
* **Original text:** [Quote a specific line/section from the tutorial.]
|
|
72
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
73
|
+
* **Grade Level**:
|
|
74
|
+
- **85-100**: The documentation provides a clear and comprehensive guide to the tutorial, with all necessary steps and information provided.
|
|
75
|
+
- **65-84**: The documentation provides a clear and comprehensive guide to the tutorial, with most necessary steps and information provided.
|
|
76
|
+
- **45-64**: The documentation provides a clear and comprehensive guide to the tutorial, with some necessary steps and information provided.
|
|
77
|
+
- **0-44**: The documentation does not provide a clear and comprehensive guide to the tutorial, with no necessary steps and information provided.
|
|
78
|
+
|
|
79
|
+
5. **Executable Code Quality**:
|
|
80
|
+
* **Assessment**: [Your evaluation on whether the code snippets are executable and functional, idiomatic, no hard-coded paths, etc.]
|
|
81
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
82
|
+
* **Original text:** [Quote a specific line/section from the tutorial.]
|
|
83
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
84
|
+
* **Grade Level**:
|
|
85
|
+
- **85-100**: The documentation provides a clear and comprehensive guide to the tutorial, with all necessary steps and information provided.
|
|
86
|
+
- **65-84**: The documentation provides a clear and comprehensive guide to the tutorial, with most necessary steps and information provided.
|
|
87
|
+
- **45-64**: The documentation provides a clear and comprehensive guide to the tutorial, with some necessary steps and information provided.
|
|
88
|
+
- **0-44**: The documentation does not provide a clear and comprehensive guide to the tutorial, with no necessary steps and information provided.
|
|
89
|
+
|
|
90
|
+
6. **Result Verification**:
|
|
91
|
+
* **Assessment**: [Your evaluation on expected outputs shown (figures/tables/metrics), acceptance criteria, etc.]
|
|
92
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
93
|
+
* **Original text:** [Quote a specific line/section from the tutorial.]
|
|
94
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
95
|
+
* **Grade Level**:
|
|
96
|
+
- **85-100**: The documentation provides a clear and comprehensive guide to the tutorial, with all necessary steps and information provided.
|
|
97
|
+
- **65-84**: The documentation provides a clear and comprehensive guide to the tutorial, with most necessary steps and information provided.
|
|
98
|
+
- **45-64**: The documentation provides a clear and comprehensive guide to the tutorial, with some necessary steps and information provided.
|
|
99
|
+
- **0-44**: The documentation does not provide a clear and comprehensive guide to the tutorial, with no necessary steps and information provided.
|
|
100
|
+
|
|
101
|
+
7. **Performance & Resource Notes**:
|
|
102
|
+
* **Assessment**: [Your evaluation on performance and resource notes, e.g., CPU/GPU usage, memory usage, runtime estimates, small "lite" path provided.]
|
|
103
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
104
|
+
* **Original text:** [Quote a specific line/section from the tutorial.]
|
|
105
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
106
|
+
* **Grade Level**:
|
|
107
|
+
- **85-100**: The documentation provides a clear and comprehensive guide to the tutorial, with all necessary steps and information provided.
|
|
108
|
+
- **65-84**: The documentation provides a clear and comprehensive guide to the tutorial, with most necessary steps and information provided.
|
|
109
|
+
- **45-64**: The documentation provides a clear and comprehensive guide to the tutorial, with some necessary steps and information provided.
|
|
110
|
+
- **0-44**: The documentation does not provide a clear and comprehensive guide to the tutorial, with no necessary steps and information provided.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### **Final Report Ouput**
|
|
115
|
+
Your final report must **exactly match** the following format. Do not add or omit any sections.
|
|
116
|
+
|
|
117
|
+
**FinalAnswer**
|
|
118
|
+
* **Overall Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
119
|
+
* **Overall Key Strengths**: <brief summary of the Tutorial's strongest points in 2-3 sentences>
|
|
120
|
+
|
|
121
|
+
* **Readability Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
122
|
+
* **Readability Error Count:** [TOTAL number of error INSTANCES found - count each occurrence]
|
|
123
|
+
* **Readability Errors Found:** [List of ALL individual error instances]
|
|
124
|
+
- **CRITICAL**: List EVERY INDIVIDUAL ERROR INSTANCE (not grouped)
|
|
125
|
+
- **WRONG EXAMPLE** (Do NOT do this):
|
|
126
|
+
❌ "TYPO: 'analysi' → 'analysis' - appears in multiple locations"
|
|
127
|
+
❌ "LINKS: Several URLs missing colons"
|
|
128
|
+
- **CORRECT EXAMPLE** (Do this instead):
|
|
129
|
+
✅ "TYPO: 'analysi' → 'analysis' - in section 'Perform DE analysi...'"
|
|
130
|
+
✅ "TYPO: 'analysi' → 'analysis' - in paragraph 'The analysi shows...'"
|
|
131
|
+
✅ "TYPO: 'analysi' → 'analysis' - in code comment 'Run analysi...'"
|
|
132
|
+
✅ "TYPO: 'analysi' → 'analysis' - in heading 'Results of analysi'"
|
|
133
|
+
✅ "LINK: 'https//www.nature.com/articles/nbt.4042' → 'https://www.nature.com/articles/nbt.4042'"
|
|
134
|
+
✅ "LINK: 'https//github.com/satijalab/seurat-data' → 'https://github.com/satijalab/seurat-data'"
|
|
135
|
+
|
|
136
|
+
**Format for each error** (list them ALL individually):
|
|
137
|
+
- **Typos**: "original misspelled text" → "corrected text" (location/context)
|
|
138
|
+
- **Links**: Complete URL → Fixed URL (one entry per link)
|
|
139
|
+
- **Markdown/RMarkdown**: "syntax error" → "correct syntax" (specific location)
|
|
140
|
+
- **Bio terms**: "wrong term" → "correct term" (where it appears)
|
|
141
|
+
- **Function names**: "misspelled function" → "correct function" (which code block)
|
|
142
|
+
- **Inline code**: "missing backticks around X" → "add backticks" (specific variable/function)
|
|
143
|
+
- **Other issues**: describe and provide corrections
|
|
144
|
+
- General readability improvements (sentence structure, clarity, etc.)
|
|
145
|
+
|
|
146
|
+
**Remember**: Each error instance = one separate entry in Readability Errors Found list
|
|
147
|
+
* **Readability Suggestions:** [General non-error readability improvements like sentence structure, clarity, etc.]
|
|
148
|
+
|
|
149
|
+
* **Coverage Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
150
|
+
* **Coverage Improvement Suggestions:** please be as specific as possible.
|
|
151
|
+
- "Original text snippet 1" - Improving comment 1
|
|
152
|
+
- "Original text snippet 2" - Improving comment 2
|
|
153
|
+
- ...
|
|
154
|
+
* **Reproducibility Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
155
|
+
* **Reproducibility Improvement Suggestions:** please be as specific as possible.
|
|
156
|
+
- "Original text snippet 1" - Improving comment 1
|
|
157
|
+
- "Original text snippet 2" - Improving comment 2
|
|
158
|
+
- ...
|
|
159
|
+
* **Structure & Navigation Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
160
|
+
* **Structure & Navigation Improvement Suggestions:** please be as specific as possible.
|
|
161
|
+
- "Original text snippet 1" - Improving comment 1
|
|
162
|
+
- "Original text snippet 2" - Improving comment 2
|
|
163
|
+
- ...
|
|
164
|
+
* **Executable Code Quality Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
165
|
+
* **Executable Code Quality Improvement Suggestions:** please be as specific as possible.
|
|
166
|
+
- "Original text snippet 1" - Improving comment 1
|
|
167
|
+
- "Original text snippet 2" - Improving comment 2
|
|
168
|
+
- ...
|
|
169
|
+
* **Result Verification Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
170
|
+
* **Result Verification Improvement Suggestions:** please be as specific as possible.
|
|
171
|
+
- "Original text snippet 1" - Improving comment 1
|
|
172
|
+
- "Original text snippet 2" - Improving comment 2
|
|
173
|
+
- ...
|
|
174
|
+
* **Performance & Resource Notes Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
175
|
+
* **Performance & Resource Notes Improvement Suggestions:** please be as specific as possible.
|
|
176
|
+
- "Original text snippet 1" - Improving comment 1
|
|
177
|
+
- "Original text snippet 2" - Improving comment 2
|
|
178
|
+
- ...
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### **Tutorial File Content:**
|
|
183
|
+
{tutorial_file_content}
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
"""
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
|
|
2
|
+
INDIVIDUAL_USERGUIDE_EVALUATION_SYSTEM_PROMPT = """
|
|
3
|
+
You are an expert in evaluating the quality of user guide in software repositories.
|
|
4
|
+
Your task is to analyze the provided files related to user guide and generate a structured quality assessment based on the following criteria.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
### **Evaluation Criteria**
|
|
8
|
+
|
|
9
|
+
1. **Readability** AND **Error Detection**:
|
|
10
|
+
* **Flesch Reading Ease**: `{flesch_reading_ease}` (A higher score is better, with 60-70 being easily understood by most adults).
|
|
11
|
+
* **Flesch-Kincaid Grade Level**: `{flesch_kincaid_grade}` (Represents the US school-grade level needed to understand the text).
|
|
12
|
+
* **Gunning Fog Index**: `{gunning_fog_index}` (A score above 12 is generally considered too hard for most people).
|
|
13
|
+
* **SMOG Index**: `{smog_index}` (Estimates the years of education needed to understand the text).
|
|
14
|
+
* **Assessment**: Based on these scores, evaluate the overall readability and technical complexity of the language used.
|
|
15
|
+
* **CRITICAL - Error Detection**: You MUST scan for and identify ALL error INSTANCES (not just types):
|
|
16
|
+
- **Typos and spelling errors**: Misspelled words, truncated words (e.g., "analysi" → "analysis", "exampl" → "example")
|
|
17
|
+
* If the SAME typo appears multiple times, LIST EACH OCCURRENCE separately
|
|
18
|
+
- **Malformed links**: URLs missing colons (e.g., "https//..." should be "https://...")
|
|
19
|
+
* Check EVERY link/URL in the document
|
|
20
|
+
- **Markdown/RMarkdown syntax errors**:
|
|
21
|
+
* Missing code fence markers (e.g., missing opening ```)
|
|
22
|
+
* Headers without spaces
|
|
23
|
+
* Broken R chunk syntax (e.g., missing {{r or }})
|
|
24
|
+
* Check ALL code blocks and headers
|
|
25
|
+
- **Bio/domain term errors**: Wrong scientific terms (e.g., "single sell" → "single cell", "genomis" → "genomics")
|
|
26
|
+
* Pay special attention to biology/bioinformatics terminology
|
|
27
|
+
- **Function name errors**: Misspelled function/API names (e.g., "Dat()" → "Date()")
|
|
28
|
+
* Check ALL function calls in code blocks
|
|
29
|
+
- **Inline code formatting**: Missing backticks around code elements
|
|
30
|
+
* Check that all code references use proper backtick formatting
|
|
31
|
+
- **ANY OTHER ANOMALIES**: Trust your judgment - if something looks wrong, report it
|
|
32
|
+
* **IMPORTANT**: Report EVERY INDIVIDUAL ERROR INSTANCE
|
|
33
|
+
- If "analysi" appears 4 times, report it 4 times (with line references if possible)
|
|
34
|
+
- If 5 URLs are malformed, report all 5 individually
|
|
35
|
+
- Do NOT group similar errors - LIST EACH ONE SEPARATELY
|
|
36
|
+
- **NEVER use phrases like**: "multiple occurrences", "and elsewhere", "several instances"
|
|
37
|
+
- **INSTEAD**: List each occurrence as a separate numbered error
|
|
38
|
+
- **DO not** make up errors - only report errors that are actually present in the text
|
|
39
|
+
* **Grade Level**:
|
|
40
|
+
- **85-100**: The user guide is exceptionally clear, polished, and engaging. It reads smoothly, with minimal effort required from the reader.
|
|
41
|
+
- **65-84**: The user guide is clear and easy to understand, with a natural flow and minimal jargon.
|
|
42
|
+
- **45-64**: The user guide is somewhat clear, but could benefit from more polish and consistency.
|
|
43
|
+
- **0-44**: The user guide is difficult to understand, with unclear language, jargon, or overly complex sentences.
|
|
44
|
+
|
|
45
|
+
2. **Arguments and Clarity**:
|
|
46
|
+
* **Assessment**: [Your evaluation of whether it provides a clear **description** of arguments and their usage]
|
|
47
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
48
|
+
* **Original text:** [Quote a specific line/section from the user guide.]
|
|
49
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
50
|
+
* **Grade Level**:
|
|
51
|
+
- **85-100**: The user guide provides a clear and comprehensive guide to the user guide, with all necessary steps and information provided.
|
|
52
|
+
- **65-84**: The user guide provides a clear and comprehensive guide to the user guide, with most necessary steps and information provided.
|
|
53
|
+
- **45-64**: The user guide provides a clear and comprehensive guide to the user guide, with some necessary steps and information provided.
|
|
54
|
+
- **0-44**: The user guide does not provide a clear and comprehensive guide to the user guide, with no necessary steps and information provided.
|
|
55
|
+
|
|
56
|
+
3. **Return Value and Clarity**:
|
|
57
|
+
* **Assessment**: [Your evaluation of whether it provides a clear **description** of return value and its meaning]
|
|
58
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
59
|
+
* **Original text:** [Quote a specific line/section from the user guide.]
|
|
60
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
61
|
+
* **Grade Level**:
|
|
62
|
+
- **85-100**: The user guide provides a clear and comprehensive guide to the user guide, with all necessary steps and information provided.
|
|
63
|
+
- **65-84**: The user guide provides a clear and comprehensive guide to the user guide, with most necessary steps and information provided.
|
|
64
|
+
- **45-64**: The user guide provides a clear and comprehensive guide to the user guide, with some necessary steps and information provided.
|
|
65
|
+
- **0-44**: The user guide does not provide a clear and comprehensive guide to the user guide, with no necessary steps and information provided.
|
|
66
|
+
|
|
67
|
+
4. **Context and Purpose**:
|
|
68
|
+
* **Assessment**: [Your evaluation of whether it provides a clear **description** of the context and purpose of the module]
|
|
69
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
70
|
+
* **Original text:** [Quote a specific line/section from the user guide.]
|
|
71
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
72
|
+
* **Grade Level**:
|
|
73
|
+
- **85-100**: The user guide provides a clear and comprehensive guide to the user guide, with all necessary steps and information provided.
|
|
74
|
+
- **65-84**: The user guide provides a clear and comprehensive guide to the user guide, with most necessary steps and information provided.
|
|
75
|
+
- **45-64**: The user guide provides a clear and comprehensive guide to the user guide, with some necessary steps and information provided.
|
|
76
|
+
- **0-44**: The user guide does not provide a clear and comprehensive guide to the user guide, with no necessary steps and information provided.
|
|
77
|
+
|
|
78
|
+
5. **Error Handling**:
|
|
79
|
+
* **Assessment**: [Your evaluation of whether it provides a clear **description** of error handling]
|
|
80
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
81
|
+
* **Original text:** [Quote a specific line/section from the user guide.]
|
|
82
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
83
|
+
* **Grade Level**:
|
|
84
|
+
- **85-100**: The user guide provides a clear and comprehensive guide to the user guide, with all necessary steps and information provided.
|
|
85
|
+
- **65-84**: The user guide provides a clear and comprehensive guide to the user guide, with most necessary steps and information provided.
|
|
86
|
+
- **45-64**: The user guide provides a clear and comprehensive guide to the user guide, with some necessary steps and information provided.
|
|
87
|
+
- **0-44**: The user guide does not provide a clear and comprehensive guide to the user guide, with no necessary steps and information provided.
|
|
88
|
+
|
|
89
|
+
6. **Usage Examples**:
|
|
90
|
+
* **Assessment**: [Your evaluation of whether it provides a clear **description** of usage examples]
|
|
91
|
+
* **Improvement Suggestions**: please be as specific as possible.
|
|
92
|
+
* **Original text:** [Quote a specific line/section from the user guide.]
|
|
93
|
+
* **Improving comments:** [Provide your suggestions to improve clarity.]
|
|
94
|
+
* **Grade Level**:
|
|
95
|
+
- **85-100**: The user guide provides a clear and comprehensive guide to the user guide, with all necessary steps and information provided.
|
|
96
|
+
- **65-84**: The user guide provides a clear and comprehensive guide to the user guide, with most necessary steps and information provided.
|
|
97
|
+
- **45-64**: The user guide provides a clear and comprehensive guide to the user guide, with some necessary steps and information provided.
|
|
98
|
+
- **0-44**: The user guide does not provide a clear and comprehensive guide to the user guide, with no necessary steps and information provided.
|
|
99
|
+
|
|
100
|
+
7. **Overall Score**: Give an overall quality rating of the User Guide information.
|
|
101
|
+
* Output: `0-44`, `45-64`, `65-84`, or `85-100`
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### **Final Report Ouput**
|
|
106
|
+
Your final report must **exactly match** the following format. Do not add or omit any sections.
|
|
107
|
+
|
|
108
|
+
**FinalAnswer**
|
|
109
|
+
* **Overall Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
110
|
+
* **Overall Key Strengths**: <brief summary of the User Guide's strongest points in 2-3 sentences>
|
|
111
|
+
|
|
112
|
+
* **Readability Analysis Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
113
|
+
* **Readability Error Count:** [TOTAL number of error INSTANCES found - count each occurrence]
|
|
114
|
+
* **Readability Errors Found:** [List of ALL individual error instances]
|
|
115
|
+
- **CRITICAL**: List EVERY INDIVIDUAL ERROR INSTANCE (not grouped)
|
|
116
|
+
- **WRONG EXAMPLE** (Do NOT do this):
|
|
117
|
+
❌ "TYPO: 'analysi' → 'analysis' - appears in multiple locations"
|
|
118
|
+
❌ "LINKS: Several URLs missing colons"
|
|
119
|
+
- **CORRECT EXAMPLE** (Do this instead):
|
|
120
|
+
✅ "TYPO: 'analysi' → 'analysis' - in section 'Perform DE analysi...'"
|
|
121
|
+
✅ "TYPO: 'analysi' → 'analysis' - in paragraph 'The analysi shows...'"
|
|
122
|
+
✅ "TYPO: 'analysi' → 'analysis' - in code comment 'Run analysi...'"
|
|
123
|
+
✅ "TYPO: 'analysi' → 'analysis' - in heading 'Results of analysi'"
|
|
124
|
+
✅ "LINK: 'https//www.nature.com/articles/nbt.4042' → 'https://www.nature.com/articles/nbt.4042'"
|
|
125
|
+
✅ "LINK: 'https//github.com/satijalab/seurat-data' → 'https://github.com/satijalab/seurat-data'"
|
|
126
|
+
|
|
127
|
+
**Format for each error** (list them ALL individually):
|
|
128
|
+
- **Typos**: "original misspelled text" → "corrected text" (location/context)
|
|
129
|
+
- **Links**: Complete URL → Fixed URL (one entry per link)
|
|
130
|
+
- **Markdown/RMarkdown**: "syntax error" → "correct syntax" (specific location)
|
|
131
|
+
- **Bio terms**: "wrong term" → "correct term" (where it appears)
|
|
132
|
+
- **Function names**: "misspelled function" → "correct function" (which code block)
|
|
133
|
+
- **Inline code**: "missing backticks around X" → "add backticks" (specific variable/function)
|
|
134
|
+
- **Other issues**: describe and provide corrections
|
|
135
|
+
- General readability improvements (sentence structure, clarity, etc.)
|
|
136
|
+
|
|
137
|
+
**Remember**: Each error instance = one separate entry in Readability Errors Found list
|
|
138
|
+
* **Readability Suggestions:** [General non-error readability improvements like sentence structure, clarity, etc.]
|
|
139
|
+
* **Arguments and Clarity Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
140
|
+
* **Arguments and Clarity Key Strengths**: <brief summary of the User Guide's strongest points in 2-3 sentences>
|
|
141
|
+
* **Arguments and Clarity Improvement Suggestions:** please be as specific as possible.
|
|
142
|
+
- "Original text snippet 1" - Improving comment 1
|
|
143
|
+
- "Original text snippet 2" - Improving comment 2
|
|
144
|
+
- ...
|
|
145
|
+
* **Return Value and Clarity Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
146
|
+
* **Return Value and Clarity Key Strengths**: <brief summary of the User Guide's strongest points in 2-3 sentences>
|
|
147
|
+
* **Return Value and Clarity Improvement Suggestions:** please be as specific as possible.
|
|
148
|
+
- "Original text snippet 1" - Improving comment 1
|
|
149
|
+
- "Original text snippet 2" - Improving comment 2
|
|
150
|
+
- ...
|
|
151
|
+
* **Context and Purpose Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
152
|
+
* **Context and Purpose Key Strengths**: <brief summary of the User Guide's strongest points in 2-3 sentences>
|
|
153
|
+
* **Context and Purpose Improvement Suggestions:** please be as specific as possible.
|
|
154
|
+
- "Original text snippet 1" - Improving comment 1
|
|
155
|
+
- "Original text snippet 2" - Improving comment 2
|
|
156
|
+
- ...
|
|
157
|
+
* **Error Handling Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
158
|
+
* **Error Handling Key Strengths**: <brief summary of the User Guide's strongest points in 2-3 sentences>
|
|
159
|
+
* **Error Handling Improvement Suggestions:** please be as specific as possible.
|
|
160
|
+
- "Original text snippet 1" - Improving comment 1
|
|
161
|
+
- "Original text snippet 2" - Improving comment 2
|
|
162
|
+
- ...
|
|
163
|
+
* **Usage Examples Score:** [a number between 0 and 100 representing the overall quality rating.]
|
|
164
|
+
* **Usage Examples Key Strengths**: <brief summary of the User Guide's strongest points in 2-3 sentences>
|
|
165
|
+
* **Usage Examples Improvement Suggestions:** please be as specific as possible.
|
|
166
|
+
- "Original text snippet 1" - Improving comment 1
|
|
167
|
+
- "Original text snippet 2" - Improving comment 2
|
|
168
|
+
- ...
|
|
169
|
+
...
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### **User Guide Content:**
|
|
174
|
+
{userguide_content}
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
"""
|
|
179
|
+
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import logging
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from langchain.prompts import ChatPromptTemplate
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from bioguider.agents.collection_task import CollectionTask
|
|
9
|
+
from bioguider.agents.consistency_evaluation_task import ConsistencyEvaluationResult
|
|
10
|
+
from bioguider.agents.prompt_utils import CollectionGoalItemEnum
|
|
11
|
+
from bioguider.utils.constants import (
|
|
12
|
+
DEFAULT_TOKEN_USAGE,
|
|
13
|
+
)
|
|
14
|
+
from bioguider.utils.file_utils import flatten_files
|
|
15
|
+
from .evaluation_utils import (
|
|
16
|
+
compute_readability_metrics,
|
|
17
|
+
default_consistency_result,
|
|
18
|
+
evaluate_consistency_on_content,
|
|
19
|
+
normalize_evaluation_content,
|
|
20
|
+
run_llm_evaluation,
|
|
21
|
+
sanitize_files,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
from .evaluation_task import EvaluationTask
|
|
25
|
+
from bioguider.utils.utils import get_overall_score, increase_token_usage
|
|
26
|
+
from .evaluation_userguide_prompts import INDIVIDUAL_USERGUIDE_EVALUATION_SYSTEM_PROMPT
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class UserGuideEvaluationResult(BaseModel):
|
|
30
|
+
overall_score: int=Field(description="A number between 0 and 100 representing the overall quality rating.")
|
|
31
|
+
overall_key_strengths: str=Field(description="A string value, the key strengths of the user guide")
|
|
32
|
+
|
|
33
|
+
readability_score: int=Field(description="A number between 0 and 100 representing the readability quality rating.")
|
|
34
|
+
readability_error_count: Optional[int]=Field(default=0, description="Total number of ERROR INSTANCES found (count every occurrence, not types)")
|
|
35
|
+
readability_errors_found: list[str]=Field(default_factory=list, description="List of ALL individual error instances with format: 'ERROR_TYPE: original → corrected - location'")
|
|
36
|
+
readability_suggestions: list[str]=Field(description="A list of string values, suggestions to improve readability if necessary")
|
|
37
|
+
context_and_purpose_score: int=Field(description="A number between 0 and 100 representing the context and purpose quality rating.")
|
|
38
|
+
context_and_purpose_suggestions: list[str]=Field(description="A list of string values, suggestions to improve context and purpose if necessary")
|
|
39
|
+
error_handling_score: int=Field(description="A number between 0 and 100 representing the error handling quality rating.")
|
|
40
|
+
error_handling_suggestions: list[str]=Field(description="A list of string values, suggestions to improve error handling if necessary")
|
|
41
|
+
|
|
42
|
+
class IndividualUserGuideEvaluationResult(BaseModel):
|
|
43
|
+
user_guide_evaluation: UserGuideEvaluationResult | None=Field(description="The evaluation result of the user guide")
|
|
44
|
+
consistency_evaluation: ConsistencyEvaluationResult | None=Field(description="The evaluation result of the consistency of the user guide")
|
|
45
|
+
|
|
46
|
+
logger = logging.getLogger(__name__)
|
|
47
|
+
|
|
48
|
+
MAX_FILE_SIZE = 1024 * 100 # 100K
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class EvaluationUserGuideTask(EvaluationTask):
|
|
52
|
+
def __init__(
|
|
53
|
+
self,
|
|
54
|
+
llm,
|
|
55
|
+
repo_path,
|
|
56
|
+
gitignore_path,
|
|
57
|
+
meta_data = None,
|
|
58
|
+
step_callback = None,
|
|
59
|
+
summarized_files_db = None,
|
|
60
|
+
code_structure_db = None,
|
|
61
|
+
collected_files: list[str] | None = None,
|
|
62
|
+
):
|
|
63
|
+
super().__init__(llm, repo_path, gitignore_path, meta_data, step_callback, summarized_files_db)
|
|
64
|
+
self.evaluation_name = "User Guide Evaluation"
|
|
65
|
+
self.code_structure_db = code_structure_db
|
|
66
|
+
self.collected_files = collected_files
|
|
67
|
+
|
|
68
|
+
def _collect_files(self):
|
|
69
|
+
if self.collected_files is not None:
|
|
70
|
+
return self.collected_files
|
|
71
|
+
|
|
72
|
+
task = CollectionTask(
|
|
73
|
+
llm=self.llm,
|
|
74
|
+
step_callback=self.step_callback,
|
|
75
|
+
summarized_files_db=self.summarized_files_db,
|
|
76
|
+
)
|
|
77
|
+
task.compile(
|
|
78
|
+
repo_path=self.repo_path,
|
|
79
|
+
gitignore_path=Path(self.repo_path, ".gitignore"),
|
|
80
|
+
goal_item=CollectionGoalItemEnum.UserGuide.name,
|
|
81
|
+
)
|
|
82
|
+
files = task.collect()
|
|
83
|
+
files = flatten_files(self.repo_path, files)
|
|
84
|
+
files = sanitize_files(self.repo_path, files, max_size_bytes=MAX_FILE_SIZE)
|
|
85
|
+
return files
|
|
86
|
+
|
|
87
|
+
def _evaluate_individual_userguide(self, file: str) -> tuple[IndividualUserGuideEvaluationResult | None, dict]:
|
|
88
|
+
content, readability_content = normalize_evaluation_content(
|
|
89
|
+
self.repo_path, file
|
|
90
|
+
)
|
|
91
|
+
if content is None or readability_content is None:
|
|
92
|
+
logger.error(f"Error in reading file {file}")
|
|
93
|
+
return None, {**DEFAULT_TOKEN_USAGE}
|
|
94
|
+
|
|
95
|
+
# evaluate general criteria
|
|
96
|
+
flesch_reading_ease, flesch_kincaid_grade, gunning_fog_index, smog_index = \
|
|
97
|
+
compute_readability_metrics(readability_content)
|
|
98
|
+
system_prompt = ChatPromptTemplate.from_template(
|
|
99
|
+
INDIVIDUAL_USERGUIDE_EVALUATION_SYSTEM_PROMPT
|
|
100
|
+
).format(
|
|
101
|
+
flesch_reading_ease=flesch_reading_ease,
|
|
102
|
+
flesch_kincaid_grade=flesch_kincaid_grade,
|
|
103
|
+
gunning_fog_index=gunning_fog_index,
|
|
104
|
+
smog_index=smog_index,
|
|
105
|
+
userguide_content=readability_content,
|
|
106
|
+
)
|
|
107
|
+
res, token_usage, reasoning_process = run_llm_evaluation(
|
|
108
|
+
llm=self.llm,
|
|
109
|
+
system_prompt=system_prompt,
|
|
110
|
+
instruction_prompt="Now, let's begin the user guide/API documentation evaluation.",
|
|
111
|
+
schema=UserGuideEvaluationResult,
|
|
112
|
+
)
|
|
113
|
+
res: UserGuideEvaluationResult = res
|
|
114
|
+
|
|
115
|
+
# evaluate consistency
|
|
116
|
+
consistency_evaluation_result, _temp_token_usage = evaluate_consistency_on_content(
|
|
117
|
+
llm=self.llm,
|
|
118
|
+
code_structure_db=self.code_structure_db,
|
|
119
|
+
step_callback=self.step_callback,
|
|
120
|
+
domain="user guide/API",
|
|
121
|
+
content=content,
|
|
122
|
+
)
|
|
123
|
+
if consistency_evaluation_result is None:
|
|
124
|
+
# No sufficient information to evaluate the consistency of the user guide/API documentation
|
|
125
|
+
consistency_evaluation_result = default_consistency_result("user guide/API")
|
|
126
|
+
|
|
127
|
+
# calculate overall score
|
|
128
|
+
res.overall_score = get_overall_score(
|
|
129
|
+
[
|
|
130
|
+
consistency_evaluation_result.score,
|
|
131
|
+
res.readability_score,
|
|
132
|
+
res.context_and_purpose_score,
|
|
133
|
+
res.error_handling_score,
|
|
134
|
+
],
|
|
135
|
+
[2, 1, 1, 1],
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
return IndividualUserGuideEvaluationResult(
|
|
139
|
+
user_guide_evaluation=res,
|
|
140
|
+
consistency_evaluation=consistency_evaluation_result,
|
|
141
|
+
), token_usage
|
|
142
|
+
|
|
143
|
+
def _evaluate(self, files: list[str] | None = None) -> tuple[dict[str, IndividualUserGuideEvaluationResult] | None, dict, list[str]]:
|
|
144
|
+
total_token_usage = {**DEFAULT_TOKEN_USAGE}
|
|
145
|
+
user_guide_evaluation_results = {}
|
|
146
|
+
files = flatten_files(self.repo_path, files)
|
|
147
|
+
for file in files:
|
|
148
|
+
if file.endswith(".py") or file.endswith(".R"):
|
|
149
|
+
continue
|
|
150
|
+
user_guide_evaluation_result, token_usage = self._evaluate_individual_userguide(file)
|
|
151
|
+
total_token_usage = increase_token_usage(total_token_usage, token_usage)
|
|
152
|
+
user_guide_evaluation_results[file] = user_guide_evaluation_result
|
|
153
|
+
|
|
154
|
+
return user_guide_evaluation_results, total_token_usage, files
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Iterable, Tuple
|
|
4
|
+
|
|
5
|
+
from bioguider.agents.agent_utils import read_file
|
|
6
|
+
from bioguider.agents.consistency_evaluation_task import (
|
|
7
|
+
ConsistencyEvaluationResult,
|
|
8
|
+
ConsistencyEvaluationTask,
|
|
9
|
+
)
|
|
10
|
+
from bioguider.utils.constants import DEFAULT_TOKEN_USAGE
|
|
11
|
+
from bioguider.utils.file_utils import detect_file_type
|
|
12
|
+
from bioguider.utils.notebook_utils import (
|
|
13
|
+
extract_markdown_from_notebook,
|
|
14
|
+
strip_notebook_to_code_and_markdown,
|
|
15
|
+
)
|
|
16
|
+
from bioguider.utils.pyphen_utils import PyphenReadability
|
|
17
|
+
from bioguider.utils.utils import convert_html_to_text
|
|
18
|
+
from .common_agent_2step import CommonAgentTwoChainSteps, CommonAgentTwoSteps
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _escape_template_braces(text: str) -> str:
|
|
22
|
+
return text.replace("{", "<<").replace("}", ">>")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def sanitize_files(
|
|
26
|
+
repo_path: str,
|
|
27
|
+
files: Iterable[str],
|
|
28
|
+
max_size_bytes: int,
|
|
29
|
+
disallowed_exts: set[str] | None = None,
|
|
30
|
+
check_ipynb_size: bool = False,
|
|
31
|
+
) -> list[str]:
|
|
32
|
+
sanitized_files: list[str] = []
|
|
33
|
+
for file in files:
|
|
34
|
+
file_path = Path(repo_path, file)
|
|
35
|
+
if not file_path.exists() or not file_path.is_file():
|
|
36
|
+
continue
|
|
37
|
+
if detect_file_type(file_path) == "binary":
|
|
38
|
+
continue
|
|
39
|
+
if disallowed_exts and file_path.suffix.lower() in disallowed_exts:
|
|
40
|
+
continue
|
|
41
|
+
if file_path.suffix.lower() != ".ipynb" or check_ipynb_size:
|
|
42
|
+
if file_path.stat().st_size > max_size_bytes:
|
|
43
|
+
continue
|
|
44
|
+
sanitized_files.append(file)
|
|
45
|
+
return sanitized_files
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def normalize_evaluation_content(
|
|
49
|
+
repo_path: str,
|
|
50
|
+
file: str,
|
|
51
|
+
) -> Tuple[str | None, str | None]:
|
|
52
|
+
file_path = Path(repo_path, file)
|
|
53
|
+
content = read_file(file_path)
|
|
54
|
+
if content is None:
|
|
55
|
+
return None, None
|
|
56
|
+
|
|
57
|
+
suffix = file_path.suffix.lower()
|
|
58
|
+
if suffix == ".ipynb":
|
|
59
|
+
readability_content = extract_markdown_from_notebook(file_path)
|
|
60
|
+
content = json.dumps(strip_notebook_to_code_and_markdown(file_path))
|
|
61
|
+
content = _escape_template_braces(content)
|
|
62
|
+
return content, readability_content
|
|
63
|
+
|
|
64
|
+
if suffix in {".html", ".htm"}:
|
|
65
|
+
readability_content = convert_html_to_text(file_path)
|
|
66
|
+
content = _escape_template_braces(readability_content)
|
|
67
|
+
return content, readability_content
|
|
68
|
+
|
|
69
|
+
return content, content
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def compute_readability_metrics(
|
|
73
|
+
content: str,
|
|
74
|
+
) -> Tuple[float, float, float, float]:
|
|
75
|
+
readability = PyphenReadability()
|
|
76
|
+
flesch_reading_ease, flesch_kincaid_grade, gunning_fog_index, smog_index, \
|
|
77
|
+
_, _, _, _, _ = readability.readability_metrics(content)
|
|
78
|
+
return flesch_reading_ease, flesch_kincaid_grade, gunning_fog_index, smog_index
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def evaluate_consistency_on_content(
|
|
82
|
+
llm,
|
|
83
|
+
code_structure_db,
|
|
84
|
+
step_callback,
|
|
85
|
+
domain: str,
|
|
86
|
+
content: str,
|
|
87
|
+
) -> Tuple[ConsistencyEvaluationResult | None, dict]:
|
|
88
|
+
if code_structure_db is None:
|
|
89
|
+
return None, {**DEFAULT_TOKEN_USAGE}
|
|
90
|
+
consistency_evaluation_task = ConsistencyEvaluationTask(
|
|
91
|
+
llm=llm,
|
|
92
|
+
code_structure_db=code_structure_db,
|
|
93
|
+
step_callback=step_callback,
|
|
94
|
+
)
|
|
95
|
+
return (
|
|
96
|
+
consistency_evaluation_task.evaluate(
|
|
97
|
+
domain=domain,
|
|
98
|
+
documentation=content,
|
|
99
|
+
),
|
|
100
|
+
{**DEFAULT_TOKEN_USAGE},
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def run_llm_evaluation(
|
|
105
|
+
llm,
|
|
106
|
+
system_prompt: str,
|
|
107
|
+
instruction_prompt: str,
|
|
108
|
+
schema,
|
|
109
|
+
chain: bool = False,
|
|
110
|
+
) -> Tuple[object, dict, str | None]:
|
|
111
|
+
agent_cls = CommonAgentTwoChainSteps if chain else CommonAgentTwoSteps
|
|
112
|
+
agent = agent_cls(llm=llm)
|
|
113
|
+
res, _processed, token_usage, reasoning_process = agent.go(
|
|
114
|
+
system_prompt=system_prompt,
|
|
115
|
+
instruction_prompt=instruction_prompt,
|
|
116
|
+
schema=schema,
|
|
117
|
+
)
|
|
118
|
+
return res, token_usage, reasoning_process
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def default_consistency_result(domain_label: str) -> ConsistencyEvaluationResult:
|
|
122
|
+
return ConsistencyEvaluationResult(
|
|
123
|
+
score=0,
|
|
124
|
+
assessment=f"No sufficient information to evaluate the consistency of the {domain_label} documentation",
|
|
125
|
+
development=[],
|
|
126
|
+
strengths=[],
|
|
127
|
+
)
|