Skip to content

Commit

Permalink
Josh/langchain prompt import, tag quickstart versions (#602)
Browse files Browse the repository at this point in the history
* remove extra reset cell

* fix langchain prompt import, quickstart

* async fix imports, update install pins

* fix langchain prompttemplate imports

* ada embeddings in quickstart, pinned install versions

* pin package versions

* clear output
  • Loading branch information
joshreini1 authored Nov 29, 2023
1 parent a81438c commit 56ee9b2
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"metadata": {},
"outputs": [],
"source": [
"# ! pip install trulens_eval==0.18.0 langchain>=0.0.335"
"# ! pip install trulens_eval==0.18.1 langchain>=0.0.342"
]
},
{
Expand All @@ -40,7 +40,7 @@
"import asyncio\n",
"\n",
"from langchain import LLMChain\n",
"from langchain import PromptTemplate\n",
"from langchain.prompts import PromptTemplate\n",
"from langchain.callbacks import AsyncIteratorCallbackHandler\n",
"from langchain.chains import LLMChain\n",
"from langchain.chat_models.openai import ChatOpenAI\n",
Expand Down Expand Up @@ -70,8 +70,8 @@
"outputs": [],
"source": [
"import os\n",
"os.environ[\"HUGGINGFACE_API_KEY\"] = \"...\"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"...\""
"os.environ[\"HUGGINGFACE_API_KEY\"] = \"hf_...\"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"sk-...\""
]
},
{
Expand Down Expand Up @@ -223,13 +223,6 @@
"await task\n",
"record = recording.get()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -248,7 +241,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.11.5"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"metadata": {},
"outputs": [],
"source": [
"# ! pip install trulens==0.11.0 langchain==0.0.283"
"# ! pip install trulens_eval==0.18.1 langchain>=0.0.342"
]
},
{
Expand All @@ -39,8 +39,8 @@
"source": [
"from langchain.chains import LLMChain\n",
"from langchain.llms import OpenAI\n",
"from langchain.prompts.chat import ChatPromptTemplate, PromptTemplate\n",
"from langchain.prompts.chat import HumanMessagePromptTemplate\n",
"from langchain.prompts import ChatPromptTemplate, PromptTemplate\n",
"from langchain.prompts import HumanMessagePromptTemplate\n",
"\n",
"from trulens_eval import Feedback, Tru, TruChain\n",
"from trulens_eval.feedback import GroundTruthAgreement, Huggingface\n",
Expand All @@ -63,8 +63,8 @@
"outputs": [],
"source": [
"import os\n",
"os.environ[\"HUGGINGFACE_API_KEY\"] = \"...\"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"...\""
"os.environ[\"HUGGINGFACE_API_KEY\"] = \"hf_...\"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"sk-...\""
]
},
{
Expand Down Expand Up @@ -189,7 +189,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.5"
},
"vscode": {
"interpreter": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"# ! pip install langchain>=0.0.170\n",
"from langchain.chains import LLMChain\n",
"from langchain.llms import OpenAI\n",
"from langchain.prompts.chat import ChatPromptTemplate, PromptTemplate\n",
"from langchain.prompts.chat import HumanMessagePromptTemplate\n",
"from langchain.prompts import ChatPromptTemplate, PromptTemplate\n",
"from langchain.prompts import HumanMessagePromptTemplate\n",
"from langchain import PromptTemplate\n",
"from langchain.llms import OpenAI\n",
"from langchain import LLMChain\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/truera/trulens/blob/main/trulens_eval/examples/quickstart/langchain_retrieval_agent.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -55,7 +50,7 @@
"from trulens_eval import TruChain, Feedback, Tru, feedback, Select, FeedbackMode\n",
"from trulens_eval.feedback import OpenAI as fOpenAI\n",
"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"...\"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"sk-...\"\n",
"tru = Tru()\n"
]
},
Expand Down Expand Up @@ -337,20 +332,6 @@
"source": [
"tru.start_evaluator()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
9 changes: 9 additions & 0 deletions trulens_eval/examples/quickstart/groundtruth_evals.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
"For this quickstart, you will need Open AI keys."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ! pip install trulens==0.18.1 openai==1.3.1"
]
},
{
"cell_type": "code",
"execution_count": 2,
Expand Down
97 changes: 18 additions & 79 deletions trulens_eval/examples/quickstart/human_feedback.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/truera/trulens/blob/main/trulens_eval/examples/quickstart/human_feedback.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ! pip install trulens==0.18.1 openai==1.3.1"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -38,7 +47,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -56,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -97,7 +106,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -114,7 +123,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -133,25 +142,9 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "4addc21b832d4bebb2124f902d9f7ac0",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(Button(description='👍', style=ButtonStyle()), Button(description='👎', style=ButtonStyle())))"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"from ipywidgets import Button, HBox, VBox\n",
"\n",
Expand All @@ -176,7 +169,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -198,63 +191,9 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Human Feedack</th>\n",
" <th>latency</th>\n",
" <th>total_cost</th>\n",
" </tr>\n",
" <tr>\n",
" <th>app_id</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>LLM App v1</th>\n",
" <td>1.0</td>\n",
" <td>1.0</td>\n",
" <td>0.000159</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Human Feedack latency total_cost\n",
"app_id \n",
"LLM App v1 1.0 1.0 0.000159"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"tru.get_leaderboard(app_ids=[tru_app.app_id])"
]
Expand Down
13 changes: 11 additions & 2 deletions trulens_eval/examples/quickstart/langchain_quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
"For this quickstart you will need Open AI and Huggingface keys"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ! pip install trulens==0.18.1 openai==1.3.1"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -59,8 +68,8 @@
"# ! pip install langchain>=0.0.170\n",
"from langchain.chains import LLMChain\n",
"from langchain.llms import OpenAI\n",
"from langchain.prompts.chat import ChatPromptTemplate, PromptTemplate\n",
"from langchain.prompts.chat import HumanMessagePromptTemplate"
"from langchain.prompts import ChatPromptTemplate, PromptTemplate\n",
"from langchain.prompts import HumanMessagePromptTemplate"
]
},
{
Expand Down
9 changes: 9 additions & 0 deletions trulens_eval/examples/quickstart/prototype_evals.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@
"## Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ! pip install trulens==0.18.1"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Loading

0 comments on commit 56ee9b2

Please sign in to comment.