Skip to content

Commit

Permalink
Revert "example appui in quickstart"
Browse files Browse the repository at this point in the history
This reverts commit affab95.
  • Loading branch information
piotrm0 committed Oct 25, 2023
1 parent 0f3e1e0 commit 6bde633
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 38 deletions.
53 changes: 19 additions & 34 deletions trulens_eval/examples/quickstart/langchain_quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import JSON\n",
"\n",
"# Imports main tools:\n",
"from trulens_eval import Feedback, Huggingface, Tru\n",
"from trulens_eval import TruChain, Feedback, Huggingface, Tru\n",
"from trulens_eval.schema import FeedbackResult\n",
"tru = Tru()\n",
"\n",
Expand All @@ -77,7 +79,7 @@
"source": [
"### Create Simple LLM Application\n",
"\n",
"This example uses a LangChain framework and OpenAI LLM. "
"This example uses a LangChain framework and OpenAI LLM"
]
},
{
Expand All @@ -86,27 +88,19 @@
"metadata": {},
"outputs": [],
"source": [
"def new_session() -> LLMChain:\n",
" # A function to return a chain for a new session. This is needed if you\n",
" # would like to run your app from the dashboard.\n",
"\n",
" full_prompt = HumanMessagePromptTemplate(\n",
" prompt=PromptTemplate(\n",
" template=\n",
" \"Provide a helpful response with relevant background information for the following: {prompt}\",\n",
" input_variables=[\"prompt\"],\n",
" )\n",
"full_prompt = HumanMessagePromptTemplate(\n",
" prompt=PromptTemplate(\n",
" template=\n",
" \"Provide a helpful response with relevant background information for the following: {prompt}\",\n",
" input_variables=[\"prompt\"],\n",
" )\n",
")\n",
"\n",
" chat_prompt_template = ChatPromptTemplate.from_messages([full_prompt])\n",
"\n",
" llm = OpenAI(temperature=0.9, max_tokens=128)\n",
"\n",
" chain = LLMChain(llm=llm, prompt=chat_prompt_template, verbose=True)\n",
"chat_prompt_template = ChatPromptTemplate.from_messages([full_prompt])\n",
"\n",
" return chain\n",
"llm = OpenAI(temperature=0.9, max_tokens=128)\n",
"\n",
"chain = new_session()"
"chain = LLMChain(llm=llm, prompt=chat_prompt_template, verbose=True)"
]
},
{
Expand Down Expand Up @@ -174,12 +168,9 @@
"metadata": {},
"outputs": [],
"source": [
"tru_recorder = tru.Chain(\n",
" chain,\n",
"tru_recorder = TruChain(chain,\n",
" app_id='Chain1_ChatApplication',\n",
" feedbacks=[f_lang_match],\n",
" new_session=new_session # to interact with app in the dashboard\n",
")"
" feedbacks=[f_lang_match])"
]
},
{
Expand Down Expand Up @@ -274,7 +265,7 @@
"\n",
"Note: Average feedback values are returned and displayed in a range from 0 (worst) to 1 (best).\n",
"\n",
"![Chain Leaderboard](https://www.trulens.org/assets/images/Leaderboard.png)\n",
"![Chain Leaderboard](https://www.trulens.org/Assets/image/Leaderboard.png)\n",
"\n",
"To dive deeper on a particular chain, click \"Select Chain\".\n",
"\n",
Expand All @@ -284,21 +275,15 @@
"\n",
"The evaluations tab provides record-level metadata and feedback on the quality of your LLM application.\n",
"\n",
"![Evaluations](https://www.trulens.org/assets/images/Leaderboard.png)\n",
"![Evaluations](https://www.trulens.org/Assets/image/Leaderboard.png)\n",
"\n",
"### Deep dive into full chain metadata\n",
"\n",
"Click on a record to dive deep into all of the details of your chain stack and underlying LLM, captured by tru_chain_recorder.\n",
"\n",
"![Explore a Chain](https://www.trulens.org/assets/images/Chain_Explore.png)\n",
"\n",
"If you prefer the raw format, you can quickly get it using the \"Display full chain json\" or \"Display full record json\" buttons at the bottom of the page.\n",
"\n",
"### Run the Chain from the Dashboard\n",
"\n",
"![App Runner](https://www.trulens.org/assets/images/appui/running_session.png)\n",
"![Explore a Chain](https://www.trulens.org/Assets/image/Chain_Explore.png)\n",
"\n",
"You can run the chain inside the dashboard by creating a new session on the \"Apps\" page. See more information about this feature in `dashboard_appui.ipynb`."
"If you prefer the raw format, you can quickly get it using the \"Display full chain json\" or \"Display full record json\" buttons at the bottom of the page."
]
},
{
Expand Down
4 changes: 0 additions & 4 deletions trulens_eval/trulens_eval/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,6 @@ def __init__(
metadata: Optional[Metadata] = None,
feedback_mode: FeedbackMode = FeedbackMode.WITH_APP_THREAD,
app_extra_json: JSON = None,
new_session: Optional[Callable[[], Any]] = None,
**kwargs
):

Expand Down Expand Up @@ -570,9 +569,6 @@ def __init__(
metadata = {}
self.metadata = metadata

if new_session is not None:
kwargs['initial_app_loader'] = new_session

# EXPERIMENTAL
if 'initial_app_loader' in kwargs:
try:
Expand Down

0 comments on commit 6bde633

Please sign in to comment.