tasks-prompts-chain 0.0.1__tar.gz → 0.0.3__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.
- tasks_prompts_chain-0.0.3/.github/workflows/publish.yml +59 -0
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/PKG-INFO +17 -5
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/README.md +16 -4
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/pyproject.toml +1 -1
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/src/tasks_prompts_chain/tasks_prompts_chain.py +12 -1
- tasks_prompts_chain-0.0.1/.github/workflows/publish.yml +0 -30
- tasks_prompts_chain-0.0.1/.pypirc +0 -3
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/LICENSE +0 -0
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/requirements/requirements-dev.txt +0 -0
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/requirements.txt +0 -0
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/src/tasks_prompts_chain/__init__.py +0 -0
- {tasks_prompts_chain-0.0.1 → tasks_prompts_chain-0.0.3}/tests/test_tasks_prompts_chain.py +0 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
name: Upload Python Package to PyPI when a Release is Created
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
permissions:
|
8
|
+
contents: read
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
release-build:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v4
|
16
|
+
|
17
|
+
- uses: actions/setup-python@v5
|
18
|
+
with:
|
19
|
+
python-version: "3.x"
|
20
|
+
|
21
|
+
- name: Build release distributions
|
22
|
+
run: |
|
23
|
+
# NOTE: put your own distribution build steps here.
|
24
|
+
python -m pip install build
|
25
|
+
python -m build
|
26
|
+
|
27
|
+
- name: Upload distributions
|
28
|
+
uses: actions/upload-artifact@v4
|
29
|
+
with:
|
30
|
+
name: release-dists
|
31
|
+
path: dist/
|
32
|
+
|
33
|
+
pypi-publish:
|
34
|
+
runs-on: ubuntu-latest
|
35
|
+
needs:
|
36
|
+
- release-build
|
37
|
+
permissions:
|
38
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
39
|
+
id-token: write
|
40
|
+
|
41
|
+
# Dedicated environments with protections for publishing are strongly recommended.
|
42
|
+
# For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules
|
43
|
+
environment:
|
44
|
+
name: pypi
|
45
|
+
# ALTERNATIVE: if your GitHub Release name is the PyPI project version string
|
46
|
+
# ALTERNATIVE: exactly, uncomment the following line instead:
|
47
|
+
url: https://pypi.org/project/tasks-prompts-chain/${{ github.event.release.name }}
|
48
|
+
|
49
|
+
steps:
|
50
|
+
- name: Retrieve release distributions
|
51
|
+
uses: actions/download-artifact@v4
|
52
|
+
with:
|
53
|
+
name: release-dists
|
54
|
+
path: dist/
|
55
|
+
|
56
|
+
- name: Publish release distributions to PyPI
|
57
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
58
|
+
with:
|
59
|
+
packages-dir: dist/
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: tasks_prompts_chain
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.3
|
4
4
|
Summary: A Python library for creating and executing chains of prompts using OpenAI's SDK with streaming support and template formatting.
|
5
5
|
Project-URL: Homepage, https://github.com/smirfolio/tasks_prompts_chain
|
6
6
|
Project-URL: Issues, https://github.com/smirfolio/tasks_prompts_chain/issues
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Requires-Python: >=3.8
|
13
13
|
Description-Content-Type: text/markdown
|
14
14
|
|
15
|
-
#
|
15
|
+
# TasksPromptsChain
|
16
16
|
|
17
17
|
A Mini Python library for creating and executing chains of prompts using OpenAI's API with streaming support and output template formatting.
|
18
18
|
|
@@ -26,14 +26,26 @@ A Mini Python library for creating and executing chains of prompts using OpenAI'
|
|
26
26
|
- Multiple output formats (JSON, Markdown, CSV, Text)
|
27
27
|
- Async/await support
|
28
28
|
|
29
|
-
##
|
29
|
+
## Dependancies
|
30
30
|
|
31
|
-
|
31
|
+
Please install typing-extensions and openai python packages
|
32
|
+
```bash
|
33
|
+
pip install typing-extensions
|
34
|
+
pip install openai
|
35
|
+
```
|
36
|
+
To Install the library:
|
37
|
+
```
|
38
|
+
pip install tasks_prompts_chain
|
39
|
+
```
|
40
|
+
|
41
|
+
## Installation from source code
|
42
|
+
|
43
|
+
### For Users required from source gitHub repo
|
32
44
|
```bash
|
33
45
|
pip install -r requirements/requirements.txt
|
34
46
|
```
|
35
47
|
|
36
|
-
### For Developers
|
48
|
+
### For Developers required from source gitHub repo
|
37
49
|
```bash
|
38
50
|
pip install -r requirements/requirements.txt
|
39
51
|
pip install -r requirements/requirements-dev.txt
|
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# TasksPromptsChain
|
2
2
|
|
3
3
|
A Mini Python library for creating and executing chains of prompts using OpenAI's API with streaming support and output template formatting.
|
4
4
|
|
@@ -12,14 +12,26 @@ A Mini Python library for creating and executing chains of prompts using OpenAI'
|
|
12
12
|
- Multiple output formats (JSON, Markdown, CSV, Text)
|
13
13
|
- Async/await support
|
14
14
|
|
15
|
-
##
|
15
|
+
## Dependancies
|
16
16
|
|
17
|
-
|
17
|
+
Please install typing-extensions and openai python packages
|
18
|
+
```bash
|
19
|
+
pip install typing-extensions
|
20
|
+
pip install openai
|
21
|
+
```
|
22
|
+
To Install the library:
|
23
|
+
```
|
24
|
+
pip install tasks_prompts_chain
|
25
|
+
```
|
26
|
+
|
27
|
+
## Installation from source code
|
28
|
+
|
29
|
+
### For Users required from source gitHub repo
|
18
30
|
```bash
|
19
31
|
pip install -r requirements/requirements.txt
|
20
32
|
```
|
21
33
|
|
22
|
-
### For Developers
|
34
|
+
### For Developers required from source gitHub repo
|
23
35
|
```bash
|
24
36
|
pip install -r requirements/requirements.txt
|
25
37
|
pip install -r requirements/requirements-dev.txt
|
@@ -89,6 +89,7 @@ class TasksPromptsChain:
|
|
89
89
|
self.final_result_placeholder = final_result_placeholder or "final_result"
|
90
90
|
self._results = {}
|
91
91
|
self._output_template = None
|
92
|
+
self._final_output_template = None
|
92
93
|
self._current_stream_buffer = ""
|
93
94
|
|
94
95
|
def set_output_template(self, template: str) -> None:
|
@@ -117,6 +118,7 @@ class TasksPromptsChain:
|
|
117
118
|
output = output.replace(f"{{{{{placeholder}}}}}", value or "")
|
118
119
|
# Replace current streaming placeholder
|
119
120
|
output = output.replace(f"{{{{{self.final_result_placeholder}}}}}", self._current_stream_buffer)
|
121
|
+
self._final_output_template=output
|
120
122
|
return output
|
121
123
|
|
122
124
|
async def execute_chain(self, prompts: List[Union[Dict, PromptTemplate]], temperature: float = 0.7) -> AsyncGenerator[str, None]:
|
@@ -181,7 +183,8 @@ class TasksPromptsChain:
|
|
181
183
|
delta = chunk.choices[0].delta.content
|
182
184
|
response_content += delta
|
183
185
|
self._current_stream_buffer = response_content
|
184
|
-
|
186
|
+
self._format_current_stream()
|
187
|
+
yield response_content
|
185
188
|
|
186
189
|
responses.append(response_content)
|
187
190
|
|
@@ -209,6 +212,14 @@ class TasksPromptsChain:
|
|
209
212
|
"""
|
210
213
|
return self._results.get(placeholder)
|
211
214
|
|
215
|
+
def get_final_result_within_template(self) -> Optional[str]:
|
216
|
+
"""
|
217
|
+
Get tje final result
|
218
|
+
Returns:
|
219
|
+
Optional[str]: The response for that placeholder if it exists, None otherwise
|
220
|
+
"""
|
221
|
+
return self._final_output_template
|
222
|
+
|
212
223
|
def template_output(self, template: str) -> None:
|
213
224
|
"""
|
214
225
|
Set the output template for streaming responses.
|
@@ -1,30 +0,0 @@
|
|
1
|
-
name: Upload Python Package to PyPI when a Release is Created
|
2
|
-
|
3
|
-
on:
|
4
|
-
release:
|
5
|
-
types: [created]
|
6
|
-
|
7
|
-
jobs:
|
8
|
-
pypi-publish:
|
9
|
-
name: Publish release to PyPI
|
10
|
-
runs-on: ubuntu-latest
|
11
|
-
environment:
|
12
|
-
name: pypi
|
13
|
-
url: https://pypi.org/p/tasks_prompts_chain
|
14
|
-
permissions:
|
15
|
-
id-token: write
|
16
|
-
steps:
|
17
|
-
- uses: actions/checkout@v4
|
18
|
-
- name: Set up Python
|
19
|
-
uses: actions/setup-python@v4
|
20
|
-
with:
|
21
|
-
python-version: "3.x"
|
22
|
-
- name: Install dependencies
|
23
|
-
run: |
|
24
|
-
python -m pip install --upgrade pip
|
25
|
-
pip install setuptools wheel
|
26
|
-
- name: Build package
|
27
|
-
run: |
|
28
|
-
python setup.py sdist bdist_wheel # Could also be python -m build
|
29
|
-
- name: Publish package distributions to PyPI
|
30
|
-
uses: pypa/gh-action-pypi-publish@release/v1
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|