deepctl-cmd-read 0.0.2__tar.gz

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,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: deepctl-cmd-read
3
+ Version: 0.0.2
4
+ Summary: Read (text intelligence) command for deepctl
5
+ Author-email: Deepgram <devrel@deepgram.com>
6
+ Maintainer-email: Deepgram <devrel@deepgram.com>
7
+ License-Expression: MIT
8
+ Keywords: deepgram,cli,text-intelligence,nlp,read
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: deepctl-core>=0.1.10
18
+ Requires-Dist: click>=8.0.0
19
+ Requires-Dist: rich>=13.0.0
20
+ Requires-Dist: pydantic>=2.0.0
21
+
22
+ # deepctl-cmd-read
23
+
24
+ > Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
25
+
26
+ Read (text intelligence) command for deepctl
27
+
28
+ ## Installation
29
+
30
+ This package is included with deepctl and does not need to be installed separately.
31
+
32
+ ### Install deepctl
33
+
34
+ ```bash
35
+ # Install with pip
36
+ pip install deepctl
37
+
38
+ # Or install with uv
39
+ uv tool install deepctl
40
+
41
+ # Or install with pipx
42
+ pipx install deepctl
43
+
44
+ # Or run without installing
45
+ uvx deepctl --help
46
+ pipx run deepctl --help
47
+ ```
48
+
49
+ ## Commands
50
+
51
+ | Command | Entry Point |
52
+ |---------|-------------|
53
+ | `deepctl read` | `deepctl_cmd_read.command:ReadCommand` |
54
+
55
+ ## Dependencies
56
+
57
+ - `click>=8.0.0`
58
+ - `rich>=13.0.0`
59
+ - `pydantic>=2.0.0`
60
+
61
+ ## License
62
+
63
+ MIT — see [LICENSE](../../LICENSE)
@@ -0,0 +1,42 @@
1
+ # deepctl-cmd-read
2
+
3
+ > Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
4
+
5
+ Read (text intelligence) command for deepctl
6
+
7
+ ## Installation
8
+
9
+ This package is included with deepctl and does not need to be installed separately.
10
+
11
+ ### Install deepctl
12
+
13
+ ```bash
14
+ # Install with pip
15
+ pip install deepctl
16
+
17
+ # Or install with uv
18
+ uv tool install deepctl
19
+
20
+ # Or install with pipx
21
+ pipx install deepctl
22
+
23
+ # Or run without installing
24
+ uvx deepctl --help
25
+ pipx run deepctl --help
26
+ ```
27
+
28
+ ## Commands
29
+
30
+ | Command | Entry Point |
31
+ |---------|-------------|
32
+ | `deepctl read` | `deepctl_cmd_read.command:ReadCommand` |
33
+
34
+ ## Dependencies
35
+
36
+ - `click>=8.0.0`
37
+ - `rich>=13.0.0`
38
+ - `pydantic>=2.0.0`
39
+
40
+ ## License
41
+
42
+ MIT — see [LICENSE](../../LICENSE)
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "deepctl-cmd-read"
7
+ version = "0.0.2" # x-release-please-version
8
+ description = "Read (text intelligence) command for deepctl"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [{ name = "Deepgram", email = "devrel@deepgram.com" }]
12
+ maintainers = [{ name = "Deepgram", email = "devrel@deepgram.com" }]
13
+ classifiers = [
14
+ "Development Status :: 3 - Alpha",
15
+ "Intended Audience :: Developers",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ ]
21
+ keywords = ["deepgram", "cli", "text-intelligence", "nlp", "read"]
22
+ requires-python = ">=3.10"
23
+ dependencies = [
24
+ "deepctl-core>=0.1.10",
25
+ "click>=8.0.0",
26
+ "rich>=13.0.0",
27
+ "pydantic>=2.0.0",
28
+ ]
29
+
30
+ [project.scripts]
31
+
32
+ [project.entry-points."deepctl.commands"]
33
+ read = "deepctl_cmd_read.command:ReadCommand"
34
+
35
+ [tool.setuptools]
36
+ package-dir = { "" = "src" }
37
+
38
+ [tool.setuptools.packages.find]
39
+ where = ["src"]
40
+ include = ["deepctl_cmd_read*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ """Read (text intelligence) command for deepctl."""
@@ -0,0 +1,222 @@
1
+ """Read (text intelligence) command for deepctl."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+ from pathlib import Path
7
+ from typing import Any
8
+
9
+ from deepctl_core import (
10
+ AuthManager,
11
+ BaseCommand,
12
+ BaseResult,
13
+ Config,
14
+ DeepgramClient,
15
+ )
16
+ from rich.console import Console
17
+
18
+ from .models import ReadResult
19
+
20
+ console = Console()
21
+
22
+
23
+ class ReadCommand(BaseCommand):
24
+ """Command for analyzing text using Deepgram's text intelligence."""
25
+
26
+ name = "read"
27
+ help = "Analyze text using Deepgram text intelligence"
28
+ short_help = "Text intelligence"
29
+
30
+ requires_auth = True
31
+ requires_project = False
32
+ ci_friendly = True
33
+
34
+ examples = [
35
+ 'dg read "The product is amazing and works perfectly."',
36
+ "dg read --file article.txt --summarize",
37
+ 'dg read --sentiment --topics --intents "Customer called about billing issue."',
38
+ "cat review.txt | dg read --sentiment --summarize",
39
+ ]
40
+ agent_help = (
41
+ "Analyze text using Deepgram's text intelligence API. "
42
+ "Supports sentiment analysis, summarization, topic detection, and intent recognition. "
43
+ "Text can be provided as an argument, from a file, or piped via stdin."
44
+ )
45
+
46
+ def get_arguments(self) -> list[dict[str, Any]]:
47
+ return [
48
+ {
49
+ "name": "text",
50
+ "help": "Text to analyze",
51
+ "required": False,
52
+ "default": None,
53
+ },
54
+ {
55
+ "names": ["--file", "-f"],
56
+ "help": "Read text from file",
57
+ "type": str,
58
+ "is_option": True,
59
+ },
60
+ {
61
+ "names": ["--sentiment"],
62
+ "help": "Analyze sentiment",
63
+ "is_flag": True,
64
+ "is_option": True,
65
+ },
66
+ {
67
+ "names": ["--summarize"],
68
+ "help": "Generate summary",
69
+ "is_flag": True,
70
+ "is_option": True,
71
+ },
72
+ {
73
+ "names": ["--topics"],
74
+ "help": "Detect topics",
75
+ "is_flag": True,
76
+ "is_option": True,
77
+ },
78
+ {
79
+ "names": ["--intents"],
80
+ "help": "Detect intents",
81
+ "is_flag": True,
82
+ "is_option": True,
83
+ },
84
+ {
85
+ "names": ["--language", "-l"],
86
+ "help": "Language code (e.g., en)",
87
+ "type": str,
88
+ "is_option": True,
89
+ },
90
+ ]
91
+
92
+ def handle(
93
+ self,
94
+ config: Config,
95
+ auth_manager: AuthManager,
96
+ client: DeepgramClient,
97
+ **kwargs: Any,
98
+ ) -> BaseResult:
99
+ text = kwargs.get("text")
100
+ file_path = kwargs.get("file")
101
+ sentiment = kwargs.get("sentiment", False)
102
+ summarize = kwargs.get("summarize", False)
103
+ topics = kwargs.get("topics", False)
104
+ intents = kwargs.get("intents", False)
105
+ language = kwargs.get("language")
106
+
107
+ # Resolve text input: arg > --file > stdin
108
+ if not text and file_path:
109
+ path = Path(file_path)
110
+ if not path.exists():
111
+ return BaseResult(
112
+ status="error", message=f"File not found: {file_path}"
113
+ )
114
+ text = path.read_text().strip()
115
+ elif not text and not sys.stdin.isatty():
116
+ text = sys.stdin.read().strip()
117
+
118
+ if not text:
119
+ return BaseResult(
120
+ status="error",
121
+ message="No text provided. Pass text as argument, use --file, or pipe via stdin.",
122
+ )
123
+
124
+ # Default: enable all features if none specified
125
+ if not any([sentiment, summarize, topics, intents]):
126
+ sentiment = True
127
+ summarize = True
128
+ topics = True
129
+ intents = True
130
+
131
+ try:
132
+ console.print("[blue]Analyzing text...[/blue]")
133
+
134
+ result = client.analyze_text(
135
+ text=text,
136
+ sentiment=sentiment,
137
+ summarize=summarize,
138
+ topics=topics,
139
+ intents=intents,
140
+ language=language,
141
+ )
142
+
143
+ return self._display_results(result, sentiment, summarize, topics, intents)
144
+
145
+ except Exception as e:
146
+ console.print(f"[red]Error analyzing text:[/red] {e}")
147
+ return BaseResult(status="error", message=str(e))
148
+
149
+ def _display_results(
150
+ self,
151
+ result: dict[str, Any],
152
+ show_sentiment: bool,
153
+ show_summary: bool,
154
+ show_topics: bool,
155
+ show_intents: bool,
156
+ ) -> ReadResult:
157
+ results = result.get("results", {})
158
+ read_result = ReadResult(status="success")
159
+
160
+ # Summary
161
+ if show_summary:
162
+ summaries = results.get("summary", {})
163
+ summary_text = (
164
+ summaries.get("text", "") if isinstance(summaries, dict) else ""
165
+ )
166
+ if summary_text:
167
+ console.print("\n[green]Summary:[/green]")
168
+ console.print(f" {summary_text}")
169
+ read_result.summary = summary_text
170
+
171
+ # Sentiment
172
+ if show_sentiment:
173
+ sentiments = results.get("sentiments", {})
174
+ if sentiments:
175
+ average = sentiments.get("average", {})
176
+ sentiment_val = average.get("sentiment", "")
177
+ sentiment_score = average.get("sentiment_score", 0.0)
178
+ console.print(
179
+ f"\n[green]Sentiment:[/green] {sentiment_val} ({sentiment_score:.2f})"
180
+ )
181
+ read_result.sentiment = sentiment_val
182
+ read_result.sentiment_score = float(sentiment_score)
183
+
184
+ # Topics
185
+ if show_topics:
186
+ topics_data = results.get("topics", {})
187
+ segments = (
188
+ topics_data.get("segments", []) if isinstance(topics_data, dict) else []
189
+ )
190
+ if segments:
191
+ console.print("\n[green]Topics:[/green]")
192
+ seen_topics: set[str] = set()
193
+ for seg in segments:
194
+ for topic in seg.get("topics", []):
195
+ topic_name = topic.get("topic", "")
196
+ if topic_name and topic_name not in seen_topics:
197
+ seen_topics.add(topic_name)
198
+ confidence = topic.get("confidence_score", 0.0)
199
+ console.print(f" • {topic_name} ({confidence:.0%})")
200
+ read_result.topics = segments
201
+
202
+ # Intents
203
+ if show_intents:
204
+ intents_data = results.get("intents", {})
205
+ segments = (
206
+ intents_data.get("segments", [])
207
+ if isinstance(intents_data, dict)
208
+ else []
209
+ )
210
+ if segments:
211
+ console.print("\n[green]Intents:[/green]")
212
+ seen_intents: set[str] = set()
213
+ for seg in segments:
214
+ for intent in seg.get("intents", []):
215
+ intent_name = intent.get("intent", "")
216
+ if intent_name and intent_name not in seen_intents:
217
+ seen_intents.add(intent_name)
218
+ confidence = intent.get("confidence_score", 0.0)
219
+ console.print(f" • {intent_name} ({confidence:.0%})")
220
+ read_result.intents = segments
221
+
222
+ return read_result
@@ -0,0 +1,16 @@
1
+ """Models for read command."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ from deepctl_core import BaseResult
8
+ from pydantic import Field
9
+
10
+
11
+ class ReadResult(BaseResult):
12
+ summary: str = ""
13
+ sentiment: str = ""
14
+ sentiment_score: float = 0.0
15
+ topics: list[dict[str, Any]] = Field(default_factory=list)
16
+ intents: list[dict[str, Any]] = Field(default_factory=list)
@@ -0,0 +1,63 @@
1
+ Metadata-Version: 2.4
2
+ Name: deepctl-cmd-read
3
+ Version: 0.0.2
4
+ Summary: Read (text intelligence) command for deepctl
5
+ Author-email: Deepgram <devrel@deepgram.com>
6
+ Maintainer-email: Deepgram <devrel@deepgram.com>
7
+ License-Expression: MIT
8
+ Keywords: deepgram,cli,text-intelligence,nlp,read
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ Requires-Dist: deepctl-core>=0.1.10
18
+ Requires-Dist: click>=8.0.0
19
+ Requires-Dist: rich>=13.0.0
20
+ Requires-Dist: pydantic>=2.0.0
21
+
22
+ # deepctl-cmd-read
23
+
24
+ > Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
25
+
26
+ Read (text intelligence) command for deepctl
27
+
28
+ ## Installation
29
+
30
+ This package is included with deepctl and does not need to be installed separately.
31
+
32
+ ### Install deepctl
33
+
34
+ ```bash
35
+ # Install with pip
36
+ pip install deepctl
37
+
38
+ # Or install with uv
39
+ uv tool install deepctl
40
+
41
+ # Or install with pipx
42
+ pipx install deepctl
43
+
44
+ # Or run without installing
45
+ uvx deepctl --help
46
+ pipx run deepctl --help
47
+ ```
48
+
49
+ ## Commands
50
+
51
+ | Command | Entry Point |
52
+ |---------|-------------|
53
+ | `deepctl read` | `deepctl_cmd_read.command:ReadCommand` |
54
+
55
+ ## Dependencies
56
+
57
+ - `click>=8.0.0`
58
+ - `rich>=13.0.0`
59
+ - `pydantic>=2.0.0`
60
+
61
+ ## License
62
+
63
+ MIT — see [LICENSE](../../LICENSE)
@@ -0,0 +1,11 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/deepctl_cmd_read/__init__.py
4
+ src/deepctl_cmd_read/command.py
5
+ src/deepctl_cmd_read/models.py
6
+ src/deepctl_cmd_read.egg-info/PKG-INFO
7
+ src/deepctl_cmd_read.egg-info/SOURCES.txt
8
+ src/deepctl_cmd_read.egg-info/dependency_links.txt
9
+ src/deepctl_cmd_read.egg-info/entry_points.txt
10
+ src/deepctl_cmd_read.egg-info/requires.txt
11
+ src/deepctl_cmd_read.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [deepctl.commands]
2
+ read = deepctl_cmd_read.command:ReadCommand
@@ -0,0 +1,4 @@
1
+ deepctl-core>=0.1.10
2
+ click>=8.0.0
3
+ rich>=13.0.0
4
+ pydantic>=2.0.0
@@ -0,0 +1 @@
1
+ deepctl_cmd_read