mrmd-ai 0.1.0__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.
@@ -0,0 +1,41 @@
1
+ """Document-level AI modules."""
2
+
3
+ import dspy
4
+ from ..signatures.document import (
5
+ DocumentResponseSignature,
6
+ DocumentSummarySignature,
7
+ DocumentAnalysisSignature,
8
+ )
9
+
10
+
11
+ class DocumentResponsePredict(dspy.Module):
12
+ """Generate a response to the document (document as prompt)."""
13
+
14
+ def __init__(self):
15
+ super().__init__()
16
+ self.predict = dspy.Predict(DocumentResponseSignature)
17
+
18
+ def forward(self, document: str):
19
+ return self.predict(document=document)
20
+
21
+
22
+ class DocumentSummaryPredict(dspy.Module):
23
+ """Summarize a document."""
24
+
25
+ def __init__(self):
26
+ super().__init__()
27
+ self.predict = dspy.Predict(DocumentSummarySignature)
28
+
29
+ def forward(self, document: str):
30
+ return self.predict(document=document)
31
+
32
+
33
+ class DocumentAnalysisPredict(dspy.Module):
34
+ """Analyze a document."""
35
+
36
+ def __init__(self):
37
+ super().__init__()
38
+ self.predict = dspy.Predict(DocumentAnalysisSignature)
39
+
40
+ def forward(self, document: str, analysis_type: str = "general"):
41
+ return self.predict(document=document, analysis_type=analysis_type)
@@ -0,0 +1,95 @@
1
+ """Finish/completion modules - complete sentences, paragraphs, and code."""
2
+
3
+ import dspy
4
+ from typing import Optional
5
+
6
+ from mrmd_ai.signatures.finish import (
7
+ FinishSentenceSignature,
8
+ FinishParagraphSignature,
9
+ FinishCodeLineSignature,
10
+ FinishCodeSectionSignature,
11
+ )
12
+
13
+
14
+ class FinishSentencePredict(dspy.Module):
15
+ """Complete the current sentence naturally."""
16
+
17
+ def __init__(self):
18
+ super().__init__()
19
+ self.predictor = dspy.Predict(FinishSentenceSignature)
20
+
21
+ def forward(
22
+ self,
23
+ text_before_cursor: str,
24
+ local_context: str,
25
+ document_context: Optional[str] = None,
26
+ ) -> dspy.Prediction:
27
+ return self.predictor(
28
+ document_context=document_context,
29
+ local_context=local_context,
30
+ text_before_cursor=text_before_cursor,
31
+ )
32
+
33
+
34
+ class FinishParagraphPredict(dspy.Module):
35
+ """Complete the current paragraph naturally."""
36
+
37
+ def __init__(self):
38
+ super().__init__()
39
+ self.predictor = dspy.Predict(FinishParagraphSignature)
40
+
41
+ def forward(
42
+ self,
43
+ text_before_cursor: str,
44
+ local_context: str,
45
+ document_context: Optional[str] = None,
46
+ ) -> dspy.Prediction:
47
+ return self.predictor(
48
+ document_context=document_context,
49
+ local_context=local_context,
50
+ text_before_cursor=text_before_cursor,
51
+ )
52
+
53
+
54
+ class FinishCodeLinePredict(dspy.Module):
55
+ """Complete the current line of code."""
56
+
57
+ def __init__(self):
58
+ super().__init__()
59
+ self.predictor = dspy.Predict(FinishCodeLineSignature)
60
+
61
+ def forward(
62
+ self,
63
+ code_before_cursor: str,
64
+ language: str,
65
+ local_context: str,
66
+ document_context: Optional[str] = None,
67
+ ) -> dspy.Prediction:
68
+ return self.predictor(
69
+ document_context=document_context,
70
+ local_context=local_context,
71
+ code_before_cursor=code_before_cursor,
72
+ language=language,
73
+ )
74
+
75
+
76
+ class FinishCodeSectionPredict(dspy.Module):
77
+ """Complete the current code section (function, class, block)."""
78
+
79
+ def __init__(self):
80
+ super().__init__()
81
+ self.predictor = dspy.Predict(FinishCodeSectionSignature)
82
+
83
+ def forward(
84
+ self,
85
+ code_before_cursor: str,
86
+ language: str,
87
+ local_context: str,
88
+ document_context: Optional[str] = None,
89
+ ) -> dspy.Prediction:
90
+ return self.predictor(
91
+ document_context=document_context,
92
+ local_context=local_context,
93
+ code_before_cursor=code_before_cursor,
94
+ language=language,
95
+ )
mrmd_ai/modules/fix.py ADDED
@@ -0,0 +1,52 @@
1
+ """Fix modules - grammar and transcription correction."""
2
+
3
+ import dspy
4
+ from typing import Optional
5
+
6
+ from mrmd_ai.signatures.fix import (
7
+ FixGrammarSignature,
8
+ FixTranscriptionSignature,
9
+ )
10
+
11
+
12
+ class FixGrammarPredict(dspy.Module):
13
+ """Fix grammar, spelling, and punctuation errors."""
14
+
15
+ def __init__(self):
16
+ super().__init__()
17
+ self.predictor = dspy.Predict(FixGrammarSignature)
18
+
19
+ def forward(
20
+ self,
21
+ text_to_fix: str,
22
+ local_context: str,
23
+ document_context: Optional[str] = None,
24
+ ) -> dspy.Prediction:
25
+ print(f"[FixGrammar] Input: {repr(text_to_fix[:100])}", flush=True)
26
+ result = self.predictor(
27
+ document_context=document_context,
28
+ local_context=local_context,
29
+ text_to_fix=text_to_fix,
30
+ )
31
+ print(f"[FixGrammar] Output: {repr(result.fixed_text[:100] if hasattr(result, 'fixed_text') else 'NO fixed_text')}", flush=True)
32
+ return result
33
+
34
+
35
+ class FixTranscriptionPredict(dspy.Module):
36
+ """Fix speech-to-text transcription errors."""
37
+
38
+ def __init__(self):
39
+ super().__init__()
40
+ self.predictor = dspy.Predict(FixTranscriptionSignature)
41
+
42
+ def forward(
43
+ self,
44
+ text_to_fix: str,
45
+ local_context: str,
46
+ document_context: Optional[str] = None,
47
+ ) -> dspy.Prediction:
48
+ return self.predictor(
49
+ document_context=document_context,
50
+ local_context=local_context,
51
+ text_to_fix=text_to_fix,
52
+ )
@@ -0,0 +1,15 @@
1
+ """Notebook-related AI modules."""
2
+
3
+ import dspy
4
+ from ..signatures.notebook import NotebookNameSignature
5
+
6
+
7
+ class NotebookNamePredict(dspy.Module):
8
+ """Generate a descriptive name for a notebook based on its content."""
9
+
10
+ def __init__(self):
11
+ super().__init__()
12
+ self.predict = dspy.Predict(NotebookNameSignature)
13
+
14
+ def forward(self, document: str, current_name: str = "Untitled"):
15
+ return self.predict(document=document, current_name=current_name)
@@ -0,0 +1,69 @@
1
+ """Text transformation modules."""
2
+
3
+ import dspy
4
+ from ..signatures.text import (
5
+ GetSynonymsSignature,
6
+ GetPhraseSynonymsSignature,
7
+ ReformatMarkdownSignature,
8
+ IdentifyReplacementSignature,
9
+ )
10
+
11
+
12
+ class GetSynonymsPredict(dspy.Module):
13
+ """Find synonyms for a single word."""
14
+
15
+ def __init__(self):
16
+ super().__init__()
17
+ self.predict = dspy.Predict(GetSynonymsSignature)
18
+
19
+ def forward(self, text: str, local_context: str, document_context: str = None):
20
+ return self.predict(
21
+ text=text,
22
+ local_context=local_context,
23
+ document_context=document_context,
24
+ )
25
+
26
+
27
+ class GetPhraseSynonymsPredict(dspy.Module):
28
+ """Find alternative phrases for multi-word expressions."""
29
+
30
+ def __init__(self):
31
+ super().__init__()
32
+ self.predict = dspy.Predict(GetPhraseSynonymsSignature)
33
+
34
+ def forward(self, phrase: str, local_context: str, document_context: str = None):
35
+ return self.predict(
36
+ phrase=phrase,
37
+ local_context=local_context,
38
+ document_context=document_context,
39
+ )
40
+
41
+
42
+ class ReformatMarkdownPredict(dspy.Module):
43
+ """Clean up and reformat markdown text."""
44
+
45
+ def __init__(self):
46
+ super().__init__()
47
+ self.predict = dspy.Predict(ReformatMarkdownSignature)
48
+
49
+ def forward(self, text: str, local_context: str, document_context: str = None):
50
+ return self.predict(
51
+ text=text,
52
+ local_context=local_context,
53
+ document_context=document_context,
54
+ )
55
+
56
+
57
+ class IdentifyReplacementPredict(dspy.Module):
58
+ """Identify exact phrase to replace for synonym application."""
59
+
60
+ def __init__(self):
61
+ super().__init__()
62
+ self.predict = dspy.Predict(IdentifyReplacementSignature)
63
+
64
+ def forward(self, original_word: str, chosen_synonym: str, context: str):
65
+ return self.predict(
66
+ original_word=original_word,
67
+ chosen_synonym=chosen_synonym,
68
+ context=context,
69
+ )
@@ -0,0 +1 @@
1
+ """Optimizers for improving MRMD AI program performance."""