Skip to content

Commit

Permalink
fix: TypeError: Client.__init__() got an unexpected keyword argument …
Browse files Browse the repository at this point in the history
…'proxies' [Google Colab] #294
  • Loading branch information
fm1320 committed Dec 17, 2024
1 parent 16793b0 commit e78448b
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions notebooks/tutorials/adalflow_rag_optimization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"metadata": {
"id": "xHF95Kr4CzGq"
},
"metadata": {
"id": "xHF95Kr4CzGq"
},
"source": [
"# 🤗 Welcome to AdalFlow!\n",
"## The PyTorch library to auto-optimize any LLM task pipelines\n",
Expand Down Expand Up @@ -34,6 +37,7 @@
"\n",
"- Learn how to connect the output-input between components to enable auto-text-grad optimization."
]
]
},
"id": "ONfzF9Puzdd_",
"outputId": "5fc0cd30-9ae7-443a-c06c-31e9edeafd69"
Expand All @@ -46,6 +50,9 @@
"metadata": {
"id": "Kof5M6DRaKhh"
},
"metadata": {
"id": "Kof5M6DRaKhh"
},
"source": [
"\n",
"# Installation\n",
Expand All @@ -59,6 +66,7 @@
"\n",
"You can choose to use different client. You can import the model client you prefer. We support `Anthropic`, `Cohere`, `Google`, `GROQ`, `OpenAI`, `Transformer` and more in development. We will use OpenAI here as an example.Please refer to our [full installation guide](https://adalflow.sylph.ai/get_started/installation.html)"
]
]
},
{
"cell_type": "code",
Expand All @@ -76,6 +84,9 @@
"!pip uninstall httpx anyio -y\n",
"!pip install \"anyio>=3.1.0,<4.0\"\n",
"!pip install httpx==0.24.1\n",
"!pip uninstall httpx anyio -y\n",
"!pip install \"anyio>=3.1.0,<4.0\"\n",
"!pip install httpx==0.24.1\n",
"clear_output()"
]
},
Expand All @@ -84,6 +95,9 @@
"metadata": {
"id": "KapUyHMM07pJ"
},
"metadata": {
"id": "KapUyHMM07pJ"
},
"source": [
"## Set Environment Variables\n",
"\n",
Expand All @@ -93,6 +107,7 @@
"\n",
"*Go to [OpenAI](https://platform.openai.com/docs/introduction) to get API keys if you don't already have.*"
]
]
},
{
"cell_type": "code",
Expand All @@ -114,6 +129,24 @@
]
}
],
"execution_count": 3,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ONfzF9Puzdd_",
"outputId": "5fc0cd30-9ae7-443a-c06c-31e9edeafd69"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Please enter your OpenAI API key: ··········\n",
"API keys have been set.\n"
]
}
],
"source": [
"import os\n",
"\n",
Expand All @@ -136,6 +169,11 @@
"id": "aE3I05BqOmd7"
},
"outputs": [],
"execution_count": 20,
"metadata": {
"id": "aE3I05BqOmd7"
},
"outputs": [],
"source": [
"import dspy\n",
"import re\n",
Expand All @@ -151,6 +189,7 @@
"from adalflow.core.component import fun_to_component\n",
"from adalflow.components.model_client.openai_client import OpenAIClient"
]
]
},
{
"cell_type": "code",
Expand All @@ -159,6 +198,11 @@
"id": "cqUUoua9fUxQ"
},
"outputs": [],
"execution_count": null,
"metadata": {
"id": "cqUUoua9fUxQ"
},
"outputs": [],
"source": [
"\n",
"gpt_4o_model = {\n",
Expand All @@ -177,6 +221,7 @@
" },\n",
"}"
]
]
},
{
"cell_type": "code",
Expand Down Expand Up @@ -207,6 +252,33 @@
"output_type": "execute_result"
}
],
"execution_count": 22,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "0irHeHUkOmL8",
"outputId": "61f778a2-9ec1-4fda-daa2-bcc7f31baa78"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"HotPotQAData(id='5a8b57f25542995d1e6f1371', question='Were Scott Derrickson and Ed Wood of the same nationality?', answer='yes', gold_titles=\"{'Scott Derrickson', 'Ed Wood'}\") <class 'adalflow.datasets.types.HotPotQAData'>\n"
]
},
{
"data": {
"text/plain": [
"HotPotQAData(id='5a8b57f25542995d1e6f1371', question='Were Scott Derrickson and Ed Wood of the same nationality?', answer='yes', gold_titles=\"{'Scott Derrickson', 'Ed Wood'}\")"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"def load_datasets():\n",
"\n",
Expand Down Expand Up @@ -242,6 +314,11 @@
"id": "ZZIEtZYHNVjo"
},
"outputs": [],
"execution_count": 23,
"metadata": {
"id": "ZZIEtZYHNVjo"
},
"outputs": [],
"source": [
"class DspyRetriever(adal.Retriever):\n",
" def __init__(self, top_k: int = 3):\n",
Expand Down

0 comments on commit e78448b

Please sign in to comment.