TalkPipe 0.6.0__tar.gz → 0.7.0__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.
Files changed (121) hide show
  1. {talkpipe-0.6.0 → talkpipe-0.7.0}/CHANGELOG.md +27 -0
  2. talkpipe-0.7.0/PKG-INFO +582 -0
  3. talkpipe-0.7.0/README.md +539 -0
  4. talkpipe-0.7.0/docs/.gitignore +3 -0
  5. talkpipe-0.7.0/docs/make_structure_diagram.sh +3 -0
  6. talkpipe-0.7.0/docs/structure.tex +59 -0
  7. talkpipe-0.7.0/docs/talkpipe_diagram.png +0 -0
  8. {talkpipe-0.6.0 → talkpipe-0.7.0}/pyproject.toml +2 -1
  9. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/__init__.py +2 -0
  10. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/static/unit-docs.html +151 -10
  11. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/static/unit-docs.txt +117 -6
  12. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/pipe/basic.py +44 -31
  13. talkpipe-0.7.0/src/talkpipe/search/abstract.py +64 -0
  14. talkpipe-0.7.0/src/talkpipe/search/simplevectordb.py +413 -0
  15. talkpipe-0.7.0/src/talkpipe/search/whoosh.py +324 -0
  16. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/util/data_manipulation.py +2 -2
  17. talkpipe-0.7.0/src/talkpipe.egg-info/PKG-INFO +582 -0
  18. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe.egg-info/SOURCES.txt +9 -0
  19. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe.egg-info/requires.txt +1 -0
  20. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/pipe/test_basic.py +36 -15
  21. talkpipe-0.7.0/tests/talkpipe/search/test_simplevectordb.py +179 -0
  22. talkpipe-0.7.0/tests/talkpipe/search/test_whoosh.py +204 -0
  23. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/util/test_util.py +8 -0
  24. talkpipe-0.6.0/PKG-INFO +0 -413
  25. talkpipe-0.6.0/README.md +0 -371
  26. talkpipe-0.6.0/src/talkpipe.egg-info/PKG-INFO +0 -413
  27. {talkpipe-0.6.0 → talkpipe-0.7.0}/.github/ISSUE_TEMPLATE/release-checklist.md +0 -0
  28. {talkpipe-0.6.0 → talkpipe-0.7.0}/.gitignore +0 -0
  29. {talkpipe-0.6.0 → talkpipe-0.7.0}/.vscode/settings.json +0 -0
  30. {talkpipe-0.6.0 → talkpipe-0.7.0}/.vscode/tasks.json +0 -0
  31. {talkpipe-0.6.0 → talkpipe-0.7.0}/COPYRIGHT +0 -0
  32. {talkpipe-0.6.0 → talkpipe-0.7.0}/Dockerfile +0 -0
  33. {talkpipe-0.6.0 → talkpipe-0.7.0}/LICENSE +0 -0
  34. {talkpipe-0.6.0 → talkpipe-0.7.0}/base-image/Dockerfile +0 -0
  35. {talkpipe-0.6.0 → talkpipe-0.7.0}/bin/config-analyzer.py +0 -0
  36. {talkpipe-0.6.0 → talkpipe-0.7.0}/bin/config_bash +0 -0
  37. {talkpipe-0.6.0 → talkpipe-0.7.0}/docs/LLMChat.png +0 -0
  38. {talkpipe-0.6.0 → talkpipe-0.7.0}/docs/LLMEvaluateWebPage.png +0 -0
  39. {talkpipe-0.6.0 → talkpipe-0.7.0}/docs/TalkPipe.png +0 -0
  40. {talkpipe-0.6.0 → talkpipe-0.7.0}/docs/TalkPipe.xcf +0 -0
  41. {talkpipe-0.6.0 → talkpipe-0.7.0}/pytest.ini +0 -0
  42. {talkpipe-0.6.0 → talkpipe-0.7.0}/setup.cfg +0 -0
  43. {talkpipe-0.6.0 → talkpipe-0.7.0}/setup.py +0 -0
  44. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/__init__.py +0 -0
  45. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/apiendpoint.py +0 -0
  46. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/chatcli.py +0 -0
  47. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/chatterlang_server.py +0 -0
  48. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/runscript.py +0 -0
  49. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/static/.gitignore +0 -0
  50. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/static/favicon.ico +0 -0
  51. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/app/unit_documentation_analyzer.py +0 -0
  52. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/chatterlang/__init__.py +0 -0
  53. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/chatterlang/compiler.py +0 -0
  54. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/chatterlang/parsers.py +0 -0
  55. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/chatterlang/registry.py +0 -0
  56. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/data/__init__.py +0 -0
  57. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/data/email.py +0 -0
  58. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/data/extraction.py +0 -0
  59. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/data/html.py +0 -0
  60. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/data/mongo.py +0 -0
  61. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/data/rss.py +0 -0
  62. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/jupyter/basic.py +0 -0
  63. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/jupyter/examples.py +0 -0
  64. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/jupyter/interactive.py +0 -0
  65. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/llm/__init__.py +0 -0
  66. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/llm/chat.py +0 -0
  67. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/llm/config.py +0 -0
  68. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/llm/embedding.py +0 -0
  69. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/llm/embedding_adapters.py +0 -0
  70. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/llm/prompt_adapters.py +0 -0
  71. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/operations/__init__.py +0 -0
  72. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/operations/filtering.py +0 -0
  73. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/operations/matrices.py +0 -0
  74. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/operations/signatures.py +0 -0
  75. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/operations/thread_ops.py +0 -0
  76. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/operations/transforms.py +0 -0
  77. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/pipe/__init__.py +0 -0
  78. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/pipe/core.py +0 -0
  79. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/pipe/fork.py +0 -0
  80. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/pipe/io.py +0 -0
  81. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/pipe/math.py +0 -0
  82. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/util/__init__.py +0 -0
  83. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/util/collections.py +0 -0
  84. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/util/config.py +0 -0
  85. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe/util/os.py +0 -0
  86. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe.egg-info/dependency_links.txt +0 -0
  87. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe.egg-info/entry_points.txt +0 -0
  88. {talkpipe-0.6.0 → talkpipe-0.7.0}/src/talkpipe.egg-info/top_level.txt +0 -0
  89. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/conftest.py +0 -0
  90. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/app/test_chatcli.py +0 -0
  91. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/app/test_runscript.py +0 -0
  92. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/chatterlang/test_chatterlang_server.py +0 -0
  93. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/chatterlang/test_compiler.py +0 -0
  94. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/chatterlang/test_parsers.py +0 -0
  95. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/sample_feed.pkl +0 -0
  96. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test.docx +0 -0
  97. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test_email.py +0 -0
  98. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test_extraction.py +0 -0
  99. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test_html.py +0 -0
  100. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test_html_exceptions.py +0 -0
  101. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test_mogomock.py +0 -0
  102. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test_mongo.py +0 -0
  103. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test_mongo_integration.py +0 -0
  104. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/data/test_rss.py +0 -0
  105. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/jupyter/test_basic_jupyter.py +0 -0
  106. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/jupyter/test_examples.py +0 -0
  107. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/jupyter/test_interactive.py +0 -0
  108. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/llm/test_chat.py +0 -0
  109. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/llm/test_embedding.py +0 -0
  110. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/operations/test_filtering.py +0 -0
  111. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/operations/test_matrices.py +0 -0
  112. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/operations/test_signatures.py +0 -0
  113. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/operations/test_threading.py +0 -0
  114. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/operations/test_transforms.py +0 -0
  115. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/pipe/test_core.py +0 -0
  116. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/pipe/test_fork.py +0 -0
  117. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/pipe/test_io.py +0 -0
  118. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/pipe/test_math.py +0 -0
  119. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/test_documentation_examples.py +0 -0
  120. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/talkpipe/util/test_collections.py +0 -0
  121. {talkpipe-0.6.0 → talkpipe-0.7.0}/tests/testutils.py +0 -0
@@ -1,4 +1,31 @@
1
1
  # Changelog
2
+ ## 0.7.0
3
+ ### New Segments and Sources
4
+ - **progressTicks** – Prints out a tick for every n items seen and a new line for every m ticks.
5
+ Especially useful for debugging and marking progress in logs.
6
+ - **indexWhoosh** and **searchWhoosh** – Added segments for creating and searching Whoosh
7
+ indices. This provides built-in full-text support in TalkPipe.
8
+ - **addVector** and **searchVector** – Added segments for creating and searching the simple
9
+ built-in vector store.
10
+
11
+ ### Improvements
12
+ - Rewrote firstN to use decorator syntax (making it shorter) and to not throw an exception
13
+ when there are fewer than N items.
14
+ - Created a set of protocols for search engines, both full-text and vector DB-based.
15
+ These protocols can be used to write wrappers around different search engines and
16
+ vector databases, providing a common API that can then be used in different segments
17
+ and sources.
18
+ - Integrated the Whoosh pure-Python, stand-alone search engine. This is intended for testing,
19
+ debugging, and smaller stand-alone scenarios. It allows a programmer to work on pipelines that
20
+ use full-text search engines without setting up a full search engine server. It can support
21
+ tens of thousands of smaller documents. A Python class wrapping Whoosh in a TalkPipe-like
22
+ design pattern is included, as well as segments for indexing and searching.
23
+ - Added SimpleVectorDB, a pure Python, simple vector database. It allows a programmer to build
24
+ and debug pipelines requiring simple vector databases. It supports smaller-scale databases
25
+ that can later be replaced with a separate server.
26
+ - Added a default option to extract_property and propagated the option to several segments.
27
+ - Wrote a conceptual diagram for the library and wrote short descriptions to orient people to
28
+ how the library can be used.
2
29
 
3
30
  ## 0.6.0
4
31
  ### New Segments and Sources
@@ -0,0 +1,582 @@
1
+ Metadata-Version: 2.4
2
+ Name: talkpipe
3
+ Version: 0.7.0
4
+ Summary: Python internal and external DSL for writing generative AI analytics
5
+ Author-email: Travis Bauer <tlbauer@sandia.gov>
6
+ Maintainer-email: Travis Bauer <tlbauer@sandia.gov>
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/sandialabs/talkpipe
9
+ Keywords: ai
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.11
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: prompt_toolkit
17
+ Requires-Dist: parsy
18
+ Requires-Dist: pydantic
19
+ Requires-Dist: ollama
20
+ Requires-Dist: pypdf
21
+ Requires-Dist: numpy
22
+ Requires-Dist: accelerate
23
+ Requires-Dist: python-docx
24
+ Requires-Dist: pandas
25
+ Requires-Dist: feedparser
26
+ Requires-Dist: readability-lxml
27
+ Requires-Dist: lxml[html_clean]
28
+ Requires-Dist: openai
29
+ Requires-Dist: fastapi[standard]
30
+ Requires-Dist: ipywidgets
31
+ Requires-Dist: pymongo
32
+ Requires-Dist: umap-learn
33
+ Requires-Dist: scikit-learn
34
+ Requires-Dist: cryptography
35
+ Requires-Dist: uvicorn
36
+ Requires-Dist: whoosh
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest; extra == "dev"
39
+ Requires-Dist: pytest-mock; extra == "dev"
40
+ Requires-Dist: pytest-cov; extra == "dev"
41
+ Requires-Dist: mongomock; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ <center><img src="docs/TalkPipe.png" width=500></center>
45
+
46
+ **Build and iterate on smarter AI workflows in minutes.**
47
+
48
+ TalkPipe is a Python toolkit that makes it easy to create, test, and deploy workflows that integrate Generative AI with your existing tools and data sources. TalkPipe treats LLMs as one tool in your arsenal - letting you build practical solutions that combine AI with data processing, file handling, and more.
49
+
50
+ ## What Can You Do With TalkPipe?
51
+
52
+ - **Chat with LLMs** - Create multi-turn conversations with OpenAI or Ollama models in just 2 lines of code
53
+ - **Process Documents** - Extract text from PDFs, analyze research papers, score content relevance
54
+ - **Analyze Web Content** - Download web pages (respecting robots.txt), extract readable text, and summarize
55
+ - **Build Data Pipelines** - Chain together data transformations, filtering, and analysis with Unix-like simplicity
56
+ - **Create AI Agents** - Build agents that can debate topics, evaluate streams of documents, or monitor RSS feeds
57
+ - **Deploy Anywhere** - Run in Jupyter notebooks, as Docker containers, or as standalone Python applications
58
+
59
+ ## Structure
60
+
61
+ <center><img src="docs/talkpipe_diagram.png" width=700></center>
62
+
63
+ Talkpipe is structured in five layers: Key Functionality, Pipe, ChatterLang, Applications Components, and Docker Containers.
64
+
65
+ The Key Functionality layer offers foundational utilities and abstractions that ensure consistency across the entire system. It includes configuration management, as well as standardized wrappers for interacting with LLMs, full-text search engines, and a lightweight vector database. These components provide a unified interface for core capabilities, making it easy to integrate advanced AI and search features throughout your workflows.
66
+
67
+ The Pipe layer serves as TalkPipe's internal domain-specific language (DSL), enabling you to construct sophisticated workflows directly in Python. By instantiating modular classes and chaining them together using the `|` (pipe) operator, you can seamlessly connect sources, segments, and sinks to process data in a clear, readable, and composable manner. This approach leverages Python's native syntax and type checking, allowing for rapid development, easy debugging, and full IDE support. The Pipe layer is ideal for users who prefer programmatic control and want to integrate TalkPipe pipelines into larger Python applications or scripts.
68
+
69
+ The ChatterLang layer serves as TalkPipe's external domain-specific language (DSL), enabling you to define workflows using concise, human-readable text scripts. These scripts can be compiled directly in Python, producing callable functions that integrate seamlessly with your codebase. ChatterLang also supports specifying workflows via environment variables or command-line arguments, making it easy to configure and automate pipelines in Docker containers, shell scripts, CI/CD pipelines, and other deployment environments. This flexibility empowers both developers and non-developers to create, share, and modify AI-powered workflows without writing Python code, streamlining experimentation and operationalization.
70
+
71
+ The Application Components layer contains runnable applications that provide user interfaces and automation tools for working with TalkPipe pipelines and ChatterLang scripts. These components are designed to make it easy to interact with TalkPipe from the command line, web browser, or as part of automated workflows.
72
+
73
+ ### Key Applications
74
+
75
+ - **chatterlang_server**
76
+ Launches an interactive web interface for writing, testing, and running ChatterLang scripts. It provides real-time execution, logging, and documentation lookup.
77
+
78
+ - **chatterlang_script**
79
+ Runs ChatterLang scripts from files or directly from the command line, enabling batch processing and automation.
80
+
81
+ - **talkpipe_ref**
82
+ Generates HTML and text documentation for all available sources and segments, making it easy to discover and understand built-in functionality.
83
+
84
+ - **talkpipe_endpoint**
85
+ Exposes ChatterLang pipelines as REST APIs or web forms, allowing you to deploy workflows as web services or user-facing endpoints.
86
+
87
+ These applications are entry points for different usage scenarios, from interactive development to production deployment.
88
+
89
+ The Docker layer provides ready-to-use container images for deploying TalkPipe in different environments. It includes:
90
+
91
+ - **talkpipe-base**
92
+ A minimal container image that contains all dependencies required by TalkPipe, but does not install TalkPipe itself. Use this as a foundation for building your own images, custom workflows, or CI/CD jobs where you want to control the installation of TalkPipe or add additional components.
93
+
94
+ - **chatterlang_script**
95
+ An image that installs TalkPipe on top of the base dependencies and runs a talkpipe script.
96
+
97
+ These containers exist to simplify deployment, ensure consistent environments, and enable rapid experimentation or production use of TalkPipe and ChatterLang across platforms.
98
+
99
+ ## Quick Start
100
+
101
+ Install TalkPipe:
102
+ ```bash
103
+ pip install talkpipe
104
+ ```
105
+
106
+ Create a multi-turn chat function in 2 lines:
107
+ ```python
108
+ from talkpipe.chatterlang import compiler
109
+
110
+ script = '| llmPrompt[name="llama3.2", source="ollama", multi_turn=True]'
111
+ chat = compiler.compile(script).asFunction(single_in=True, single_out=True)
112
+
113
+ response = chat("Hello! My name is Alice.")
114
+ response = chat("What's my name?") # Will remember context
115
+ ```
116
+
117
+ # Core Components
118
+
119
+ ## 1. The Pipe API (Internal DSL)
120
+
121
+ TalkPipe's Pipe API is a Pythonic way to build data pipelines using the `|` operator to chain components:
122
+
123
+ ```python
124
+ from talkpipe.pipe import io
125
+ from talkpipe.llm import chat
126
+
127
+ # Create a pipeline that prompts for input, gets an LLM response, and prints it
128
+ pipeline = io.Prompt() | chat.LLMPrompt(name="llama3.2") | io.Print()
129
+ pipeline = pipeline.asFunction()
130
+ pipeline() # Run the interactive pipeline
131
+ ```
132
+
133
+ ### Creating Custom Components
134
+
135
+ Add new functionality with simple decorators:
136
+
137
+ ```python
138
+ from talkpipe.pipe import core, io
139
+
140
+ @core.segment()
141
+ def uppercase(items):
142
+ """Convert each item to uppercase"""
143
+ for item in items:
144
+ yield item.upper()
145
+
146
+ # Use it in a pipeline
147
+ pipeline = io.echo(data="hello,world") | uppercase() | io.Print()
148
+ result = pipeline.asFunction(single_out=False)()
149
+
150
+ # Output:
151
+ # HELLO
152
+ # WORLD
153
+ # Returns: ['HELLO', 'WORLD']
154
+ ```
155
+
156
+ ## 2. ChatterLang (External DSL)
157
+
158
+ ChatterLang provides a Unix-like syntax for building pipelines, perfect for rapid prototyping and experimentation:
159
+
160
+ ```
161
+ INPUT FROM echo[data="1,2,hello,3"] | cast[cast_type="int"] | print
162
+ ```
163
+
164
+ ### Key ChatterLang Features
165
+
166
+ - **Variables**: Store intermediate results with `@variable_name`
167
+ - **Constants**: Define reusable values with `CONST name = "value"`
168
+ - **Loops**: Repeat operations with `LOOP n TIMES { ... }`
169
+ - **Multiple Pipelines**: Chain workflows with `;` or newlines
170
+
171
+ ## 3. Built-in Applications
172
+
173
+ ### Interactive Web Interface
174
+ ```bash
175
+ chatterlang_server [--port 8080]
176
+ ```
177
+ A web UI for writing and testing ChatterLang scripts with real-time execution and logging.
178
+
179
+ ### Command-Line Tools
180
+ - `chatterlang_server` - Start the interactive web interface for experimenting with ChatterLang
181
+ - `chatterlang_script` - Run ChatterLang scripts from files or command line
182
+ - `talkpipe_ref` - Generate documentation for all available sources and segments
183
+ - `talkpipe_endpoint` - Create a customizable user-accessible web interface and REST API from ChatterLang scripts
184
+
185
+ ### Jupyter Integration
186
+ TalkPipe components work seamlessly in Jupyter notebooks for interactive data analysis.
187
+
188
+ # Detailed Examples
189
+
190
+ ## Example 1: Multi-Agent Debate
191
+
192
+ Create agents with different perspectives that debate a topic:
193
+
194
+ ```python
195
+ from talkpipe.chatterlang import compiler
196
+
197
+ script = """
198
+ CONST economist_prompt = "You are an economist. Reply in one sentence.";
199
+ CONST theologian_prompt = "You are a theologian. Reply in one sentence.";
200
+
201
+ INPUT FROM echo[data="The US should give free puppies to all children."]
202
+ | @topic
203
+ | accum[variable=@conversation]
204
+ | print;
205
+
206
+ LOOP 3 TIMES {
207
+ INPUT FROM @topic
208
+ | llmPrompt[system_prompt=economist_prompt]
209
+ | @topic
210
+ | accum[variable=@conversation]
211
+ | print;
212
+
213
+ INPUT FROM @topic
214
+ | llmPrompt[system_prompt=theologian_prompt]
215
+ | @topic
216
+ | accum[variable=@conversation]
217
+ | print;
218
+ };
219
+
220
+ INPUT FROM @conversation
221
+ """
222
+
223
+ pipeline = compiler.compile(script).asFunction()
224
+ debate = pipeline() # Watch the debate unfold!
225
+ ```
226
+
227
+ ## Example 2: Document Stream Evaluation
228
+
229
+ Score documents based on relevance to a topic:
230
+
231
+ ```python
232
+ import pandas as pd
233
+ from talkpipe.chatterlang import compiler
234
+
235
+ # Sample document data
236
+ documents = [
237
+ '{"title": "Dog", "description": "Dogs are loyal companions..."}',
238
+ '{"title": "Cat", "description": "Cats are independent pets..."}',
239
+ '{"title": "Wolf", "description": "Wolves are wild canines..."}'
240
+ ]
241
+
242
+ script = """
243
+ CONST scorePrompt = "Rate 1-10 how related to dogs this is:";
244
+
245
+ | loadsJsonl
246
+ | llmScore[system_prompt=scorePrompt, name="llama3.2", append_as="dog_relevance"]
247
+ | appendAs[field_list="dog_relevance.score:relevance_score"]
248
+ | toDataFrame
249
+ """
250
+
251
+ pipeline = compiler.compile(script).asFunction(single_in=False, single_out=True)
252
+ df = pipeline(documents)
253
+ # df now contains relevance scores for each document
254
+ ```
255
+
256
+ ## Example 3: Web Page Analysis
257
+
258
+ Download and summarize web content:
259
+
260
+ ```python
261
+ from talkpipe.chatterlang import compiler
262
+
263
+ script = """
264
+ | downloadURL
265
+ | htmlToText
266
+ | llmPrompt[
267
+ system_prompt="Summarize this article in 3 bullet points",
268
+ name="llama3.2"
269
+ ]
270
+ | print
271
+ """
272
+
273
+ analyzer = compiler.compile(script).asFunction(single_in=True)
274
+ analyzer("https://example.com/")
275
+ ```
276
+
277
+ ## Example 4: Content Evaluation Pipeline
278
+
279
+ Evaluate and filter articles based on relevance scores:
280
+
281
+ ```python
282
+ from talkpipe.chatterlang import compiler
283
+
284
+ # Sample article data
285
+ articles = [
286
+ '{"title": "New LLM Model Released", "summary": "AI Company announces new LLM with improved reasoning"}',
287
+ '{"title": "Smart Home IoT Devices", "summary": "Review of latest Arduino-based home automation"}',
288
+ '{"title": "Cat Videos Go Viral", "summary": "Funny cats take over social media again"}',
289
+ '{"title": "RAG Systems in Production", "summary": "How companies deploy retrieval-augmented generation"}',
290
+ ]
291
+
292
+ script = """
293
+ # Define evaluation prompts
294
+ CONST ai_prompt = "Rate 0-10 how relevant this is to AI practitioners. Consider mentions of AI, ML, algorithms, or applications.";
295
+ CONST iot_prompt = "Rate 0-10 how relevant this is to IoT researchers. Consider hardware, sensors, or embedded systems.";
296
+
297
+ # Process articles
298
+ | loadsJsonl
299
+ | concat[fields="title,summary", append_as="full_text"]
300
+
301
+ # Score for AI relevance
302
+ | llmScore[system_prompt=ai_prompt, field="full_text", append_as="ai_eval", name="llama3.2"]
303
+ | appendAs[field_list="ai_eval.score:ai_score,ai_eval.explanation:ai_reason"]
304
+
305
+ # Score for IoT relevance
306
+ | llmScore[system_prompt=iot_prompt, field="full_text", append_as="iot_eval", name="llama3.2"]
307
+ | appendAs[field_list="iot_eval.score:iot_score,iot_eval.explanation:iot_reason"]
308
+
309
+ # Find highest score
310
+ | lambda[expression="max(item['ai_score'],item['iot_score'])", append_as="max_score"]
311
+
312
+ # Filter articles with score > 6
313
+ | gt[field="max_score", n=6]
314
+
315
+ # Format output
316
+ | toDict[field_list="title,ai_score,iot_score,max_score"]
317
+ | print
318
+ """
319
+
320
+ evaluator = compiler.compile(script).asFunction(single_in=False, single_out=False)
321
+ results = evaluator(articles)
322
+
323
+ # Output shows only relevant articles with their scores:
324
+ # {'title': 'New LLM Model Released', 'ai_score': 9, 'iot_score': 2, 'max_score': 9}
325
+ # {'title': 'Smart Home IoT Devices', 'ai_score': 3, 'iot_score': 9, 'max_score': 9}
326
+ # {'title': 'RAG Systems in Production', 'ai_score': 8, 'iot_score': 2, 'max_score': 8}
327
+ ```
328
+
329
+ # Architecture & Development
330
+
331
+ ## Design Principles
332
+
333
+ ### Dual-Language Architecture
334
+ - **Internal DSL (Pipe API)**: Pure Python for maximum flexibility and IDE support
335
+ - **External DSL (ChatterLang)**: Concise syntax for rapid prototyping
336
+
337
+ ### Streaming Architecture
338
+ TalkPipe uses Python generators throughout, enabling:
339
+ - Memory-efficient processing of large datasets
340
+ - Real-time results as data flows through pipelines
341
+ - Natural integration with streaming data sources
342
+
343
+ ### Extensibility First
344
+ - Simple decorators (`@source`, `@segment`, `@field_segment`) for adding functionality
345
+ - Components are just Python functions - easy to test and debug
346
+ - Mix TalkPipe with any Python code or library
347
+
348
+ ## Project Structure
349
+
350
+ ```
351
+ talkpipe/
352
+ ├── app/ # Runnable applications (servers, CLIs)
353
+ ├── chatterlang/ # ChatterLang parser, compiler, and components
354
+ ├── data/ # Data manipulation and I/O components
355
+ ├── llm/ # LLM integrations (OpenAI, Ollama)
356
+ ├── operations/ # Algorithms and data processing
357
+ └── pipe/ # Core pipeline infrastructure
358
+ ```
359
+
360
+ ## Configuration
361
+
362
+ TalkPipe uses a flexible configuration system via `~/.talkpipe.toml` or environment variables:
363
+
364
+ ```toml
365
+ # ~/.talkpipe.toml
366
+ default_model_name = "llama3.2"
367
+ default_model_source = "ollama"
368
+ smtp_server = "smtp.gmail.com"
369
+ smtp_port = 587
370
+ ```
371
+
372
+ Environment variables use the `TALKPIPE_` prefix:
373
+ ```bash
374
+ export TALKPIPE_email_password="your-password"
375
+ export TALKPIPE_openai_api_key="sk-..."
376
+ ```
377
+
378
+ ## Development Guidelines
379
+
380
+ ### Naming Conventions
381
+ - **Classes**: `CamelCase` (e.g., `LLMPrompt`)
382
+ - **Decorated functions**: `camelCase` (e.g., `@segment def extractText`)
383
+ - **ChatterLang names**: `camelCase` (e.g., `llmPrompt`, `toDataFrame`)
384
+
385
+ ### Creating Components
386
+
387
+ **Sources** generate data:
388
+ ```python
389
+ from talkpipe.pipe import core, io
390
+
391
+ @core.source()
392
+ def fibonacci(n=10):
393
+ a, b = 0, 1
394
+ for _ in range(n):
395
+ yield a
396
+ a, b = b, a + b
397
+
398
+ # Use it in a pipeline
399
+ pipeline = fibonacci(n=5) | io.Print()
400
+ result = pipeline.asFunction(single_out=False)()
401
+
402
+ # Output:
403
+ # 0
404
+ # 1
405
+ # 1
406
+ # 2
407
+ # 3
408
+ # Returns: [0, 1, 1, 2, 3]
409
+ ```
410
+
411
+ **Segments** transform data:
412
+ ```python
413
+ @core.segment()
414
+ def multiplyBy(items, factor=2):
415
+ for item in items:
416
+ yield item * factor
417
+
418
+ # Use it to double the Fibonacci numbers
419
+ pipeline = fibonacci(n=5) | multiplyBy(factor=3) | io.Print()
420
+ result = pipeline.asFunction(single_out=False)()
421
+
422
+ # Output:
423
+ # 0
424
+ # 3
425
+ # 3
426
+ # 6
427
+ # 9
428
+ # Returns: [0, 3, 3, 6, 9]
429
+ ```
430
+
431
+ **Field Segments** provide a convenient way to create 1:1 segments:
432
+ ```python
433
+ from datetime import datetime
434
+ from talkpipe.chatterlang import registry
435
+
436
+ @registry.register_segment("addTimestamp")
437
+ @core.field_segment()
438
+ def addTimestamp(item):
439
+ # Handle a single item, not an iterable
440
+ # The decorator handles append_as and field parameters automatically
441
+ return datetime.now()
442
+
443
+ # Use it with dictionaries
444
+ data = [{'name': 'Alice'}, {'name': 'Bob'}]
445
+ pipeline = addTimestamp(append_as="timestamp") | io.Print()
446
+
447
+ result = pipeline.asFunction(single_in=False, single_out=False)(data)
448
+
449
+ # Output (timestamps will vary):
450
+ # {'name': 'Alice', 'timestamp': datetime.datetime(2024, 1, 15, 10, 30, 45, 123456)}
451
+ # {'name': 'Bob', 'timestamp': datetime.datetime(2024, 1, 15, 10, 30, 45, 234567)}
452
+
453
+ # Now it's also available in ChatterLang:
454
+ # script = '| addTimestamp[append_as="timestamp"] | print'
455
+ ```
456
+
457
+ ### Best Practices
458
+
459
+ 1. **Units with side effects should pass data through** - e.g., `writeFile` should yield items after writing
460
+ 2. **Use descriptive parameter names** with underscores (e.g., `fail_on_error`, `append_as`)
461
+ 3. **Handle errors gracefully** - use `fail_on_error` parameter pattern
462
+ 4. **Document with docstrings** - they appear in generated documentation
463
+ 5. **Test with both APIs** - ensure components work in both Python and ChatterLang
464
+
465
+ ## Roadmap & Contributing
466
+
467
+ TalkPipe is under active development. Current priorities:
468
+
469
+ - **Enhanced LLM Support**: Additional providers (Anthropic, Cohere, local models)
470
+ - **Data Connectors**: More database integrations, API clients, file formats
471
+ - **Workflow Features**: Conditional branching, error handling, retry logic
472
+ - **Performance**: Parallel processing, caching, optimization
473
+ - **Developer Tools**: Better debugging, testing utilities, IDE plugins
474
+
475
+ We welcome contributions! Whether it's new components, bug fixes, documentation, or examples, please check our [GitHub repository](https://github.com/sandialabs/talkpipe) for contribution guidelines.
476
+
477
+ ## Status
478
+
479
+ TalkPipe is currently in active development. While feature-rich and actively used, APIs may evolve. We follow semantic versioning - minor versions maintain compatibility within the same major version, while major version changes may include breaking changes.
480
+
481
+ ## License
482
+
483
+ TalkPipe is licensed under the Apache License 2.0. See LICENSE file for details.
484
+
485
+ # Developer Documentation
486
+
487
+ ## Glossary
488
+
489
+ * **Segment** - A unit that reads from another Unit and may or may not yield data of its own. All units that
490
+ are not at the start of a pipeline is a Segment.
491
+ * **Source** - A unit that takes nothing as input and yields data items. These Units are used in the
492
+ "INPUT FROM..." portion of a pipeline.
493
+ * **Unit** - A component in a pipeline that either produces or processes data. There are two types of units, Source, and Segments.
494
+
495
+ ## Conventions
496
+
497
+ ### Versioning
498
+
499
+ This codebase will use [semantic versioning](https://semver.org/) with the addtional convention that during the 0.x.y development that each MINOR version will maintain backward compatibility and PATCH versions will include substantial new capability. So, for example, every 0.2.x version will be backward compatible, but 0.3.0 might contain code reorganization.
500
+
501
+ ### Codebase Structure
502
+
503
+ The following are the main breakdown of the codebase. These should be considered firm but not strict breakdowns. Sometimes a source could fit within either operations or data, for exmaple.
504
+
505
+ * **talkpipe.app** - Contains the primary runnable applications.
506
+ * Example: runscript
507
+ * **talkpipe.operations** - Contains general algorithm implementations. Associated segments and sources can be included next to the algorithm implementations, but the algorithms themselves should also work stand-alone.
508
+ * Exmaple: bloom filters
509
+ * **talkpipe.data** - Contain components having to do with complex, type-specific data manipulation.
510
+ * Example: extracting text from files.
511
+ * **talkpipe.llm** - Contain the abstract classes and implementations for accessing LLMs, both code for accessing specific LLMs and code for doing prompting.
512
+ * Example: Code for talking with Ollama or OpenAI
513
+ * **talkpipe.pipe** - Code that implements the core classes and decorators for the pipe api as well and misc implementations of helper segments and sources.
514
+ * Example: echo and the definition of the @segment decorator
515
+ * **talkpipe.chatterlang** - The definition, parsers, and compiler for the chatterlang language as well as any chatterlang specific segments and sources
516
+ * Example: the chatterlang compiler and the variable segment
517
+
518
+ ### Source/Segment Names
519
+
520
+ - **For your own Units, do whatever you want!** These conventions are for authors writing units intended for broader reuse.
521
+ - **Classes that implement Units** are named in CamelCase with the initial letter in uppercase.
522
+ - **Units defined using `@segment` and `@source` decorators** should be named in camelCase with an initial lowercase letter.
523
+ - In **ChatterLang**, sources and segments also use camelCase with an initial lowercase letter.
524
+ - Except for the **`cast`** segment, segments that convert data into a specific format—whether they process items one-by-one or drain the entire input—should be named using the form `[tT]oX`, where **X** is the output data type (e.g., `toDataFrame` outputs a pandas DataFrame).
525
+ - **Segments that write files** use the form `[Ww]riteX`, where **X** is the file type (e.g., `writeExcel` writes an Excel file, `writePickle` writes a pickle file).
526
+ - **Segments that read files** use the form `[Rr]eadX`, where **X** is the file type (e.g., `readExcel` should read an Excel file).
527
+ - **Parameter names in segments** should be in all lower case with words separated by an underscore (_)
528
+
529
+ ### Parameter Names
530
+
531
+ These parameter names should behave consistently across all units:
532
+
533
+ - **append_as**
534
+ If used, any processed output is attached to the original data using bracket notation. The original item is then emitted.
535
+
536
+ - **fail_on_error**
537
+ If True, an operation the exception should be raised, likely aborting the pipeline. If False, the operation should continue
538
+ and either None should be yielded or nothing, depending on the segment or source. A warning message should be logged.
539
+
540
+ - **field**
541
+ Specifies that the unit should operate on data accessed via “field syntax.” This syntax can include indices, properties, or parameter-free methods, separated by periods.
542
+ - For example, given `{"X": ["a", "b", ["c", "d"]]}`, the field `"X.2.0"` refers to `"c"`.
543
+
544
+ - **field_list**
545
+ Specifies that a list of fields can or shoudl be provided, with each field separated
546
+ by a comma. In some cases, each field needs to be mapped to some other name. In
547
+ those case, the field and name should be separated by a colon. In field_lists,
548
+ the underscore (_) refers to the item as a whole.
549
+ - For example, "X.2.0:SomeName,X.1:SomeOtherName". If no "name" is provided,
550
+ the fieldname itself is used. Where only a list of fields is needed and no names,
551
+ the names can still be provided but have no effect.
552
+
553
+ ### General Behavior Principles
554
+
555
+ * Units that have side effects (e.g. writing data to a disk) should generally also pass
556
+ on their data.
557
+
558
+ ### Source and Segement Reference
559
+
560
+ The chatterlang_server command starts a web service designed for experimentation. It also contains links to HTML and text versions
561
+ of all the sources and segments included in TalkPipe.
562
+
563
+ After talkpipe is installed, a script called "talkpipe_ref" is avaialble that will write an HTML and text file in the current directory, each of which contains the documentation for build-in sources and segments.
564
+
565
+ ### Standard Configuration File Items
566
+
567
+ Configuration constants can be defined either in ~/.talkpipe.toml or in environment variables. Any constant defined in an environment variable needs to be prefixed with TALKPIPE_. So email_password, stored in an environment variable, needs to be TALKPIPE_email_password. Note that in Chatterlang, any variable stored in the format
568
+ can be specified as a parameter using $var_name. This will get dereferenced to
569
+ the environment varaible TALKPIPE_var_name or var_name in talkpipe.toml.
570
+
571
+ * **default_embedding_source** - The default source (e.g. ollama) to be used for creating sentence embeddings.
572
+ * **default_embedding_model_name** - The name of the LLM model to be used for creating sentence embeddings.
573
+ * **default_model_name** - The default name of a LLM model to be used in chat
574
+ * **default_model_source** - The default source (e.g. ollama) to be used in chat
575
+ * **email_password** - Password for the SMTP server
576
+ * **logger_files** - Files to store logs, in the form logger1:fname1,logger2:fname2,...
577
+ * **logger_levels** - Logger levles in the form logger1:level1,logger2:level2
578
+ * **recipient_email** - Who should receive a sent email
579
+ * **rss_url** - The default URL used by the rss segment
580
+ * **sender_email** - Who the sender of an email should be
581
+ * **smtp_port** - SMTP server port
582
+ * **smtp_server** - SMTP server hostname