Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Feature: Streaming Reply (#94)
Browse files Browse the repository at this point in the history
* bump version

* ChatGPT Aliases Logic Change (#87)

* Should fix history_length 0 issue

* ci: auto fixes from pre-commit.com hooks

* Re-implemented the logic for replacing content within promts with its aliases

* ci: auto fixes from pre-commit.com hooks

---------

Co-authored-by: stayinalive <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* version bump

* Implemented streaming using Flet
Add the current model to the subtext
Dependency for Flet
Custom font

* storyboard and Workflow config file updated, an option $stream_reply added

* Change version rto 1.5.4

* ci: auto fixes from pre-commit.com hooks

* Updated Readme

* Updated Readme and discription

* Readme update

* combined text_chat_flet and text_chat to one file

* Renamed it back to the original text_chat.py

* ci: auto fixes from pre-commit.com hooks

* fix: remove all .so files

* add: Readme to reflect what Stream reply does

---------

Co-authored-by: Chris Lemke <[email protected]>
Co-authored-by: stayinalive <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
4 people committed Aug 10, 2023
1 parent ee14da3 commit dcef358
Show file tree
Hide file tree
Showing 1,441 changed files with 533,450 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ You can tweak the workflow to your liking. The following parameters are availabl
- **Show notifications**: Shows all notifications provided by the workflow. For this, to work System notifications must be activated for Alfred. Default: `on`.
- **Show ChatGPT is thinking message**: Shows the message: "💭 Stay tuned... ChatGPT is thinking" while OpenAI is processing your request. Default: `on`.
- **Loading indicator text**: The text that is shown while ChatGPT is thinking. Default: `💭 Stay tuned... ChatGPT is thinking`.
- **Stream reply**: If checked, partial message deltas will be sent, like in ChatGPT. Reply will be shown in a stand-alone window implemented using [Flet](https://flet.dev). Close it by pressing Esc. Default: `off`. Overrides `Show ChatGPT is thinking message` when checked.

## Troubleshooting ⛑️
### General 🙀
Expand Down
99 changes: 93 additions & 6 deletions info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,19 @@
<false/>
</dict>
</array>
<key>4F8D85D8-499B-4A92-805A-2B06BB064695</key>
<array>
<dict>
<key>destinationuid</key>
<string>AD46F538-F4DD-41B2-BE43-E830535CA0E3</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
<key>51AA54E6-C0D7-4A43-B5C9-D18B0A805FA9</key>
<array>
<dict>
Expand Down Expand Up @@ -488,8 +501,6 @@
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>sourceoutputuid</key>
<string>EB4174C6-1124-4C08-9E80-AAAA8419FA81</string>
<key>vitoclose</key>
<false/>
</dict>
Expand Down Expand Up @@ -1006,7 +1017,7 @@
</dict>
<dict>
<key>destinationuid</key>
<string>AD46F538-F4DD-41B2-BE43-E830535CA0E3</string>
<string>4F8D85D8-499B-4A92-805A-2B06BB064695</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
Expand Down Expand Up @@ -1666,19 +1677,33 @@ python3 -c 'import custom_prompts; custom_prompts.custom_or_error_prompt_usage()
<key>matchcasesensitive</key>
<false/>
<key>matchmode</key>
<integer>5</integer>
<integer>6</integer>
<key>matchstring</key>
<string></string>
<key>outputlabel</key>
<string></string>
<key>uid</key>
<string>EB4174C6-1124-4C08-9E80-AAAA8419FA81</string>
</dict>
<dict>
<key>inputstring</key>
<string>{var:stream_reply}</string>
<key>matchcasesensitive</key>
<false/>
<key>matchmode</key>
<integer>5</integer>
<key>matchstring</key>
<string></string>
<key>outputlabel</key>
<string></string>
<key>uid</key>
<string>94D6C3C4-6719-4DD6-AB66-DAD9F2279483</string>
</dict>
</array>
<key>elselabel</key>
<string>else</string>
<key>hideelse</key>
<true/>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.utility.conditional</string>
Expand Down Expand Up @@ -2416,6 +2441,38 @@ RESPONSE:'{query}'</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>conditions</key>
<array>
<dict>
<key>inputstring</key>
<string>{var:stream_reply}</string>
<key>matchcasesensitive</key>
<false/>
<key>matchmode</key>
<integer>5</integer>
<key>matchstring</key>
<string>🚨\s</string>
<key>outputlabel</key>
<string></string>
<key>uid</key>
<string>898A73C4-3AC4-4A30-830C-187C148678D6</string>
</dict>
</array>
<key>elselabel</key>
<string></string>
<key>hideelse</key>
<false/>
</dict>
<key>type</key>
<string>alfred.workflow.utility.conditional</string>
<key>uid</key>
<string>4F8D85D8-499B-4A92-805A-2B06BB064695</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -3336,6 +3393,17 @@ Please refer to OpenAI's [safety best practices guide](https://platform.openai.c
<key>ypos</key>
<real>2245</real>
</dict>
<key>4F8D85D8-499B-4A92-805A-2B06BB064695</key>
<dict>
<key>colorindex</key>
<integer>3</integer>
<key>note</key>
<string>If stream_reply is used, don't show Large Type</string>
<key>xpos</key>
<real>1190</real>
<key>ypos</key>
<real>1625</real>
</dict>
<key>51AA54E6-C0D7-4A43-B5C9-D18B0A805FA9</key>
<dict>
<key>colorindex</key>
Expand Down Expand Up @@ -3436,7 +3504,7 @@ Please refer to OpenAI's [safety best practices guide](https://platform.openai.c
<key>colorindex</key>
<integer>3</integer>
<key>note</key>
<string>Shows the message: "💭 Stay tuned... ChatGPT is thinking" if "show_loading_indicator" is checked.</string>
<string>Shows the message: "💭 Stay tuned... ChatGPT is thinking" if "show_loading_indicator" is checked and "stream_reply" isn't.</string>
<key>xpos</key>
<real>540</real>
<key>ypos</key>
Expand Down Expand Up @@ -4421,6 +4489,25 @@ Please refer to OpenAI's [safety best practices guide](https://platform.openai.c
<key>variable</key>
<string>loading_indicator_text</string>
</dict>
<dict>
<key>config</key>
<dict>
<key>default</key>
<false/>
<key>required</key>
<false/>
<key>text</key>
<string></string>
</dict>
<key>description</key>
<string>If checked, partial message deltas will be sent, like in ChatGPT. Reply will be shown in a stand-alone window implemented using Flet. Close it by pressing Esc.</string>
<key>label</key>
<string>Stream reply</string>
<key>type</key>
<string>checkbox</string>
<key>variable</key>
<string>stream_reply</string>
</dict>
</array>
<key>version</key>
<string>1.5.3</string>
Expand Down
Binary file added workflow/src/fonts/Helvetica.ttc
Binary file not shown.
5 changes: 3 additions & 2 deletions workflow/src/history_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
__workflow_data_path = os.getenv("alfred_workflow_data") or os.path.expanduser("~")
__log_file_path = f"{__workflow_data_path}/ChatFred_ChatGPT.csv"
__history_type = os.getenv("history_type")
__model = os.getenv("chat_gpt_model") or "gpt-3.5-turbo"


def get_query() -> str:
Expand Down Expand Up @@ -47,9 +48,9 @@ def provide_history():
history = [tuple[0] for tuple in process.extract(prompt, history, limit=20)]

if prompt in ["", " "]:
history.insert(0, (str(uuid.uuid1()), "...", "Talk to ChatGPT 💬", "0"))
history.insert(0, (str(uuid.uuid1()), "...", f"Talk to {__model} 💬", "0"))
else:
history.insert(0, (str(uuid.uuid1()), prompt, "Talk to ChatGPT 💬", "0"))
history.insert(0, (str(uuid.uuid1()), prompt, f"Talk to {__model} 💬", "0"))

non_hist_text = [prompt, "..."]

Expand Down
1 change: 1 addition & 0 deletions workflow/src/libs/Jinja2-3.1.2.dist-info/INSTALLER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
28 changes: 28 additions & 0 deletions workflow/src/libs/Jinja2-3.1.2.dist-info/LICENSE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Copyright 2007 Pallets

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113 changes: 113 additions & 0 deletions workflow/src/libs/Jinja2-3.1.2.dist-info/METADATA
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
Metadata-Version: 2.1
Name: Jinja2
Version: 3.1.2
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
Author: Armin Ronacher
Author-email: [email protected]
Maintainer: Pallets
Maintainer-email: [email protected]
License: BSD-3-Clause
Project-URL: Donate, https://palletsprojects.com/donate
Project-URL: Documentation, https://jinja.palletsprojects.com/
Project-URL: Changes, https://jinja.palletsprojects.com/changes/
Project-URL: Source Code, https://github.com/pallets/jinja/
Project-URL: Issue Tracker, https://github.com/pallets/jinja/issues/
Project-URL: Twitter, https://twitter.com/PalletsTeam
Project-URL: Chat, https://discord.gg/pallets
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
License-File: LICENSE.rst
Requires-Dist: MarkupSafe (>=2.0)
Provides-Extra: i18n
Requires-Dist: Babel (>=2.7) ; extra == 'i18n'

Jinja
=====

Jinja is a fast, expressive, extensible templating engine. Special
placeholders in the template allow writing code similar to Python
syntax. Then the template is passed data to render the final document.

It includes:

- Template inheritance and inclusion.
- Define and import macros within templates.
- HTML templates can use autoescaping to prevent XSS from untrusted
user input.
- A sandboxed environment can safely render untrusted templates.
- AsyncIO support for generating templates and calling async
functions.
- I18N support with Babel.
- Templates are compiled to optimized Python code just-in-time and
cached, or can be compiled ahead-of-time.
- Exceptions point to the correct line in templates to make debugging
easier.
- Extensible filters, tests, functions, and even syntax.

Jinja's philosophy is that while application logic belongs in Python if
possible, it shouldn't make the template designer's job difficult by
restricting functionality too much.


Installing
----------

Install and update using `pip`_:

.. code-block:: text

$ pip install -U Jinja2

.. _pip: https://pip.pypa.io/en/stable/getting-started/


In A Nutshell
-------------

.. code-block:: jinja

{% extends "base.html" %}
{% block title %}Members{% endblock %}
{% block content %}
<ul>
{% for user in users %}
<li><a href="{{ user.url }}">{{ user.username }}</a></li>
{% endfor %}
</ul>
{% endblock %}


Donate
------

The Pallets organization develops and supports Jinja and other popular
packages. In order to grow the community of contributors and users, and
allow the maintainers to devote more time to the projects, `please
donate today`_.

.. _please donate today: https://palletsprojects.com/donate


Links
-----

- Documentation: https://jinja.palletsprojects.com/
- Changes: https://jinja.palletsprojects.com/changes/
- PyPI Releases: https://pypi.org/project/Jinja2/
- Source Code: https://github.com/pallets/jinja/
- Issue Tracker: https://github.com/pallets/jinja/issues/
- Website: https://palletsprojects.com/p/jinja/
- Twitter: https://twitter.com/PalletsTeam
- Chat: https://discord.gg/pallets


58 changes: 58 additions & 0 deletions workflow/src/libs/Jinja2-3.1.2.dist-info/RECORD
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Jinja2-3.1.2.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
Jinja2-3.1.2.dist-info/LICENSE.rst,sha256=O0nc7kEF6ze6wQ-vG-JgQI_oXSUrjp3y4JefweCUQ3s,1475
Jinja2-3.1.2.dist-info/METADATA,sha256=PZ6v2SIidMNixR7MRUX9f7ZWsPwtXanknqiZUmRbh4U,3539
Jinja2-3.1.2.dist-info/RECORD,,
Jinja2-3.1.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
Jinja2-3.1.2.dist-info/entry_points.txt,sha256=zRd62fbqIyfUpsRtU7EVIFyiu1tPwfgO7EvPErnxgTE,59
Jinja2-3.1.2.dist-info/top_level.txt,sha256=PkeVWtLb3-CqjWi1fO29OCbj55EhX_chhKrCdrVe_zs,7
jinja2/__init__.py,sha256=8vGduD8ytwgD6GDSqpYc2m3aU-T7PKOAddvVXgGr_Fs,1927
jinja2/__pycache__/__init__.cpython-310.pyc,,
jinja2/__pycache__/_identifier.cpython-310.pyc,,
jinja2/__pycache__/async_utils.cpython-310.pyc,,
jinja2/__pycache__/bccache.cpython-310.pyc,,
jinja2/__pycache__/compiler.cpython-310.pyc,,
jinja2/__pycache__/constants.cpython-310.pyc,,
jinja2/__pycache__/debug.cpython-310.pyc,,
jinja2/__pycache__/defaults.cpython-310.pyc,,
jinja2/__pycache__/environment.cpython-310.pyc,,
jinja2/__pycache__/exceptions.cpython-310.pyc,,
jinja2/__pycache__/ext.cpython-310.pyc,,
jinja2/__pycache__/filters.cpython-310.pyc,,
jinja2/__pycache__/idtracking.cpython-310.pyc,,
jinja2/__pycache__/lexer.cpython-310.pyc,,
jinja2/__pycache__/loaders.cpython-310.pyc,,
jinja2/__pycache__/meta.cpython-310.pyc,,
jinja2/__pycache__/nativetypes.cpython-310.pyc,,
jinja2/__pycache__/nodes.cpython-310.pyc,,
jinja2/__pycache__/optimizer.cpython-310.pyc,,
jinja2/__pycache__/parser.cpython-310.pyc,,
jinja2/__pycache__/runtime.cpython-310.pyc,,
jinja2/__pycache__/sandbox.cpython-310.pyc,,
jinja2/__pycache__/tests.cpython-310.pyc,,
jinja2/__pycache__/utils.cpython-310.pyc,,
jinja2/__pycache__/visitor.cpython-310.pyc,,
jinja2/_identifier.py,sha256=_zYctNKzRqlk_murTNlzrju1FFJL7Va_Ijqqd7ii2lU,1958
jinja2/async_utils.py,sha256=dHlbTeaxFPtAOQEYOGYh_PHcDT0rsDaUJAFDl_0XtTg,2472
jinja2/bccache.py,sha256=mhz5xtLxCcHRAa56azOhphIAe19u1we0ojifNMClDio,14061
jinja2/compiler.py,sha256=Gs-N8ThJ7OWK4-reKoO8Wh1ZXz95MVphBKNVf75qBr8,72172
jinja2/constants.py,sha256=GMoFydBF_kdpaRKPoM5cl5MviquVRLVyZtfp5-16jg0,1433
jinja2/debug.py,sha256=iWJ432RadxJNnaMOPrjIDInz50UEgni3_HKuFXi2vuQ,6299
jinja2/defaults.py,sha256=boBcSw78h-lp20YbaXSJsqkAI2uN_mD_TtCydpeq5wU,1267
jinja2/environment.py,sha256=6uHIcc7ZblqOMdx_uYNKqRnnwAF0_nzbyeMP9FFtuh4,61349
jinja2/exceptions.py,sha256=ioHeHrWwCWNaXX1inHmHVblvc4haO7AXsjCp3GfWvx0,5071
jinja2/ext.py,sha256=ivr3P7LKbddiXDVez20EflcO3q2aHQwz9P_PgWGHVqE,31502
jinja2/filters.py,sha256=9js1V-h2RlyW90IhLiBGLM2U-k6SCy2F4BUUMgB3K9Q,53509
jinja2/idtracking.py,sha256=GfNmadir4oDALVxzn3DL9YInhJDr69ebXeA2ygfuCGA,10704
jinja2/lexer.py,sha256=DW2nX9zk-6MWp65YR2bqqj0xqCvLtD-u9NWT8AnFRxQ,29726
jinja2/loaders.py,sha256=BfptfvTVpClUd-leMkHczdyPNYFzp_n7PKOJ98iyHOg,23207
jinja2/meta.py,sha256=GNPEvifmSaU3CMxlbheBOZjeZ277HThOPUTf1RkppKQ,4396
jinja2/nativetypes.py,sha256=DXgORDPRmVWgy034H0xL8eF7qYoK3DrMxs-935d0Fzk,4226
jinja2/nodes.py,sha256=i34GPRAZexXMT6bwuf5SEyvdmS-bRCy9KMjwN5O6pjk,34550
jinja2/optimizer.py,sha256=tHkMwXxfZkbfA1KmLcqmBMSaz7RLIvvItrJcPoXTyD8,1650
jinja2/parser.py,sha256=nHd-DFHbiygvfaPtm9rcQXJChZG7DPsWfiEsqfwKerY,39595
jinja2/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
jinja2/runtime.py,sha256=5CmD5BjbEJxSiDNTFBeKCaq8qU4aYD2v6q2EluyExms,33476
jinja2/sandbox.py,sha256=Y0xZeXQnH6EX5VjaV2YixESxoepnRbW_3UeQosaBU3M,14584
jinja2/tests.py,sha256=Am5Z6Lmfr2XaH_npIfJJ8MdXtWsbLjMULZJulTAj30E,5905
jinja2/utils.py,sha256=u9jXESxGn8ATZNVolwmkjUVu4SA-tLgV0W7PcSfPfdQ,23965
jinja2/visitor.py,sha256=MH14C6yq24G_KVtWzjwaI7Wg14PCJIYlWW1kpkxYak0,3568
Loading

0 comments on commit dcef358

Please sign in to comment.