|
1 | 1 | # Getting Started with TalkPipe |
2 | 2 |
|
3 | | -Welcome to TalkPipe! This guide will help you get up and running quickly with TalkPipe's dual-language architecture for building AI-powered data processing pipelines. |
| 3 | +This guide gets you up and running with TalkPipe's dual-language architecture for building data processing pipelines. You can start with **no LLM**—examples below work with the base install—then add LLM support when you're ready. |
4 | 4 |
|
5 | 5 | ## Installation |
6 | 6 |
|
7 | 7 | ```bash |
8 | 8 | pip install talkpipe |
9 | 9 | ``` |
10 | 10 |
|
11 | | -For LLM support, install the provider(s) you need: |
| 11 | +The base install includes data processing, file I/O, search (Whoosh, LanceDB), and web serving. For LLM and PDF support, add optional extras: |
| 12 | + |
12 | 13 | ```bash |
13 | | -# Install specific providers |
14 | | -pip install talkpipe[openai] # For OpenAI |
15 | | -pip install talkpipe[ollama] # For Ollama |
16 | | -pip install talkpipe[anthropic] # For Anthropic Claude |
| 14 | +# LLM providers (install one or more) |
| 15 | +pip install talkpipe[ollama] # Local models via Ollama |
| 16 | +pip install talkpipe[openai] # OpenAI (GPT-4, etc.) |
| 17 | +pip install talkpipe[anthropic] # Anthropic Claude |
| 18 | + |
| 19 | +# PDF extraction |
| 20 | +pip install talkpipe[pypdf] |
| 21 | + |
| 22 | +# Combine extras |
| 23 | +pip install talkpipe[ollama,pypdf] |
| 24 | +pip install talkpipe[openai,anthropic] |
17 | 25 |
|
18 | | -# Or install all LLM providers |
| 26 | +# Everything: all LLM providers + PDF |
19 | 27 | pip install talkpipe[all] |
20 | 28 | ``` |
21 | 29 |
|
| 30 | +| Extra | Adds | |
| 31 | +|-------|------| |
| 32 | +| `ollama` | `ollama` package for local models | |
| 33 | +| `openai` | `openai` package for OpenAI API | |
| 34 | +| `anthropic` | `anthropic` package for Claude | |
| 35 | +| `pypdf` | `pypdf` for PDF text extraction | |
| 36 | +| `all` | All of the above | |
| 37 | + |
22 | 38 | ## Basic Concepts |
23 | 39 |
|
24 | | -TalkPipe provides two ways to build data processing pipelines: |
| 40 | +TalkPipe provides two ways to build pipelines: |
25 | 41 |
|
26 | 42 | - **Pipe API (Internal DSL)**: Pure Python using the `|` operator |
27 | 43 | - **ChatterLang (External DSL)**: Concise text-based syntax |
28 | 44 |
|
29 | | -Both approaches use the same underlying components and can be mixed freely. |
30 | | - |
31 | | -## Your First Pipeline |
| 45 | +Both use the same components and can be mixed. |
32 | 46 |
|
33 | | -### Using ChatterLang |
| 47 | +## Your First Pipeline (No LLM Required) |
34 | 48 |
|
35 | | -Create a simple chat interface in python: |
| 49 | +### ChatterLang |
36 | 50 |
|
37 | 51 | ```python |
38 | 52 | from talkpipe.chatterlang import compiler |
39 | 53 |
|
40 | | -# Define a pipeline that prompts an LLM and prints the response. Assumed Ollama is installed locally and llama3.2 is downloaded. |
41 | | -script = '| llmPrompt[model="llama3.2", source="ollama"] | print' |
42 | | -chat = compiler.compile(script).as_function(single_in=True, single_out=True) |
| 54 | +script = 'INPUT FROM echo[data="hello,world,test"] | print' |
| 55 | +pipeline = compiler.compile(script).as_function(single_out=False) |
43 | 56 |
|
44 | | -# Use it |
45 | | -response = chat("Hello! Tell me about the history of computers.") |
| 57 | +result = pipeline() |
| 58 | +# Prints: hello, world, test (each on its own line) |
| 59 | +# Returns: ['hello', 'world', 'test'] |
46 | 60 | ``` |
47 | 61 |
|
48 | | -### Using the Pipe API |
49 | | - |
50 | | -A similar interactive pipeline in pure Python: |
| 62 | +### Pipe API |
51 | 63 |
|
52 | 64 | ```python |
53 | 65 | from talkpipe.pipe import io |
54 | | -from talkpipe.llm import chat |
55 | 66 |
|
56 | | -# Create pipeline using the | operator |
57 | | -pipeline = io.Prompt() | chat.LLMPrompt(model="llama3.2", source="ollama") | io.Print() |
58 | | -pipeline_func = pipeline.as_function() |
| 67 | +pipeline = io.echo(data="hello,world,test") | io.Print() |
| 68 | +result = pipeline.as_function(single_out=False)() |
59 | 69 |
|
60 | | -# Run it |
61 | | -pipeline_func() # This will prompt for input interactively |
| 70 | +# Same output and return value |
62 | 71 | ``` |
63 | 72 |
|
64 | | -## Web Interface |
| 73 | +### Data Transformation (No LLM) |
65 | 74 |
|
66 | | -Create a web interface for your pipeline from the command line: |
| 75 | +```python |
| 76 | +from talkpipe.chatterlang import compiler |
67 | 77 |
|
68 | | -```bash |
69 | | -# Use single quotes to avoid escaping double quotes inside |
70 | | -chatterlang_serve --port 2025 --display-property prompt --script '| llmPrompt[model="llama3.2", source="ollama", field="prompt"]' |
| 78 | +# Parse numbers, filter, and print |
| 79 | +script = 'INPUT FROM echo[data="1,2,hello,3,4"] | cast[cast_type="int"] | print' |
| 80 | +pipeline = compiler.compile(script).as_function(single_out=False) |
| 81 | +pipeline() # Skips "hello", prints 1, 2, 3, 4 |
71 | 82 | ``` |
72 | 83 |
|
73 | | -Open http://localhost:2025/stream in your browser to interact with your pipeline through a web form. |
| 84 | +## Your First Pipeline (With LLM) |
74 | 85 |
|
75 | | -## Debug Pipelines with diagPrint |
| 86 | +Requires `talkpipe[ollama]` and Ollama running with a model (e.g. `ollama pull llama3.2`). |
76 | 87 |
|
77 | | -Use `diagPrint` to inspect data as it flows through a pipeline without altering outputs. |
78 | | - |
79 | | -### Pipe API |
| 88 | +### ChatterLang |
80 | 89 |
|
81 | 90 | ```python |
82 | | -from talkpipe.pipe import basic |
83 | | - |
84 | | -debug = basic.DiagPrint( |
85 | | - label="chunk", |
86 | | - field_list="id,text", |
87 | | - expression="len(item['text'])", |
88 | | - output="stderr", # or a logger name |
89 | | -) |
90 | | -pipeline = debug | basic.firstN(n=3) |
91 | | -list(pipeline([{"id": 1, "text": "hello world"}])) |
92 | | -``` |
| 91 | +from talkpipe.chatterlang import compiler |
93 | 92 |
|
94 | | -### ChatterLang |
| 93 | +script = '| llmPrompt[model="llama3.2", source="ollama"] | print' |
| 94 | +chat = compiler.compile(script).as_function(single_in=True, single_out=True) |
95 | 95 |
|
96 | | -``` |
97 | | -| diagPrint[label="chunk", field_list="id,text", expression="len(item['text'])", output="stderr"] |
| 96 | +response = chat("Hello! Tell me about the history of computers.") |
98 | 97 | ``` |
99 | 98 |
|
100 | | -### Config-driven output |
| 99 | +### Pipe API |
101 | 100 |
|
102 | | -Set a config key (e.g., in `~/.talkpipe.toml`): |
| 101 | +```python |
| 102 | +from talkpipe.pipe import io |
| 103 | +from talkpipe.llm import chat |
103 | 104 |
|
104 | | -```toml |
105 | | -diag_output = "stderr" |
| 105 | +pipeline = io.Prompt() | chat.LLMPrompt(model="llama3.2", source="ollama") | io.Print() |
| 106 | +pipeline_func = pipeline.as_function() |
| 107 | +pipeline_func() # Prompts for input interactively |
106 | 108 | ``` |
107 | 109 |
|
108 | | -Then point `diagPrint` to it: |
| 110 | +## Web Interface |
109 | 111 |
|
| 112 | +Use `--display-property` so the stream UI shows the input field value instead of raw JSON. Use `formatItem` to format output for readable display. |
| 113 | + |
| 114 | +### Without LLM (Echo / Transform) |
| 115 | + |
| 116 | +```bash |
| 117 | +chatterlang_serve --port 2025 --display-property prompt --script '| formatItem[field_list="prompt:You entered"] | print' |
110 | 118 | ``` |
111 | | -| diagPrint[output="config:diag_output"] |
| 119 | + |
| 120 | +Open http://localhost:2025/stream. Type in the form and submit; the pipeline echoes your input as formatted text. |
| 121 | + |
| 122 | +### With LLM |
| 123 | + |
| 124 | +```bash |
| 125 | +chatterlang_serve --port 2025 --display-property prompt --script '| llmPrompt[model="llama3.2", source="ollama", field="prompt"] | print' |
112 | 126 | ``` |
113 | 127 |
|
114 | | -Tips: |
115 | | -- Use `field_list` to print only the fields you need. |
116 | | -- `None` or `"None"` for `output` suppresses all diagnostic output. |
117 | | -- The elapsed time line shows spacing between successive items. |
| 128 | +Open http://localhost:2025/stream to chat with the LLM. |
118 | 129 |
|
119 | 130 | ## Next Steps |
120 | 131 |
|
121 | 132 | ### Learn the Tools |
122 | 133 |
|
123 | | -- **[chatterlang_serve](api-reference/chatterlang-server.md)** - Create web APIs and forms |
124 | | -- **[chatterlang_workbench](api-reference/chatterlang-workbench.md)** - Interactive development environment |
| 134 | +- **[chatterlang_serve](api-reference/chatterlang-server.md)** - Web APIs and forms |
| 135 | +- **[chatterlang_workbench](api-reference/chatterlang-workbench.md)** - Interactive development |
125 | 136 | - **[chatterlang_script](api-reference/chatterlang-script.md)** - Run scripts from files |
126 | 137 |
|
127 | 138 | ### Explore Tutorials |
128 | 139 |
|
129 | | -Check out the [tutorials directory](tutorials/) for complete tutorials: |
130 | | -- Document indexing and search |
131 | | -- RAG (Retrieval-Augmented Generation) systems |
132 | | -- Multi-format report generation |
| 140 | +[Tutorials](tutorials/) walk through document indexing, RAG, and report generation. Tutorial 1 can use the included `stories.json` if you skip the LLM data-generation step. |
133 | 141 |
|
134 | 142 | ### Extend with Plugins |
135 | 143 |
|
136 | | -TalkPipe supports plugins to add custom functionality: |
137 | | - |
138 | 144 | ```bash |
139 | | -# List installed plugins |
140 | 145 | talkpipe_plugins --list |
141 | | - |
142 | | -# Install third-party plugins |
143 | 146 | pip install talkpipe-some-plugin |
144 | 147 | ``` |
145 | 148 |
|
146 | | -Plugins automatically extend ChatterLang with new sources and segments. See [Extending TalkPipe](architecture/extending-talkpipe.md) to create your own plugins. |
| 149 | +See [Extending TalkPipe](architecture/extending-talkpipe.md) to create plugins. |
147 | 150 |
|
148 | 151 | ### Dive Deeper |
149 | 152 |
|
150 | 153 | - [Architecture](architecture/) - Technical deep-dives |
151 | | -- [API Reference](api-reference/) - Complete command reference |
152 | | - |
153 | | - |
154 | | -Ready to build something amazing? Start with the [tutorials](tutorials/)! |
| 154 | +- [API Reference](api-reference/) - Command reference |
0 commit comments