-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dummy provider and threading bugfix (#418)
* example and bugfix to queue full * minor * typo * PR comments --------- Co-authored-by: rshih32 <[email protected]>
- Loading branch information
Showing
14 changed files
with
250 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Dummy Example\n", | ||
"\n", | ||
"This notebook shows the use of the dummy feedback function provider which\n", | ||
"behaves like the huggingface provider except it does not actually perform any\n", | ||
"network calls and just produces constant results. It can be used to prototype\n", | ||
"feedback function wiring for your apps before invoking potentially slow (to\n", | ||
"run/to load) feedback functions." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import threading\n", | ||
"\n", | ||
"from examples.frameworks.custom.custom_app import CustomApp\n", | ||
"\n", | ||
"from trulens_eval import Feedback\n", | ||
"from trulens_eval import Tru\n", | ||
"from trulens_eval.feedback.provider.hugs import Dummy\n", | ||
"from trulens_eval.tru_custom_app import TruCustomApp\n", | ||
"from trulens_eval.utils.threading import TP\n", | ||
"\n", | ||
"tru = Tru()\n", | ||
"\n", | ||
"tru.reset_database()\n", | ||
"\n", | ||
"tru.start_dashboard()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# hugs = Huggingface()\n", | ||
"hugs = Dummy()\n", | ||
"\n", | ||
"f_positive_sentiment = Feedback(hugs.positive_sentiment).on_output()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Create custom app:\n", | ||
"ca = CustomApp()\n", | ||
"\n", | ||
"# Create trulens wrapper:\n", | ||
"ta = TruCustomApp(\n", | ||
" ca,\n", | ||
" app_id=\"customapp\",\n", | ||
" # feedback_mode=FeedbackMode.WITH_APP\n", | ||
" feedbacks=[f_positive_sentiment]\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"with ta:\n", | ||
" for i, q in enumerate([\"hello there\"] * 100):\n", | ||
" # Track number of requests, number of threads, and number of promises to fulfull\n", | ||
" print(f\"\\rrequest {i} \", end=\"\")\n", | ||
" print(f\"thread count={threading.active_count()}, promises={TP().promises.qsize()}\", end=\"\")\n", | ||
"\n", | ||
" res = ca.respond_to_query(input=q)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "py38_trulens", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.16" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
trulens_eval/trulens_eval/feedback/provider/endpoint/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
from trulens_eval.feedback.provider.endpoint.base import Endpoint | ||
from trulens_eval.feedback.provider.endpoint.base import Endpoint, DummyEndpoint | ||
from trulens_eval.feedback.provider.endpoint.hugs import HuggingfaceEndpoint | ||
from trulens_eval.feedback.provider.endpoint.openai import OpenAIEndpoint | ||
|
||
__all__ = ['Endpoint', 'HuggingfaceEndpoint', 'OpenAIEndpoint'] | ||
__all__ = ['Endpoint', 'DummyEndpoint', 'HuggingfaceEndpoint', 'OpenAIEndpoint'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.