|
15 | 15 | }, |
16 | 16 | { |
17 | 17 | "cell_type": "code", |
18 | | - "execution_count": 1, |
| 18 | + "execution_count": null, |
19 | 19 | "id": "9d9a71de", |
20 | 20 | "metadata": {}, |
21 | | - "outputs": [ |
22 | | - { |
23 | | - "name": "stdout", |
24 | | - "output_type": "stream", |
25 | | - "text": [ |
26 | | - "Requirement already satisfied: openai in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (1.13.3)\n", |
27 | | - "Requirement already satisfied: python-dotenv in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (1.0.1)\n", |
28 | | - "Requirement already satisfied: anyio<5,>=3.5.0 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from openai) (4.3.0)\n", |
29 | | - "Requirement already satisfied: distro<2,>=1.7.0 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from openai) (1.9.0)\n", |
30 | | - "Requirement already satisfied: httpx<1,>=0.23.0 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from openai) (0.27.0)\n", |
31 | | - "Requirement already satisfied: pydantic<3,>=1.9.0 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from openai) (2.6.3)\n", |
32 | | - "Requirement already satisfied: sniffio in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from openai) (1.3.1)\n", |
33 | | - "Requirement already satisfied: tqdm>4 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from openai) (4.66.2)\n", |
34 | | - "Requirement already satisfied: typing-extensions<5,>=4.7 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from openai) (4.10.0)\n", |
35 | | - "Requirement already satisfied: idna>=2.8 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from anyio<5,>=3.5.0->openai) (3.6)\n", |
36 | | - "Requirement already satisfied: certifi in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from httpx<1,>=0.23.0->openai) (2024.2.2)\n", |
37 | | - "Requirement already satisfied: httpcore==1.* in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from httpx<1,>=0.23.0->openai) (1.0.4)\n", |
38 | | - "Requirement already satisfied: h11<0.15,>=0.13 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)\n", |
39 | | - "Requirement already satisfied: annotated-types>=0.4.0 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from pydantic<3,>=1.9.0->openai) (0.6.0)\n", |
40 | | - "Requirement already satisfied: pydantic-core==2.16.3 in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from pydantic<3,>=1.9.0->openai) (2.16.3)\n", |
41 | | - "Requirement already satisfied: colorama in c:\\users\\henna\\documents\\github\\openai\\venv312\\lib\\site-packages (from tqdm>4->openai) (0.4.6)\n", |
42 | | - "Note: you may need to restart the kernel to use updated packages.\n" |
43 | | - ] |
44 | | - }, |
45 | | - { |
46 | | - "name": "stderr", |
47 | | - "output_type": "stream", |
48 | | - "text": [ |
49 | | - "\n", |
50 | | - "[notice] A new release of pip is available: 23.2.1 -> 24.0\n", |
51 | | - "[notice] To update, run: python.exe -m pip install --upgrade pip\n" |
52 | | - ] |
53 | | - } |
54 | | - ], |
| 21 | + "outputs": [], |
55 | 22 | "source": [ |
56 | 23 | "%pip install --upgrade openai python-dotenv" |
57 | 24 | ] |
58 | 25 | }, |
59 | 26 | { |
60 | 27 | "cell_type": "code", |
61 | | - "execution_count": 2, |
| 28 | + "execution_count": 11, |
62 | 29 | "id": "a92744f4", |
63 | 30 | "metadata": {}, |
64 | 31 | "outputs": [ |
|
68 | 35 | "True" |
69 | 36 | ] |
70 | 37 | }, |
71 | | - "execution_count": 2, |
| 38 | + "execution_count": 11, |
72 | 39 | "metadata": {}, |
73 | 40 | "output_type": "execute_result" |
74 | 41 | } |
|
89 | 56 | "### Setup Parameters\n", |
90 | 57 | "\n", |
91 | 58 | "\n", |
92 | | - "Here we will load the configurations from _config.json_ file to setup deployment name, openai api base, openai api key and openai api version." |
| 59 | + "Here we will read the environment variables from dotenv file to setup deployment name, openai api base, openai api key and openai api version." |
93 | 60 | ] |
94 | 61 | }, |
95 | 62 | { |
96 | 63 | "cell_type": "code", |
97 | | - "execution_count": 3, |
| 64 | + "execution_count": 12, |
98 | 65 | "id": "19ae1e36", |
99 | 66 | "metadata": {}, |
100 | 67 | "outputs": [], |
|
112 | 79 | "api_version = os.environ['OPENAI_API_VERSION']\n", |
113 | 80 | "\n", |
114 | 81 | "client = AzureOpenAI(\n", |
115 | | - " api_key = api_key, \n", |
116 | | - " azure_endpoint = azure_endpoint,\n", |
117 | | - " api_version = api_version\n", |
| 82 | + " api_key=api_key, \n", |
| 83 | + " azure_endpoint=azure_endpoint,\n", |
| 84 | + " api_version=api_version\n", |
118 | 85 | ")" |
119 | 86 | ] |
120 | 87 | }, |
121 | 88 | { |
122 | 89 | "cell_type": "code", |
123 | | - "execution_count": 4, |
| 90 | + "execution_count": null, |
124 | 91 | "id": "b15862a1", |
125 | 92 | "metadata": {}, |
126 | | - "outputs": [ |
127 | | - { |
128 | | - "name": "stdout", |
129 | | - "output_type": "stream", |
130 | | - "text": [ |
131 | | - "!\"\n", |
132 | | - "\n", |
133 | | - "# def outer_func(original_string):\n", |
134 | | - "# def inner_func(string):\n", |
135 | | - "# nonlocal original\n" |
136 | | - ] |
137 | | - } |
138 | | - ], |
| 93 | + "outputs": [], |
139 | 94 | "source": [ |
140 | 95 | "# Give your prompt here\n", |
141 | 96 | "prompt = \"Hello world\"\n", |
|
183 | 138 | " # Handle API error here, e.g. retry or log\n", |
184 | 139 | " print(f\"OpenAI API returned an API Error: {e}\")" |
185 | 140 | ] |
186 | | - }, |
187 | | - { |
188 | | - "cell_type": "code", |
189 | | - "execution_count": null, |
190 | | - "id": "b9be87b2", |
191 | | - "metadata": {}, |
192 | | - "outputs": [], |
193 | | - "source": [] |
194 | 141 | } |
195 | 142 | ], |
196 | 143 | "metadata": { |
|
0 commit comments