|
2 | 2 | <img src="https://github.com/AndrewClements84/PromptStream.AI/blob/master/assets/logo.png?raw=true" alt="PromptStream.AI" width="500"/> |
3 | 3 | </p> |
4 | 4 |
|
5 | | -<h1 align="center">PromptStream.AI CLI</h1> |
| 5 | +# 🧠 PromptStream.AI |
6 | 6 |
|
7 | | -<p align="center"> |
8 | | - <b>Build, validate, and analyze prompt flows — directly from your terminal.</b><br/> |
9 | | - <i>Part of the Flow.AI ecosystem alongside TokenFlow.AI and Flow.AI.Core.</i> |
10 | | -</p> |
11 | | - |
12 | | -<p align="center"> |
13 | | - <a href="https://www.nuget.org/packages/PromptStream.AI.CLI"><img src="https://img.shields.io/nuget/v/PromptStream.AI.CLI.svg" alt="NuGet version"></a> |
14 | | - <a href="https://github.com/AndrewClements84/PromptStream.AI/actions/workflows/dotnet.yml"><img src="https://github.com/AndrewClements84/PromptStream.AI/actions/workflows/dotnet.yml/badge.svg" alt="Build status"></a> |
15 | | - <a href="https://codecov.io/gh/AndrewClements84/PromptStream.AI"><img src="https://codecov.io/gh/AndrewClements84/PromptStream.AI/branch/master/graph/badge.svg" alt="Coverage"></a> |
16 | | - <a href="https://buymeacoffee.com/andrewclements84"><img src="https://img.shields.io/badge/☕-Buy%20me%20a%20coffee-ffdd00?logo=buymeacoffee&logoColor=black" alt="Buy me a coffee"></a> |
17 | | -</p> |
| 7 | +[](https://github.com/AndrewClements84/PromptStream.AI/actions/workflows/dotnet.yml) |
| 8 | +[](https://andrewclements84.github.io/PromptStream.AI/) |
| 9 | +[](https://www.nuget.org/packages/PromptStream.AI) |
| 10 | +[](https://www.nuget.org/packages/PromptStream.AI) |
| 11 | +[](https://codecov.io/gh/AndrewClements84/PromptStream.AI) |
| 12 | +[](LICENSE) |
| 13 | +[](https://buymeacoffee.com/andrewclements84) |
18 | 14 |
|
19 | 15 | --- |
20 | 16 |
|
21 | | -## 🚀 Installation |
| 17 | +### 🧩 Description |
| 18 | +**PromptStream.AI** — Token-aware prompt composition, validation, and conversational context toolkit for .NET. |
22 | 19 |
|
23 | | -Install globally via the .NET CLI: |
| 20 | +Built atop [Flow.AI.Core](https://github.com/AndrewClements84/Flow.AI.Core) and [TokenFlow.AI](https://github.com/AndrewClements84/TokenFlow.AI), |
| 21 | +PromptStream.AI enables developers to **compose**, **validate**, **generate**, and **manage** multi-turn AI prompts with token budgeting, interpolation, and contextual memory. |
24 | 22 |
|
25 | | -```bash |
26 | | -dotnet tool install --global promptstream.ai.cli |
27 | | -``` |
| 23 | +--- |
28 | 24 |
|
29 | | -Once installed, you can call it from anywhere using the `promptstream` command. |
| 25 | +### ⚙️ Key Features |
| 26 | +- 🧩 **Token-aware prompt builder** with variable interpolation (`{{variable}}` syntax) |
| 27 | +- ✅ **Validation engine** for token limits, structure, and completeness |
| 28 | +- 💬 **Shared Core Models** from Flow.AI.Core (`PromptTemplate`, `PromptInstance`, `PromptMessage`, `PromptResponse`) |
| 29 | +- 🧠 **Context manager** with replay, merge, summarization, and JSON persistence |
| 30 | +- 💾 **Persistent context storage** (`ToJson` / `LoadFromJson`) |
| 31 | +- 🧮 **Token budgeting tools** (`EstimateTokenUsage`, `TrimToTokenBudget`) |
| 32 | +- ⚡ **CLI utility (`PromptStream.AI.CLI`)** for building, validating, analyzing, and generating prompts |
| 33 | +- 🔌 Seamless integration with **TokenFlow.AI** for model-aware tokenization |
30 | 34 |
|
31 | 35 | --- |
32 | 36 |
|
33 | | -## ⚙️ Usage Examples |
34 | | - |
35 | | -### 🧱 Build a prompt |
36 | | -Render a template and substitute variables: |
| 37 | +### 🚀 Installation |
37 | 38 |
|
38 | 39 | ```bash |
39 | | -promptstream build --template "Hello {{name}}" --var name=Andrew |
| 40 | +dotnet add package PromptStream.AI |
40 | 41 | ``` |
41 | 42 |
|
42 | | -Output: |
43 | | -``` |
44 | | -✅ Prompt built successfully: |
| 43 | +Requires: |
| 44 | +- .NET 8.0 or higher |
| 45 | +- Flow.AI.Core v0.2.0+ |
| 46 | +- (optional) TokenFlow.AI for advanced token metrics |
45 | 47 |
|
46 | | -Hello Andrew |
| 48 | +--- |
| 49 | + |
| 50 | +### 🧠 Quickstart Example |
| 51 | + |
| 52 | +```csharp |
| 53 | +using System; |
| 54 | +using System.Collections.Generic; |
| 55 | +using Flow.AI.Core.Models; |
| 56 | +using Flow.AI.Core.Interfaces; |
| 57 | +using TokenFlow.AI.Integration; |
| 58 | +using PromptStream.AI.Services; |
| 59 | + |
| 60 | +// Initialize the service with token tracking |
| 61 | +var tokenProvider = new BasicTokenFlowProvider(); |
| 62 | +var modelClient = new TokenFlowModelClient("gpt-4o-mini"); |
| 63 | +var context = new PromptContextManager(); |
| 64 | + |
| 65 | +var service = new PromptStreamService(tokenProvider, context, modelClient); |
| 66 | + |
| 67 | +// Define a shared Core template |
| 68 | +var template = new PromptTemplate |
| 69 | +{ |
| 70 | + Id = "summarize-v1", |
| 71 | + Template = "Summarize the following:\n\n{{input}}\n\nBe concise.", |
| 72 | + RequiredVariables = new() { "input" } |
| 73 | +}; |
| 74 | + |
| 75 | +// Variables to inject |
| 76 | +var variables = new Dictionary<string, string> |
| 77 | +{ |
| 78 | + ["input"] = "Flow.AI enables composable AI workflows for .NET developers." |
| 79 | +}; |
| 80 | + |
| 81 | +// Build and validate |
| 82 | +var (instance, validation) = service.BuildAndValidate(template, variables); |
| 83 | + |
| 84 | +if (validation.IsValid) |
| 85 | +{ |
| 86 | + Console.WriteLine($"✅ Valid prompt ({validation.TokenCount} tokens)"); |
| 87 | + Console.WriteLine(instance.RenderedText); |
| 88 | +} |
| 89 | +else |
| 90 | +{ |
| 91 | + Console.WriteLine($"❌ Invalid: {string.Join(", ", validation.Errors)}"); |
| 92 | +} |
| 93 | + |
| 94 | +// Add a user message to the context |
| 95 | +context.AddMessage(new PromptMessage { Role = "user", Content = instance.RenderedText }); |
47 | 96 | ``` |
48 | 97 |
|
49 | | -### 🔍 Validate a prompt |
50 | | -Check structure and token limits: |
| 98 | +--- |
| 99 | + |
| 100 | +### 💻 CLI Usage (`PromptStream.AI.CLI`) |
| 101 | + |
| 102 | +PromptStream.AI includes a full command-line interface for developers to build, validate, analyze, and generate prompts directly from the terminal. |
51 | 103 |
|
| 104 | +#### 🧩 Build a prompt |
52 | 105 | ```bash |
53 | | -promptstream validate --template "Summarize this text: {{content}}" --var content="PromptStream.AI is awesome" |
| 106 | +dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- build --template "Hello {{name}}" --var name=Andrew |
54 | 107 | ``` |
55 | 108 |
|
56 | | -### 📊 Analyze cost and tokens |
57 | | -Estimate model usage and pricing: |
58 | | - |
| 109 | +#### ✅ Validate a prompt |
59 | 110 | ```bash |
60 | | -promptstream analyze --template "Explain quantum computing in simple terms." |
| 111 | +dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- validate --template "Summarize {{topic}}" --var topic="AI in .NET" |
61 | 112 | ``` |
62 | 113 |
|
63 | | -### 💬 Generate a model response |
64 | | -Build, validate, and request a completion from your configured provider: |
65 | | - |
| 114 | +#### 🤖 Generate a model response |
66 | 115 | ```bash |
67 | | -promptstream generate --template "Write a haiku about AI" --save context.json |
| 116 | +dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- generate --template "Explain {{concept}}" --var concept="tokenization" --save context.json |
68 | 117 | ``` |
69 | 118 |
|
70 | | -### 🧠 Manage context |
71 | | -Inspect or clear your conversation history: |
72 | | - |
| 119 | +#### 🧠 Manage conversation context |
73 | 120 | ```bash |
74 | | -promptstream context --load context.json --summarize |
| 121 | +dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- context --load context.json --summarize |
75 | 122 | ``` |
76 | 123 |
|
77 | | ---- |
78 | | - |
79 | | -## 🧩 Features |
| 124 | +#### 📊 Analyze prompt usage |
| 125 | +```bash |
| 126 | +dotnet run --project src/PromptStream.AI.CLI/PromptStream.AI.CLI.csproj -- analyze --template "Summarize {{topic}}" --var topic="AI" --model gpt-4o-mini |
| 127 | +``` |
80 | 128 |
|
81 | | -- 🧠 **Prompt orchestration** — consistent Flow.AI.Core integration |
82 | | -- 🧪 **Validation & analysis** — token counts, cost estimation, structure checks |
83 | | -- ⚙️ **Developer-first CLI** — clean UX, global tool packaging, colorful output |
84 | | -- 🤝 **Ecosystem-ready** — interoperable with TokenFlow.AI and Flow.AI.Core |
| 129 | +**Available commands:** |
| 130 | +| Command | Description | |
| 131 | +|----------|--------------| |
| 132 | +| `build` | Render a prompt with variable substitution | |
| 133 | +| `validate` | Validate prompt completeness and token limits | |
| 134 | +| `generate` | Build, validate, and produce a model-like response | |
| 135 | +| `context` | Load, save, summarize, or clear conversation context | |
| 136 | +| `analyze` | Estimate token usage and cost for prompts | |
85 | 137 |
|
86 | 138 | --- |
87 | 139 |
|
88 | | -## 🗺️ Documentation |
89 | | - |
90 | | -👉 [CLI Usage Guide](https://andrewclements84.github.io/PromptStream.AI/docs/cli-usage.html) |
| 140 | +### 🌟 Supporting the Project |
91 | 141 |
|
92 | | -For full developer docs: |
93 | | -[PromptStream.AI Documentation](https://andrewclements84.github.io/PromptStream.AI) |
| 142 | +If you find **PromptStream.AI** helpful, please consider |
| 143 | +⭐ **starring the repository** and ☕ [**supporting my work**](https://buymeacoffee.com/andrewclements84). |
| 144 | +Your support helps keep the Flow.AI ecosystem growing. |
94 | 145 |
|
95 | 146 | --- |
96 | 147 |
|
97 | | -## 🧑💻 Author & License |
98 | | - |
99 | | -**Author:** [AndrewClements84](https://github.com/AndrewClements84) |
100 | | -**License:** MIT |
101 | | -**Project:** [PromptStream.AI on GitHub](https://github.com/AndrewClements84/PromptStream.AI) |
102 | | - |
103 | | ---- |
| 148 | +> Part of the **Flow.AI Ecosystem** |
| 149 | +> © 2025 Andrew Clements |
0 commit comments