TalkPipe 0.4.1__tar.gz → 0.4.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.
Files changed (109) hide show
  1. {talkpipe-0.4.1 → talkpipe-0.4.2}/.github/ISSUE_TEMPLATE/release-checklist.md +1 -0
  2. {talkpipe-0.4.1 → talkpipe-0.4.2}/.vscode/settings.json +0 -5
  3. {talkpipe-0.4.1 → talkpipe-0.4.2}/CHANGELOG.md +17 -1
  4. {talkpipe-0.4.1 → talkpipe-0.4.2}/Dockerfile +4 -6
  5. {talkpipe-0.4.1 → talkpipe-0.4.2}/PKG-INFO +1 -1
  6. talkpipe-0.4.2/base-image/Dockerfile +19 -0
  7. talkpipe-0.4.2/pytest.ini +3 -0
  8. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/app/static/unit-docs.html +178 -23
  9. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/app/static/unit-docs.txt +131 -18
  10. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/chatterlang/compiler.py +30 -3
  11. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/data/html.py +8 -1
  12. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/data/rss.py +2 -2
  13. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/llm/prompt_adapters.py +47 -1
  14. talkpipe-0.4.2/src/talkpipe/pipe/math.py +201 -0
  15. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe.egg-info/PKG-INFO +1 -1
  16. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe.egg-info/SOURCES.txt +1 -0
  17. talkpipe-0.4.2/tests/conftest.py +153 -0
  18. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/app/test_chatcli.py +1 -2
  19. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/chatterlang/test_compiler.py +47 -0
  20. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/chatterlang/test_parsers.py +1 -0
  21. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test_html.py +7 -5
  22. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test_mongo.py +1 -1
  23. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test_mongo_integration.py +2 -2
  24. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/llm/test_chat.py +14 -14
  25. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/llm/test_embedding.py +2 -4
  26. talkpipe-0.4.2/tests/talkpipe/pipe/test_math.py +43 -0
  27. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/test_documentation_examples.py +3 -6
  28. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/testutils.py +60 -25
  29. talkpipe-0.4.1/pytest.ini +0 -5
  30. talkpipe-0.4.1/src/talkpipe/pipe/math.py +0 -81
  31. talkpipe-0.4.1/tests/conftest.py +0 -78
  32. talkpipe-0.4.1/tests/talkpipe/pipe/test_math.py +0 -15
  33. {talkpipe-0.4.1 → talkpipe-0.4.2}/.gitignore +0 -0
  34. {talkpipe-0.4.1 → talkpipe-0.4.2}/.vscode/tasks.json +0 -0
  35. {talkpipe-0.4.1 → talkpipe-0.4.2}/COPYRIGHT +0 -0
  36. {talkpipe-0.4.1 → talkpipe-0.4.2}/LICENSE +0 -0
  37. {talkpipe-0.4.1 → talkpipe-0.4.2}/README.md +0 -0
  38. {talkpipe-0.4.1 → talkpipe-0.4.2}/bin/config-analyzer.py +0 -0
  39. {talkpipe-0.4.1 → talkpipe-0.4.2}/bin/config_bash +0 -0
  40. {talkpipe-0.4.1 → talkpipe-0.4.2}/docs/LLMChat.png +0 -0
  41. {talkpipe-0.4.1 → talkpipe-0.4.2}/docs/LLMEvaluateWebPage.png +0 -0
  42. {talkpipe-0.4.1 → talkpipe-0.4.2}/docs/TalkPipe.png +0 -0
  43. {talkpipe-0.4.1 → talkpipe-0.4.2}/docs/TalkPipe.xcf +0 -0
  44. {talkpipe-0.4.1 → talkpipe-0.4.2}/pyproject.toml +0 -0
  45. {talkpipe-0.4.1 → talkpipe-0.4.2}/setup.cfg +0 -0
  46. {talkpipe-0.4.1 → talkpipe-0.4.2}/setup.py +0 -0
  47. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/__init__.py +0 -0
  48. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/app/chatcli.py +0 -0
  49. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/app/runscript.py +0 -0
  50. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/app/scriptendpoint.py +0 -0
  51. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/app/static/.gitignore +0 -0
  52. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/app/static/favicon.ico +0 -0
  53. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/app/unit_documentation_analyzer.py +0 -0
  54. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/chatterlang/__init__.py +0 -0
  55. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/chatterlang/parsers.py +0 -0
  56. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/chatterlang/registry.py +0 -0
  57. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/data/__init__.py +0 -0
  58. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/data/email.py +0 -0
  59. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/data/extraction.py +0 -0
  60. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/data/mongo.py +0 -0
  61. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/jupyter/basic.py +0 -0
  62. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/jupyter/examples.py +0 -0
  63. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/jupyter/interactive.py +0 -0
  64. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/llm/__init__.py +0 -0
  65. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/llm/chat.py +0 -0
  66. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/llm/config.py +0 -0
  67. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/llm/embedding.py +0 -0
  68. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/llm/embedding_adapters.py +0 -0
  69. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/operations/__init__.py +0 -0
  70. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/operations/filtering.py +0 -0
  71. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/operations/matrices.py +0 -0
  72. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/operations/threading.py +0 -0
  73. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/operations/transforms.py +0 -0
  74. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/pipe/__init__.py +0 -0
  75. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/pipe/basic.py +0 -0
  76. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/pipe/core.py +0 -0
  77. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/pipe/fork.py +0 -0
  78. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/pipe/io.py +0 -0
  79. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/util/__init__.py +0 -0
  80. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/util/collections.py +0 -0
  81. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/util/config.py +0 -0
  82. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/util/data_manipulation.py +0 -0
  83. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe/util/os.py +0 -0
  84. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe.egg-info/dependency_links.txt +0 -0
  85. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe.egg-info/entry_points.txt +0 -0
  86. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe.egg-info/requires.txt +0 -0
  87. {talkpipe-0.4.1 → talkpipe-0.4.2}/src/talkpipe.egg-info/top_level.txt +0 -0
  88. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/app/test_runscript.py +0 -0
  89. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/chatterlang/test_scriptendpoint.py +0 -0
  90. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/sample_feed.pkl +0 -0
  91. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test.docx +0 -0
  92. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test_email.py +0 -0
  93. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test_extraction.py +0 -0
  94. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test_html_exceptions.py +0 -0
  95. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test_mogomock.py +0 -0
  96. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/data/test_rss.py +0 -0
  97. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/jupyter/test_basic_jupyter.py +0 -0
  98. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/jupyter/test_examples.py +0 -0
  99. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/jupyter/test_interactive.py +0 -0
  100. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/operations/test_filtering.py +0 -0
  101. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/operations/test_matrices.py +0 -0
  102. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/operations/test_threading.py +0 -0
  103. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/operations/test_transforms.py +0 -0
  104. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/pipe/test_basic.py +0 -0
  105. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/pipe/test_core.py +0 -0
  106. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/pipe/test_fork.py +0 -0
  107. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/pipe/test_io.py +0 -0
  108. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/util/test_collections.py +0 -0
  109. {talkpipe-0.4.1 → talkpipe-0.4.2}/tests/talkpipe/util/test_util.py +0 -0
@@ -14,6 +14,7 @@ assignees: ''
14
14
  - [ ] Build docker image
15
15
  - [ ] Tag repository
16
16
  - [ ] Build whl files
17
+ - [ ] Install whl file in new environment and test a script in chatterlang_server
17
18
  - [ ] Push to pypi
18
19
  - [ ] Push code to repo
19
20
  - [ ] Push tags to repo
@@ -1,9 +1,4 @@
1
1
  {
2
- "python.testing.pytestArgs": [
3
- "tests",
4
- "-m",
5
- "not ddg"
6
- ],
7
2
  "python.testing.unittestEnabled": false,
8
3
  "python.testing.pytestEnabled": true,
9
4
  "terminal.integrated.env.osx": {
@@ -1,6 +1,22 @@
1
1
  # Changelog
2
2
 
3
- ## 0.4.0
3
+ ## 0.4.2 (in progress)
4
+ ### New Segments
5
+ - snippet - lets the script writer either load chatterlang code from a file or provide it as a parameter.
6
+ - Abstracted the comparison filter used for gt and lt
7
+ - Added filters for gte (greater than or equal), lte (less than or equal), eq (equal) and neq (not equal)
8
+ ### Improvements
9
+ - Reconfigured the Docker containers so that there is a base container with the pre-requisites and one for talkpipe.
10
+ This reduces the time needed to build a talkpipe container if the base already exists.
11
+ - Retooled unit tests to eliminate the "online" fixture, replacing it with something that checks if ollama and mongo are
12
+ available locally and skipping tests that require them if they are not available.
13
+ ### Bug Fixes
14
+ - Fixed error in rss.py causing a crash if the URL was specified in the configuration file or environment variable
15
+ - Handled code where robots.txt response is returned compressed. It now decompresses it rather than erroring out.
16
+
17
+
18
+
19
+ ## 0.4.1
4
20
  - Updated syntax so that pipelines in forks can contain more than one segment. This was an oversight in the original design.
5
21
  - Added the mongoInsert and mongoSearch segments
6
22
  - Generalized LLM source so that new ones can be registered and used without modifying TalkPipe
@@ -1,4 +1,4 @@
1
- FROM python:3.11
1
+ FROM talkpipe:base
2
2
 
3
3
  WORKDIR /app
4
4
 
@@ -17,10 +17,8 @@ COPY .git/ .git/
17
17
 
18
18
  RUN pip install --upgrade pip
19
19
  RUN pip install -e .[dev]
20
- RUN pytest -m "not online" --log-cli-level=DEBUG
21
- # RUN pip install -e .
22
-
23
- # Install the basics of the scientific computing stack for analytics
24
- RUN pip install numpy pandas matplotlib scikit-learn scipy
20
+ RUN pytest --log-cli-level=DEBUG
21
+ RUN rm -fr .git
22
+ RUN rm -fr tests
25
23
 
26
24
  CMD ["python", "-m", "talkpipe.app.runscript", "--load_module", "data/custom_module.py", "--env", "TALKPIPE_SCRIPT"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: talkpipe
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: Python internal and external DSL for writing generative AI analytics
5
5
  Author-email: Travis Bauer <tlbauer@sandia.gov>
6
6
  Maintainer-email: Travis Bauer <tlbauer@sandia.gov>
@@ -0,0 +1,19 @@
1
+ FROM python:3.11
2
+
3
+ # Set working directory
4
+ WORKDIR /app
5
+
6
+ # Install PDM
7
+ RUN pip install pdm
8
+
9
+ # Copy pyproject.toml into the container
10
+ COPY pyproject.toml ./pyproject.toml
11
+
12
+ # Run pdm lock, export deps to requirements.txt, and install
13
+ RUN pdm lock && \
14
+ pdm export --without-hashes --dev -o requirements.txt && \
15
+ pip install -r requirements.txt && \
16
+ rm requirements.txt
17
+
18
+ # Install the basics of the scientific computing stack for analytics
19
+ RUN pip install numpy pandas matplotlib scikit-learn scipy
@@ -0,0 +1,3 @@
1
+ [pytest]
2
+ log_level = DEBUG
3
+
@@ -110,6 +110,11 @@
110
110
  <td class="toc-talkpipe">accum</td>
111
111
  <td class="toc-description">Accumulates items from the input stream both in an internal buffer and in the specified variable.</td>
112
112
  </tr>
113
+ <tr>
114
+ <td class="toc-name"><a href="#talkpipe-chatterlang-compiler-Snippet">Snippet</a></td>
115
+ <td class="toc-talkpipe">snippet</td>
116
+ <td class="toc-description">A segment that loads a chatterlang script from a file and compiles it, after which it</td>
117
+ </tr>
113
118
  <tr><td class="toc-package" colspan="3"><a href="#talkpipe-data-email">talkpipe.data.email</a></td></tr>
114
119
  <tr>
115
120
  <td class="toc-name"><a href="#talkpipe-data-email-sendEmail">sendEmail</a></td>
@@ -357,18 +362,38 @@
357
362
  <tr>
358
363
  <td class="toc-name"><a href="#talkpipe-pipe-math-arange">arange</a></td>
359
364
  <td class="toc-talkpipe">range</td>
360
- <td class="toc-description">Generate a range of integers between lower and upper</td>
365
+ <td class="toc-description">Generate a range of integers between lower (inclusive) and upper (exclusive)</td>
366
+ </tr>
367
+ <tr>
368
+ <td class="toc-name"><a href="#talkpipe-pipe-math-eq">eq</a></td>
369
+ <td class="toc-talkpipe">eq</td>
370
+ <td class="toc-description">Filter items where a specified field&#x27;s value equals a number.</td>
361
371
  </tr>
362
372
  <tr>
363
373
  <td class="toc-name"><a href="#talkpipe-pipe-math-gt">gt</a></td>
364
374
  <td class="toc-talkpipe">gt</td>
365
375
  <td class="toc-description">Filter items where a specified field&#x27;s value is greater than a number.</td>
366
376
  </tr>
377
+ <tr>
378
+ <td class="toc-name"><a href="#talkpipe-pipe-math-gte">gte</a></td>
379
+ <td class="toc-talkpipe">gte</td>
380
+ <td class="toc-description">Filter items where a specified field&#x27;s value is greater than or equal to a number.</td>
381
+ </tr>
367
382
  <tr>
368
383
  <td class="toc-name"><a href="#talkpipe-pipe-math-lt">lt</a></td>
369
384
  <td class="toc-talkpipe">lt</td>
370
385
  <td class="toc-description">Filters items based on a field value being less than a specified number.</td>
371
386
  </tr>
387
+ <tr>
388
+ <td class="toc-name"><a href="#talkpipe-pipe-math-lte">lte</a></td>
389
+ <td class="toc-talkpipe">lte</td>
390
+ <td class="toc-description">Filter items where a specified field&#x27;s value is less than or equal to a number.</td>
391
+ </tr>
392
+ <tr>
393
+ <td class="toc-name"><a href="#talkpipe-pipe-math-neq">neq</a></td>
394
+ <td class="toc-talkpipe">neq</td>
395
+ <td class="toc-description">Filter items where a specified field&#x27;s value does not equal a number.</td>
396
+ </tr>
372
397
  <tr>
373
398
  <td class="toc-name"><a href="#talkpipe-pipe-math-randomInts">randomInts</a></td>
374
399
  <td class="toc-talkpipe">randomInts</td>
@@ -400,6 +425,22 @@ Args:
400
425
  </ul>
401
426
  <p><strong>Base Classes:</strong> io.AbstractSegment</p>
402
427
  </div>
428
+ <div class="class" id="talkpipe-chatterlang-compiler-Snippet">
429
+ <h2>Segment Class: Snippet</h2>
430
+ <p class="talkpipe-name">Chatterlang Name: snippet</p>
431
+ <div><pre>A segment that loads a chatterlang script from a file and compiles it, after which it
432
+ functions as a normal segment that can be integrated into a pipeline.
433
+
434
+ Args:
435
+ file (str): The path to the chatterlang script file.
436
+ runtime (RuntimeComponent, optional): The runtime component to use. Defaults to None.</pre></div>
437
+ <h3>Parameters:</h3>
438
+ <ul class="param-list">
439
+ <li>self</li>
440
+ <li>script_source: str</li>
441
+ </ul>
442
+ <p><strong>Base Classes:</strong> io.AbstractSegment</p>
443
+ </div>
403
444
  <div class="package-header" id="talkpipe-data-email">talkpipe.data.email</div>
404
445
  <div class="function" id="talkpipe-data-email-sendEmail">
405
446
  <h2>Segment Function: sendEmail</h2>
@@ -1339,68 +1380,182 @@ Args:
1339
1380
  <div class="function" id="talkpipe-pipe-math-arange">
1340
1381
  <h2>Source Function: arange</h2>
1341
1382
  <p class="talkpipe-name">Chatterlang Name: range</p>
1342
- <div><pre>Generate a range of integers between lower and upper</pre></div>
1383
+ <div><pre>Generate a range of integers between lower (inclusive) and upper (exclusive)
1384
+
1385
+ This segment wraps the built-in range function, allowing you to specify
1386
+ the lower and upper bounds of the range. The range is inclusive of the
1387
+ lower bound and exclusive of the upper bound.
1388
+
1389
+ Args:
1390
+ lower (int): Lower bound of the range (inclusive)
1391
+ upper (int): Upper bound of the range (exclusive)</pre></div>
1343
1392
  <h3>Parameters:</h3>
1344
1393
  <ul class="param-list">
1345
1394
  <li>lower</li>
1346
1395
  <li>upper</li>
1347
1396
  </ul>
1348
1397
  </div>
1349
- <div class="function" id="talkpipe-pipe-math-gt">
1350
- <h2>Segment Function: gt</h2>
1398
+ <div class="class" id="talkpipe-pipe-math-eq">
1399
+ <h2>Segment Class: eq</h2>
1400
+ <p class="talkpipe-name">Chatterlang Name: eq</p>
1401
+ <div><pre>Filter items where a specified field's value equals a number.
1402
+
1403
+ For each item passed in, this segment yields only those where the value of the specified field
1404
+ is equal to the given number n.
1405
+
1406
+ Args:
1407
+ items: Iterable of items to filter
1408
+ field: String representing the field/property to compare. Note that
1409
+ an underscore "_" can be used to refer to the item itself.
1410
+ n: Item to compare against
1411
+
1412
+ Yields:
1413
+ Items where the specified field's value equals n
1414
+
1415
+ Raises:
1416
+ AttributeError: If the specified field is missing from any item</pre></div>
1417
+ <h3>Parameters:</h3>
1418
+ <ul class="param-list">
1419
+ <li>self</li>
1420
+ <li>field: str</li>
1421
+ <li>n: Any</li>
1422
+ </ul>
1423
+ <p><strong>Base Classes:</strong> AbstractComparisonFilter</p>
1424
+ </div>
1425
+ <div class="class" id="talkpipe-pipe-math-gt">
1426
+ <h2>Segment Class: gt</h2>
1351
1427
  <p class="talkpipe-name">Chatterlang Name: gt</p>
1352
1428
  <div><pre>Filter items where a specified field's value is greater than a number.
1353
1429
 
1354
- Takes an iterable of items and yields only those where the value of the specified field
1430
+ For each item passed in, this segment yields only those where the value of the specified field
1355
1431
  is greater than the given number n.
1356
1432
 
1357
1433
  Args:
1358
1434
  items: Iterable of items to filter
1359
- field: String representing the field/property to compare
1435
+ field: String representing the field/property to compare. Note that
1436
+ an underscore "_" can be used to refer to the item itself.
1360
1437
  n: Number to compare against
1361
1438
 
1362
1439
  Yields:
1363
1440
  Items where the specified field's value is greater than n
1364
1441
 
1365
1442
  Raises:
1366
- AttributeError: If the specified field is missing from any item
1443
+ AttributeError: If the specified field is missing from any item</pre></div>
1444
+ <h3>Parameters:</h3>
1445
+ <ul class="param-list">
1446
+ <li>self</li>
1447
+ <li>field: str</li>
1448
+ <li>n: Any</li>
1449
+ </ul>
1450
+ <p><strong>Base Classes:</strong> AbstractComparisonFilter</p>
1451
+ </div>
1452
+ <div class="class" id="talkpipe-pipe-math-gte">
1453
+ <h2>Segment Class: gte</h2>
1454
+ <p class="talkpipe-name">Chatterlang Name: gte</p>
1455
+ <div><pre>Filter items where a specified field's value is greater than or equal to a number.
1367
1456
 
1368
- Example:
1369
- >>> list(gt([{'value': 5}, {'value': 2}, {'value': 8}], 'value', 4))
1370
- [{'value': 5}, {'value': 8}]</pre></div>
1457
+ For each item passed in, this segment yields only those where the value of the specified field
1458
+ is greater than or equal to the given number n.
1459
+
1460
+ Args:
1461
+ items: Iterable of items to filter
1462
+ field: String representing the field/property to compare. Note that
1463
+ an underscore "_" can be used to refer to the item itself.
1464
+ n: Number to compare against
1465
+
1466
+ Yields:
1467
+ Items where the specified field's value is greater than or equal to n
1468
+
1469
+ Raises:
1470
+ AttributeError: If the specified field is missing from any item</pre></div>
1371
1471
  <h3>Parameters:</h3>
1372
1472
  <ul class="param-list">
1373
- <li>field</li>
1374
- <li>n</li>
1473
+ <li>self</li>
1474
+ <li>field: str</li>
1475
+ <li>n: Any</li>
1375
1476
  </ul>
1477
+ <p><strong>Base Classes:</strong> AbstractComparisonFilter</p>
1376
1478
  </div>
1377
- <div class="function" id="talkpipe-pipe-math-lt">
1378
- <h2>Segment Function: lt</h2>
1479
+ <div class="class" id="talkpipe-pipe-math-lt">
1480
+ <h2>Segment Class: lt</h2>
1379
1481
  <p class="talkpipe-name">Chatterlang Name: lt</p>
1380
1482
  <div><pre>Filters items based on a field value being less than a specified number.
1381
1483
 
1382
- Yields items where the specified field value is less than the given number n.
1484
+ For each item passed in, this segment yields items where the
1485
+ specified field value is less than the given number n.
1383
1486
 
1384
1487
  Args:
1385
1488
  items (iterable): An iterable of items to filter
1386
- field (str): The field/property name to check against
1489
+ field: String representing the field/property to compare. Note that
1490
+ an underscore "_" can be used to refer to the item itself.
1387
1491
  n (numeric): The number to compare against
1388
1492
 
1389
1493
  Yields:
1390
1494
  item: Items where the specified field value is less than n
1391
1495
 
1392
1496
  Raises:
1393
- AttributeError: If the specified field does not exist on an item (due to fail_on_missing=True)
1497
+ AttributeError: If the specified field does not exist on an item (due to fail_on_missing=True)</pre></div>
1498
+ <h3>Parameters:</h3>
1499
+ <ul class="param-list">
1500
+ <li>self</li>
1501
+ <li>field: str</li>
1502
+ <li>n: Any</li>
1503
+ </ul>
1504
+ <p><strong>Base Classes:</strong> AbstractComparisonFilter</p>
1505
+ </div>
1506
+ <div class="class" id="talkpipe-pipe-math-lte">
1507
+ <h2>Segment Class: lte</h2>
1508
+ <p class="talkpipe-name">Chatterlang Name: lte</p>
1509
+ <div><pre>Filter items where a specified field's value is less than or equal to a number.
1394
1510
 
1395
- Example:
1396
- >>> items = [{'val': 1}, {'val': 5}, {'val': 3}]
1397
- >>> list(lt(items, 'val', 4))
1398
- [{'val': 1}, {'val': 3}]</pre></div>
1511
+ For each item passed in, this segment yields only those where the value of the specified field
1512
+ is less than or equal to the given number n.
1513
+
1514
+ Args:
1515
+ items: Iterable of items to filter
1516
+ field: String representing the field/property to compare. Note that
1517
+ an underscore "_" can be used to refer to the item itself.
1518
+ n: Number to compare against
1519
+
1520
+ Yields:
1521
+ Items where the specified field's value is less than or equal to n
1522
+
1523
+ Raises:
1524
+ AttributeError: If the specified field is missing from any item</pre></div>
1399
1525
  <h3>Parameters:</h3>
1400
1526
  <ul class="param-list">
1401
- <li>field</li>
1402
- <li>n</li>
1527
+ <li>self</li>
1528
+ <li>field: str</li>
1529
+ <li>n: Any</li>
1530
+ </ul>
1531
+ <p><strong>Base Classes:</strong> AbstractComparisonFilter</p>
1532
+ </div>
1533
+ <div class="class" id="talkpipe-pipe-math-neq">
1534
+ <h2>Segment Class: neq</h2>
1535
+ <p class="talkpipe-name">Chatterlang Name: neq</p>
1536
+ <div><pre>Filter items where a specified field's value does not equal a number.
1537
+
1538
+ For each item passed in, this segment yields only those where the value of the specified field
1539
+ is not equal to the given number n.
1540
+
1541
+ Args:
1542
+ items: Iterable of items to filter
1543
+ field: String representing the field/property to compare. Note that
1544
+ an underscore "_" can be used to refer to the item itself.
1545
+ n: Item to compare against
1546
+
1547
+ Yields:
1548
+ Items where the specified field's value does not equal n
1549
+
1550
+ Raises:
1551
+ AttributeError: If the specified field is missing from any item</pre></div>
1552
+ <h3>Parameters:</h3>
1553
+ <ul class="param-list">
1554
+ <li>self</li>
1555
+ <li>field: str</li>
1556
+ <li>n: Any</li>
1403
1557
  </ul>
1558
+ <p><strong>Base Classes:</strong> AbstractComparisonFilter</p>
1404
1559
  </div>
1405
1560
  <div class="function" id="talkpipe-pipe-math-randomInts">
1406
1561
  <h2>Source Function: randomInts</h2>
@@ -18,6 +18,19 @@ Segment Class: Accum
18
18
  variable: Union[VariableName, str] = None
19
19
  reset: bool = True
20
20
 
21
+ Segment Class: Snippet
22
+ Chatterlang Name: snippet
23
+ Base Classes: io.AbstractSegment
24
+ Docstring:
25
+ A segment that loads a chatterlang script from a file and compiles it, after which it
26
+ functions as a normal segment that can be integrated into a pipeline.
27
+
28
+ Args:
29
+ file (str): The path to the chatterlang script file.
30
+ runtime (RuntimeComponent, optional): The runtime component to use. Defaults to None.
31
+ Parameters:
32
+ script_source: str
33
+
21
34
 
22
35
  PACKAGE: talkpipe.data.email
23
36
  ----------------------------
@@ -901,22 +914,56 @@ PACKAGE: talkpipe.pipe.math
901
914
  Source Function: arange
902
915
  Chatterlang Name: range
903
916
  Docstring:
904
- Generate a range of integers between lower and upper
917
+ Generate a range of integers between lower (inclusive) and upper (exclusive)
918
+
919
+ This segment wraps the built-in range function, allowing you to specify
920
+ the lower and upper bounds of the range. The range is inclusive of the
921
+ lower bound and exclusive of the upper bound.
922
+
923
+ Args:
924
+ lower (int): Lower bound of the range (inclusive)
925
+ upper (int): Upper bound of the range (exclusive)
905
926
  Parameters:
906
927
  lower
907
928
  upper
908
929
 
909
- Segment Function: gt
930
+ Segment Class: eq
931
+ Chatterlang Name: eq
932
+ Base Classes: AbstractComparisonFilter
933
+ Docstring:
934
+ Filter items where a specified field's value equals a number.
935
+
936
+ For each item passed in, this segment yields only those where the value of the specified field
937
+ is equal to the given number n.
938
+
939
+ Args:
940
+ items: Iterable of items to filter
941
+ field: String representing the field/property to compare. Note that
942
+ an underscore "_" can be used to refer to the item itself.
943
+ n: Item to compare against
944
+
945
+ Yields:
946
+ Items where the specified field's value equals n
947
+
948
+ Raises:
949
+ AttributeError: If the specified field is missing from any item
950
+ Parameters:
951
+ field: str
952
+ n: Any
953
+
954
+ Segment Class: gt
910
955
  Chatterlang Name: gt
956
+ Base Classes: AbstractComparisonFilter
911
957
  Docstring:
912
958
  Filter items where a specified field's value is greater than a number.
913
959
 
914
- Takes an iterable of items and yields only those where the value of the specified field
960
+ For each item passed in, this segment yields only those where the value of the specified field
915
961
  is greater than the given number n.
916
962
 
917
963
  Args:
918
964
  items: Iterable of items to filter
919
- field: String representing the field/property to compare
965
+ field: String representing the field/property to compare. Note that
966
+ an underscore "_" can be used to refer to the item itself.
920
967
  n: Number to compare against
921
968
 
922
969
  Yields:
@@ -924,24 +971,47 @@ Segment Function: gt
924
971
 
925
972
  Raises:
926
973
  AttributeError: If the specified field is missing from any item
974
+ Parameters:
975
+ field: str
976
+ n: Any
977
+
978
+ Segment Class: gte
979
+ Chatterlang Name: gte
980
+ Base Classes: AbstractComparisonFilter
981
+ Docstring:
982
+ Filter items where a specified field's value is greater than or equal to a number.
927
983
 
928
- Example:
929
- >>> list(gt([{'value': 5}, {'value': 2}, {'value': 8}], 'value', 4))
930
- [{'value': 5}, {'value': 8}]
984
+ For each item passed in, this segment yields only those where the value of the specified field
985
+ is greater than or equal to the given number n.
986
+
987
+ Args:
988
+ items: Iterable of items to filter
989
+ field: String representing the field/property to compare. Note that
990
+ an underscore "_" can be used to refer to the item itself.
991
+ n: Number to compare against
992
+
993
+ Yields:
994
+ Items where the specified field's value is greater than or equal to n
995
+
996
+ Raises:
997
+ AttributeError: If the specified field is missing from any item
931
998
  Parameters:
932
- field
933
- n
999
+ field: str
1000
+ n: Any
934
1001
 
935
- Segment Function: lt
1002
+ Segment Class: lt
936
1003
  Chatterlang Name: lt
1004
+ Base Classes: AbstractComparisonFilter
937
1005
  Docstring:
938
1006
  Filters items based on a field value being less than a specified number.
939
1007
 
940
- Yields items where the specified field value is less than the given number n.
1008
+ For each item passed in, this segment yields items where the
1009
+ specified field value is less than the given number n.
941
1010
 
942
1011
  Args:
943
1012
  items (iterable): An iterable of items to filter
944
- field (str): The field/property name to check against
1013
+ field: String representing the field/property to compare. Note that
1014
+ an underscore "_" can be used to refer to the item itself.
945
1015
  n (numeric): The number to compare against
946
1016
 
947
1017
  Yields:
@@ -949,14 +1019,57 @@ Segment Function: lt
949
1019
 
950
1020
  Raises:
951
1021
  AttributeError: If the specified field does not exist on an item (due to fail_on_missing=True)
1022
+ Parameters:
1023
+ field: str
1024
+ n: Any
1025
+
1026
+ Segment Class: lte
1027
+ Chatterlang Name: lte
1028
+ Base Classes: AbstractComparisonFilter
1029
+ Docstring:
1030
+ Filter items where a specified field's value is less than or equal to a number.
952
1031
 
953
- Example:
954
- >>> items = [{'val': 1}, {'val': 5}, {'val': 3}]
955
- >>> list(lt(items, 'val', 4))
956
- [{'val': 1}, {'val': 3}]
1032
+ For each item passed in, this segment yields only those where the value of the specified field
1033
+ is less than or equal to the given number n.
1034
+
1035
+ Args:
1036
+ items: Iterable of items to filter
1037
+ field: String representing the field/property to compare. Note that
1038
+ an underscore "_" can be used to refer to the item itself.
1039
+ n: Number to compare against
1040
+
1041
+ Yields:
1042
+ Items where the specified field's value is less than or equal to n
1043
+
1044
+ Raises:
1045
+ AttributeError: If the specified field is missing from any item
957
1046
  Parameters:
958
- field
959
- n
1047
+ field: str
1048
+ n: Any
1049
+
1050
+ Segment Class: neq
1051
+ Chatterlang Name: neq
1052
+ Base Classes: AbstractComparisonFilter
1053
+ Docstring:
1054
+ Filter items where a specified field's value does not equal a number.
1055
+
1056
+ For each item passed in, this segment yields only those where the value of the specified field
1057
+ is not equal to the given number n.
1058
+
1059
+ Args:
1060
+ items: Iterable of items to filter
1061
+ field: String representing the field/property to compare. Note that
1062
+ an underscore "_" can be used to refer to the item itself.
1063
+ n: Item to compare against
1064
+
1065
+ Yields:
1066
+ Items where the specified field's value does not equal n
1067
+
1068
+ Raises:
1069
+ AttributeError: If the specified field is missing from any item
1070
+ Parameters:
1071
+ field: str
1072
+ n: Any
960
1073
 
961
1074
  Source Function: randomInts
962
1075
  Chatterlang Name: randomInts
@@ -33,7 +33,7 @@ def compile(script: ParsedScript, runtime: RuntimeComponent = None) -> Callable:
33
33
  logger.debug("Successfully compiled all pipelines")
34
34
  return Script(compiled_pipelines)
35
35
 
36
- def _resolve_parame(params, runtime):
36
+ def _resolve_params(params, runtime):
37
37
  """ Resolve the parameters for a segment """
38
38
  ans = {k: runtime.const_store[params[k].name] if isinstance(params[k], Identifier) else params[k] for k in params}
39
39
  return ans
@@ -57,7 +57,7 @@ def _(pipeline: ParsedPipeline, runtime: RuntimeComponent) -> Pipeline:
57
57
  ans = VariableSource(pipeline.input_node.source.name)
58
58
  logger.debug(f"Created variable source with name {pipeline.input_node.source.name}")
59
59
  else:
60
- ans = registry.input_registry.get(pipeline.input_node.source.name)(**_resolve_parame(pipeline.input_node.params, runtime=runtime))
60
+ ans = registry.input_registry.get(pipeline.input_node.source.name)(**_resolve_params(pipeline.input_node.params, runtime=runtime))
61
61
  logger.debug(f"Created registered input {pipeline.input_node.source.name}")
62
62
  ans.runtime = runtime
63
63
 
@@ -67,7 +67,7 @@ def _(pipeline: ParsedPipeline, runtime: RuntimeComponent) -> Pipeline:
67
67
  next_transform = VariableSetSegment(transform.name)
68
68
  logger.debug(f"Created variable set segment for {transform.name}")
69
69
  elif isinstance(transform, SegmentNode):
70
- next_transform = registry.segment_registry.get(transform.operation.name)(**_resolve_parame(transform.params, runtime=runtime))
70
+ next_transform = registry.segment_registry.get(transform.operation.name)(**_resolve_params(transform.params, runtime=runtime))
71
71
  logger.debug(f"Created segment {transform.operation.name}")
72
72
  elif isinstance(transform, ForkNode):
73
73
  next_transform = compile(transform, runtime)
@@ -216,3 +216,30 @@ class Accum(io.AbstractSegment):
216
216
  if self.variable_name:
217
217
  self.runtime.variable_store[self.variable_name].append(item)
218
218
  yield item
219
+
220
+
221
+ @registry.register_segment(name="snippet")
222
+ class Snippet(io.AbstractSegment):
223
+ """A segment that loads a chatterlang script from a file and compiles it, after which it
224
+ functions as a normal segment that can be integrated into a pipeline.
225
+
226
+ Args:
227
+ file (str): The path to the chatterlang script file.
228
+ runtime (RuntimeComponent, optional): The runtime component to use. Defaults to None.
229
+ """
230
+
231
+ def __init__(self, script_source: str):
232
+ super().__init__()
233
+ self.script_source = script_source
234
+ self.script = None
235
+
236
+ def transform(self, items):
237
+ if self.script is None:
238
+ try:
239
+ with open(self.script_source, "r") as f:
240
+ script_text = f.read()
241
+ except FileNotFoundError:
242
+ # If file doesn't exist, treat self.script_source as the script content
243
+ script_text = self.script_source
244
+ self.script = compile(script_text, self.runtime)
245
+ yield from self.script(items)
@@ -2,6 +2,7 @@
2
2
 
3
3
  import logging
4
4
  import re
5
+ import gzip
5
6
  import urllib.error
6
7
  import requests
7
8
  import urllib
@@ -97,7 +98,13 @@ def get_robot_parser(domain, timeout=5):
97
98
 
98
99
  try:
99
100
  with urllib.request.urlopen(robots_url, timeout=timeout) as response:
100
- content = response.read().decode('utf-8')
101
+ content = response.read()
102
+ if content.startswith(b'\x1f\x8b'):
103
+ # If the content is gzipped, decompress it
104
+ content = gzip.decompress(content).decode('utf-8')
105
+ else:
106
+ # If not gzipped, decode it directly
107
+ content = content.decode('utf-8')
101
108
 
102
109
  try:
103
110
  rp.parse(content.splitlines())