forked from Archives/langchain
Comet callback updates (#2889)
I'm working with @DN6 and I made some small fixes and improvements after playing with the integration.
This commit is contained in:
parent
634358db5e
commit
7ee87eb0c8
@ -1,7 +1,6 @@
|
|||||||
{
|
{
|
||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -9,7 +8,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -17,7 +15,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -31,7 +28,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -39,7 +35,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -52,14 +47,13 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"!pip install comet_ml\n",
|
"%pip install comet_ml langchain openai google-search-results spacy textstat pandas\n",
|
||||||
"!pip install langchain\n",
|
"\n",
|
||||||
"!pip install openai\n",
|
"import sys\n",
|
||||||
"!pip install google-search-results"
|
"!{sys.executable} -m spacy download en_core_web_sm"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -67,7 +61,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -86,7 +79,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -94,7 +86,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -109,12 +100,12 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
"%env OPENAI_API_KEY=\"...\"\n",
|
"os.environ[\"OPENAI_API_KEY\"] = \"...\"\n",
|
||||||
"%env SERPAPI_API_KEY=\"...\""
|
"#os.environ[\"OPENAI_ORGANIZATION\"] = \"...\"\n",
|
||||||
|
"os.environ[\"SERPAPI_API_KEY\"] = \"...\""
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -149,7 +140,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -185,12 +175,11 @@
|
|||||||
"synopsis_chain = LLMChain(llm=llm, prompt=prompt_template, callback_manager=manager)\n",
|
"synopsis_chain = LLMChain(llm=llm, prompt=prompt_template, callback_manager=manager)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"test_prompts = [{\"title\": \"Documentary about Bigfoot in Paris\"}]\n",
|
"test_prompts = [{\"title\": \"Documentary about Bigfoot in Paris\"}]\n",
|
||||||
"synopsis_chain.apply(test_prompts)\n",
|
"print(synopsis_chain.apply(test_prompts))\n",
|
||||||
"comet_callback.flush_tracker(synopsis_chain, finish=True)"
|
"comet_callback.flush_tracker(synopsis_chain, finish=True)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -232,7 +221,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -240,7 +228,6 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"attachments": {},
|
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
@ -256,7 +243,7 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"!pip install rouge-score"
|
"%pip install rouge-score"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -336,16 +323,29 @@
|
|||||||
" \"\"\"\n",
|
" \"\"\"\n",
|
||||||
" }\n",
|
" }\n",
|
||||||
"]\n",
|
"]\n",
|
||||||
"synopsis_chain.apply(test_prompts)\n",
|
"print(synopsis_chain.apply(test_prompts))\n",
|
||||||
"comet_callback.flush_tracker(synopsis_chain, finish=True)"
|
"comet_callback.flush_tracker(synopsis_chain, finish=True)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"language_info": {
|
"kernelspec": {
|
||||||
"name": "python"
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
},
|
},
|
||||||
"orig_nbformat": 4
|
"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.9.15"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 2
|
"nbformat_minor": 2
|
||||||
|
@ -34,12 +34,10 @@ def _get_experiment(
|
|||||||
) -> Any:
|
) -> Any:
|
||||||
comet_ml = import_comet_ml()
|
comet_ml = import_comet_ml()
|
||||||
|
|
||||||
experiment = comet_ml.config.get_global_experiment()
|
experiment = comet_ml.Experiment( # type: ignore
|
||||||
if experiment is None:
|
workspace=workspace,
|
||||||
experiment = comet_ml.Experiment( # type: ignore
|
project_name=project_name,
|
||||||
workspace=workspace,
|
)
|
||||||
project_name=project_name,
|
|
||||||
)
|
|
||||||
|
|
||||||
return experiment
|
return experiment
|
||||||
|
|
||||||
@ -132,7 +130,7 @@ class CometCallbackHandler(BaseMetadataCallbackHandler, BaseCallbackHandler):
|
|||||||
warning = (
|
warning = (
|
||||||
"The comet_ml callback is currently in beta and is subject to change "
|
"The comet_ml callback is currently in beta and is subject to change "
|
||||||
"based on updates to `langchain`. Please report any issues to "
|
"based on updates to `langchain`. Please report any issues to "
|
||||||
"https://github.com/comet_ml/issue_tracking/issues with the tag "
|
"https://github.com/comet-ml/issue_tracking/issues with the tag "
|
||||||
"`langchain`."
|
"`langchain`."
|
||||||
)
|
)
|
||||||
comet_ml.LOGGER.warning(warning)
|
comet_ml.LOGGER.warning(warning)
|
||||||
|
Loading…
Reference in New Issue
Block a user