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,134 @@
1
+ """Signature definitions for text transformation programs."""
2
+
3
+ import dspy
4
+ from typing import Optional, List
5
+
6
+
7
+ class GetSynonymsSignature(dspy.Signature):
8
+ """
9
+ Find synonyms for a SINGLE WORD that fit the context.
10
+
11
+ Guidelines:
12
+ - Provide 3-6 alternative words that could replace the input word
13
+ - Consider the surrounding context to suggest appropriate synonyms
14
+ - Preserve the part of speech (noun, verb, adjective, etc.)
15
+ - Order synonyms by relevance to the context
16
+ - Synonyms should be single words or very short (1-2 words max)
17
+ """
18
+
19
+ text: str = dspy.InputField(
20
+ desc="The single word to find synonyms for"
21
+ )
22
+ local_context: str = dspy.InputField(
23
+ desc="Surrounding text to understand usage context"
24
+ )
25
+ document_context: Optional[str] = dspy.InputField(
26
+ desc="Full document for topic understanding",
27
+ default=None,
28
+ )
29
+ original: str = dspy.OutputField(
30
+ desc="The original word (echoed back)"
31
+ )
32
+ synonyms: List[str] = dspy.OutputField(
33
+ desc="List of 3-6 synonym alternatives (prefer single words)"
34
+ )
35
+
36
+
37
+ class GetPhraseSynonymsSignature(dspy.Signature):
38
+ """
39
+ Find alternative phrases for a multi-word expression that fit the context.
40
+
41
+ Guidelines:
42
+ - Provide 3-6 alternative phrases that could replace the input phrase
43
+ - Preserve the meaning and grammatical structure
44
+ - Consider the surrounding context for appropriate alternatives
45
+ - Alternatives should be complete phrases that can directly replace the original
46
+ - Order by relevance to the context
47
+ """
48
+
49
+ phrase: str = dspy.InputField(
50
+ desc="The multi-word phrase to find alternatives for (e.g., 'executable notebooks')"
51
+ )
52
+ local_context: str = dspy.InputField(
53
+ desc="Surrounding text to understand usage context"
54
+ )
55
+ document_context: Optional[str] = dspy.InputField(
56
+ desc="Full document for topic understanding",
57
+ default=None,
58
+ )
59
+ original: str = dspy.OutputField(
60
+ desc="The original phrase (echoed back)"
61
+ )
62
+ alternatives: List[str] = dspy.OutputField(
63
+ desc="List of 3-6 alternative phrases that preserve meaning"
64
+ )
65
+
66
+
67
+ class ReformatMarkdownSignature(dspy.Signature):
68
+ """
69
+ Clean up and reformat markdown text while preserving meaning.
70
+
71
+ CRITICAL: You must ONLY reformat the `text` field. Do NOT include text from `local_context`.
72
+
73
+ Guidelines:
74
+ - Fix inconsistent heading levels
75
+ - Normalize list formatting (bullets, numbering)
76
+ - Clean up whitespace and line breaks
77
+ - Fix broken links and formatting
78
+ - Improve paragraph structure
79
+ - Preserve all content and meaning exactly
80
+ - Output must be EXACTLY the `text` input reformatted
81
+ """
82
+
83
+ text: str = dspy.InputField(
84
+ desc="The EXACT markdown text to reformat. Output must contain ONLY this text reformatted."
85
+ )
86
+ local_context: str = dspy.InputField(
87
+ desc="Surrounding text for style context ONLY - do NOT include this in output"
88
+ )
89
+ document_context: Optional[str] = dspy.InputField(
90
+ desc="Full document for understanding structure - do NOT include in output",
91
+ default=None,
92
+ )
93
+ reformatted_text: str = dspy.OutputField(
94
+ desc="ONLY the `text` input reformatted. Must have same content, cleaner formatting."
95
+ )
96
+
97
+
98
+ class IdentifyReplacementSignature(dspy.Signature):
99
+ """
100
+ Identify the exact phrase to replace when applying a synonym.
101
+
102
+ Given an original word and a chosen synonym, analyze the context to determine
103
+ what COMPLETE phrase should be replaced.
104
+
105
+ CRITICAL RULES:
106
+ 1. If the synonym is "adjective noun" (e.g., "interactive notebooks"), find if the original
107
+ word in context also has an adjective (e.g., "executable notebooks") and replace the WHOLE phrase
108
+ 2. The text_to_replace MUST be copied EXACTLY from the context - character for character
109
+ 3. The replacement should result in grammatically correct text
110
+
111
+ Examples:
112
+ - original_word="notebooks", synonym="interactive notebooks", context has "executable notebooks"
113
+ → text_to_replace="executable notebooks", replacement="interactive notebooks"
114
+ - original_word="notebooks", synonym="notebooks", context has "executable notebooks"
115
+ → text_to_replace="notebooks", replacement="notebooks"
116
+ - original_word="big", synonym="large", context has "big house"
117
+ → text_to_replace="big", replacement="large"
118
+ """
119
+
120
+ original_word: str = dspy.InputField(
121
+ desc="The word that was identified for synonym replacement"
122
+ )
123
+ chosen_synonym: str = dspy.InputField(
124
+ desc="The synonym the user chose (may be single or multi-word like 'interactive notebooks')"
125
+ )
126
+ context: str = dspy.InputField(
127
+ desc="The text surrounding the original word - search here for the phrase to replace"
128
+ )
129
+ text_to_replace: str = dspy.OutputField(
130
+ desc="The EXACT phrase copied from context that should be replaced. If synonym is 'adj noun', find 'adj noun' pattern in context containing original_word."
131
+ )
132
+ replacement: str = dspy.OutputField(
133
+ desc="The text to insert - usually the chosen_synonym, possibly adjusted for grammar"
134
+ )
@@ -0,0 +1 @@
1
+ """Utility functions for MRMD AI programs."""
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: mrmd-ai
3
+ Version: 0.1.0
4
+ Summary: AI programs for MRMD editor - completions, fixes, and corrections
5
+ Requires-Python: >=3.11
6
+ Requires-Dist: dspy>=2.6
7
+ Requires-Dist: fastapi>=0.115
8
+ Requires-Dist: litellm>=1.50
9
+ Requires-Dist: uvicorn>=0.32
10
+ Description-Content-Type: text/markdown
11
+
12
+ # MRMD AI Server
13
+
14
+ AI programs for the MRMD editor using DSPy.
15
+
16
+ ## Programs
17
+
18
+ ### Finish (Completion)
19
+ - `FinishSentencePredict` - Complete the current sentence
20
+ - `FinishParagraphPredict` - Complete the current paragraph
21
+ - `FinishCodeLinePredict` - Complete the current code line
22
+ - `FinishCodeSectionPredict` - Complete the current code section
23
+
24
+ ### Fix (Correction)
25
+ - `FixGrammarPredict` - Fix grammar/spelling errors
26
+ - `FixTranscriptionPredict` - Fix speech-to-text errors
27
+
28
+ ### Correct & Finish
29
+ - `CorrectAndFinishLinePredict` - Correct and complete current line
30
+ - `CorrectAndFinishSectionPredict` - Correct and complete current section
31
+
32
+ ## Running
33
+
34
+ ```bash
35
+ cd ai-server
36
+ uv run dspy-cli serve --port 8766
37
+ ```
38
+
39
+ ## Configuration
40
+
41
+ API keys are read from environment variables:
42
+ - `ANTHROPIC_API_KEY`
43
+ - `OPENAI_API_KEY`
44
+
45
+ See `dspy.config.yaml` for model configuration.
@@ -0,0 +1,26 @@
1
+ mrmd_ai/__init__.py,sha256=RocuoOEEJCUNinxqsXWjm_bIimCu8aDCDha-G5pU4fU,105
2
+ mrmd_ai/juice.py,sha256=0_h7_M89IDhSt4iohdz0J5StcFXOaLF33d3fTxdBO-o,14442
3
+ mrmd_ai/server.py,sha256=Jgl-bsQYbBMtv_tGu_2FwSN9BxgFpt-fmb9_pjIcqNw,14416
4
+ mrmd_ai/metrics/__init__.py,sha256=6BngKqh0a09phOzUdYeWjhsUXznCIx5jEjrEt7DIDu4,62
5
+ mrmd_ai/modules/__init__.py,sha256=4V4IzurDZs_nhBTGlHyXco24iwEkum58kRNrKfm4IjQ,1793
6
+ mrmd_ai/modules/code.py,sha256=8cK6LF0ZTrSp2srt1ltvUnmYjPlt5NZTj1yWctpJ7j0,4099
7
+ mrmd_ai/modules/correct.py,sha256=TWnE1HD_Ip7xZ5yQwJi1n01tNXgBtYNvkTK--kAknak,1478
8
+ mrmd_ai/modules/document.py,sha256=o6iLR2amscn-DHZ95JFQuEwhaj8cLs4bBISf7G9cT9Y,1106
9
+ mrmd_ai/modules/finish.py,sha256=VtyE-45-8iM6iWjNg57wRWL0Ln3mSF0RcZq8CO5CoSk,2638
10
+ mrmd_ai/modules/fix.py,sha256=fb4flKWyyyelheigeb1sI0dixd2scL9HZX-0_M_Uh-o,1506
11
+ mrmd_ai/modules/notebook.py,sha256=w8Dg-NKVL6_kPOKkvb84kGrwgv5zHxvFNWBtXHLHww8,477
12
+ mrmd_ai/modules/text.py,sha256=9MCO__EDalwi-iFf__sd8t7orsUy7WiBBf6Lp4bxxGE,2010
13
+ mrmd_ai/optimizers/__init__.py,sha256=Ay6ZrQu8fLQaG7-dl6hTMruQY5AdGOT_YnlRhhZGgag,60
14
+ mrmd_ai/signatures/__init__.py,sha256=wWT2D8beisIpYMPxN4j4JncQmUqcamD6v5BTKp2zFWc,655
15
+ mrmd_ai/signatures/code.py,sha256=zBM_Nl2NImfOw49fVWCGlXcE_sm8xgWCN1ksDbEa6e8,11245
16
+ mrmd_ai/signatures/correct.py,sha256=tIhYCONgGhuTV0eJCiLSXcGZSAEi06XY35ommtTTsRE,2920
17
+ mrmd_ai/signatures/document.py,sha256=4Y-9SeXJGCq098Vy-PIbb_rexS2dYDlkU-kxnKAPVSU,1828
18
+ mrmd_ai/signatures/finish.py,sha256=x-ZB0U8GQJdNoGGO80FBOxHXjYsCmTFq9fnkXlHDeUY,5294
19
+ mrmd_ai/signatures/fix.py,sha256=LJNvu9_XjPl90Wtt3xn6s-jGXA9GB5rdIL0MeFyRGtE,3042
20
+ mrmd_ai/signatures/notebook.py,sha256=ZBioHA9ZTkLUD_UovdfiRYiDaUKuKOCDhiZP1NDFY8o,1226
21
+ mrmd_ai/signatures/text.py,sha256=GhmFtEZqwivbevPI_NSBzh6AlH6JKLt2rA_LaYGK2lQ,5223
22
+ mrmd_ai/utils/__init__.py,sha256=T4e9jmFWDSj1HOyz5_Qv-JQSC08GwT_9CACcAn37vWg,46
23
+ mrmd_ai-0.1.0.dist-info/METADATA,sha256=4w17Do4YbBpwoT3PFN2i01zswTPJCVzR6rgib0zZXME,1167
24
+ mrmd_ai-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
25
+ mrmd_ai-0.1.0.dist-info/entry_points.txt,sha256=Bq6nXiXxhNSPEgYWBgrrgJH1DeGjKM6hfCijcWClApw,55
26
+ mrmd_ai-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mrmd-ai-server = mrmd_ai.server:main