Skip to content

Commit e2dba9a

Browse files
author
AndrewMorgan1
committed
2 parents 011e358 + 1cd5fec commit e2dba9a

1 file changed

Lines changed: 107 additions & 61 deletions

File tree

README.md

Lines changed: 107 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,102 +2,148 @@
22
<img src="https://github.com/AndrewClements84/PromptStream.AI/blob/master/assets/logo.png?raw=true" alt="PromptStream.AI" width="500"/>
33
</p>
44

5-
<h1 align="center">PromptStream.AI CLI</h1>
5+
# 🧠 PromptStream.AI
66

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+
[![Build](https://github.com/AndrewClements84/PromptStream.AI/actions/workflows/dotnet.yml/badge.svg)](https://github.com/AndrewClements84/PromptStream.AI/actions/workflows/dotnet.yml)
8+
[![Docs](https://img.shields.io/badge/docs-online-brightgreen.svg?logo=githubpages)](https://andrewclements84.github.io/PromptStream.AI/)
9+
[![NuGet Version](https://img.shields.io/nuget/v/PromptStream.AI.svg?logo=nuget&cacheSeconds=60)](https://www.nuget.org/packages/PromptStream.AI)
10+
[![NuGetDownloads](https://img.shields.io/nuget/dt/PromptStream.AI.svg)](https://www.nuget.org/packages/PromptStream.AI)
11+
[![Coverage](https://codecov.io/gh/AndrewClements84/PromptStream.AI/branch/master/graph/badge.svg)](https://codecov.io/gh/AndrewClements84/PromptStream.AI)
12+
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
13+
[![Buy Me A Coffee](https://img.shields.io/badge/☕%20Buy%20me%20a%20coffee-FFDD00?style=flat&logo=buy-me-a-coffee&logoColor=black)](https://buymeacoffee.com/andrewclements84)
1814

1915
---
2016

21-
## 🚀 Installation
17+
### 🧩 Description
18+
**PromptStream.AI** — Token-aware prompt composition, validation, and conversational context toolkit for .NET.
2219

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.
2422

25-
```bash
26-
dotnet tool install --global promptstream.ai.cli
27-
```
23+
---
2824

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
3034

3135
---
3236

33-
## ⚙️ Usage Examples
34-
35-
### 🧱 Build a prompt
36-
Render a template and substitute variables:
37+
### 🚀 Installation
3738

3839
```bash
39-
promptstream build --template "Hello {{name}}" --var name=Andrew
40+
dotnet add package PromptStream.AI
4041
```
4142

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
4547

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 });
4796
```
4897

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.
51103

104+
#### 🧩 Build a prompt
52105
```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
54107
```
55108

56-
### 📊 Analyze cost and tokens
57-
Estimate model usage and pricing:
58-
109+
#### ✅ Validate a prompt
59110
```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"
61112
```
62113

63-
### 💬 Generate a model response
64-
Build, validate, and request a completion from your configured provider:
65-
114+
#### 🤖 Generate a model response
66115
```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
68117
```
69118

70-
### 🧠 Manage context
71-
Inspect or clear your conversation history:
72-
119+
#### 🧠 Manage conversation context
73120
```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
75122
```
76123

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+
```
80128

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 |
85137

86138
---
87139

88-
## 🗺️ Documentation
89-
90-
👉 [CLI Usage Guide](https://andrewclements84.github.io/PromptStream.AI/docs/cli-usage.html)
140+
### 🌟 Supporting the Project
91141

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.
94145

95146
---
96147

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

Comments
 (0)