Spaces:
Runtime error
Runtime error
lizhen commited on
Commit ·
85a9c6b
1
Parent(s): 85a770f
add anthropic
Browse files- README.md +2 -0
- anthropic_simple.ipynb +53 -0
README.md
CHANGED
|
@@ -30,6 +30,8 @@ Anaconda的升级、配置及使用
|
|
| 30 |
https://blog.csdn.net/turui/article/details/127063642
|
| 31 |
Jupyter Notebooks in VS Code / %%time
|
| 32 |
https://code.visualstudio.com/docs/datascience/jupyter-notebooks
|
|
|
|
|
|
|
| 33 |
|
| 34 |
pip3 install langchain
|
| 35 |
pip3 install redis
|
|
|
|
| 30 |
https://blog.csdn.net/turui/article/details/127063642
|
| 31 |
Jupyter Notebooks in VS Code / %%time
|
| 32 |
https://code.visualstudio.com/docs/datascience/jupyter-notebooks
|
| 33 |
+
Anthropic
|
| 34 |
+
https://zhuanlan.zhihu.com/p/621785668
|
| 35 |
|
| 36 |
pip3 install langchain
|
| 37 |
pip3 install redis
|
anthropic_simple.ipynb
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [
|
| 8 |
+
{
|
| 9 |
+
"ename": "ValidationError",
|
| 10 |
+
"evalue": "1 validation error for Anthropic\n__root__\n Did not find anthropic_api_key, please add an environment variable `ANTHROPIC_API_KEY` which contains it, or pass `anthropic_api_key` as a named parameter. (type=value_error)",
|
| 11 |
+
"output_type": "error",
|
| 12 |
+
"traceback": [
|
| 13 |
+
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
| 14 |
+
"\u001b[1;31mValidationError\u001b[0m Traceback (most recent call last)",
|
| 15 |
+
"Cell \u001b[1;32mIn[1], line 5\u001b[0m\n\u001b[0;32m 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcallbacks\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbase\u001b[39;00m \u001b[39mimport\u001b[39;00m CallbackManager\n\u001b[0;32m 3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mlangchain\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mcallbacks\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mstreaming_stdout\u001b[39;00m \u001b[39mimport\u001b[39;00m StreamingStdOutCallbackHandler\n\u001b[1;32m----> 5\u001b[0m llm \u001b[39m=\u001b[39m Anthropic(streaming\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m, callback_manager\u001b[39m=\u001b[39;49mCallbackManager([StreamingStdOutCallbackHandler()]), verbose\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m, temperature\u001b[39m=\u001b[39;49m\u001b[39m0\u001b[39;49m)\n\u001b[0;32m 6\u001b[0m llm(\u001b[39m\"\u001b[39m\u001b[39m仿写一份周杰伦的歌词\u001b[39m\u001b[39m\"\u001b[39m)\n",
|
| 16 |
+
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\pydantic\\main.py:341\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.__init__\u001b[1;34m()\u001b[0m\n",
|
| 17 |
+
"\u001b[1;31mValidationError\u001b[0m: 1 validation error for Anthropic\n__root__\n Did not find anthropic_api_key, please add an environment variable `ANTHROPIC_API_KEY` which contains it, or pass `anthropic_api_key` as a named parameter. (type=value_error)"
|
| 18 |
+
]
|
| 19 |
+
}
|
| 20 |
+
],
|
| 21 |
+
"source": [
|
| 22 |
+
"from langchain import Anthropic\n",
|
| 23 |
+
"from langchain.callbacks.base import CallbackManager\n",
|
| 24 |
+
"from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler\n",
|
| 25 |
+
"\n",
|
| 26 |
+
"llm = Anthropic(streaming=True, callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]), verbose=True, temperature=0)\n",
|
| 27 |
+
"llm(\"仿写一份周杰伦的歌词\")"
|
| 28 |
+
]
|
| 29 |
+
}
|
| 30 |
+
],
|
| 31 |
+
"metadata": {
|
| 32 |
+
"kernelspec": {
|
| 33 |
+
"display_name": "Python 3",
|
| 34 |
+
"language": "python",
|
| 35 |
+
"name": "python3"
|
| 36 |
+
},
|
| 37 |
+
"language_info": {
|
| 38 |
+
"codemirror_mode": {
|
| 39 |
+
"name": "ipython",
|
| 40 |
+
"version": 3
|
| 41 |
+
},
|
| 42 |
+
"file_extension": ".py",
|
| 43 |
+
"mimetype": "text/x-python",
|
| 44 |
+
"name": "python",
|
| 45 |
+
"nbconvert_exporter": "python",
|
| 46 |
+
"pygments_lexer": "ipython3",
|
| 47 |
+
"version": "3.11.3"
|
| 48 |
+
},
|
| 49 |
+
"orig_nbformat": 4
|
| 50 |
+
},
|
| 51 |
+
"nbformat": 4,
|
| 52 |
+
"nbformat_minor": 2
|
| 53 |
+
}
|