|
2 | 2 | "cells": [ |
3 | 3 | { |
4 | 4 | "cell_type": "code", |
5 | | - "execution_count": null, |
| 5 | + "execution_count": 20, |
6 | 6 | "metadata": {}, |
7 | 7 | "outputs": [], |
8 | 8 | "source": [ |
|
16 | 16 | " azure_endpoint=os.getenv(\"OPENAI_API_BASE\", \"\").strip()\n", |
17 | 17 | ")\n", |
18 | 18 | "\n", |
19 | | - "API_KEY = os.getenv(\"AZURE_OPENAI_API_KEY\",\"\").strip()\n", |
20 | | - "assert API_KEY, \"ERROR: Azure OpenAI Key is missing\"\n", |
21 | | - "openai.api_key = API_KEY\n", |
22 | | - "\n", |
23 | | - "RESOURCE_ENDPOINT = os.getenv(\"OPENAI_API_BASE\",\"\").strip()\n", |
24 | | - "assert RESOURCE_ENDPOINT, \"ERROR: Azure OpenAI Endpoint is missing\"\n", |
25 | | - "assert \"openai.azure.com\" in RESOURCE_ENDPOINT.lower(), \"ERROR: Azure OpenAI Endpoint should be in the form: \\n\\n\\t<your unique endpoint identifier>.openai.azure.com\"\n", |
26 | | - "openai.api_base = RESOURCE_ENDPOINT\n", |
27 | | - "deployment = \"gpt-35-turbo\" # replace with your deployment name" |
| 19 | + "# Đảm bảo endpoint đúng định dạng\n", |
| 20 | + "assert \"openai.azure.com\" in RESOURCE_ENDPOINT.lower(), \\\n", |
| 21 | + " \"Azure endpoint phải chứa openai.azure.com\"" |
28 | 22 | ] |
29 | 23 | }, |
30 | 24 | { |
31 | 25 | "cell_type": "code", |
32 | | - "execution_count": 13, |
| 26 | + "execution_count": 21, |
33 | 27 | "metadata": {}, |
34 | | - "outputs": [], |
| 28 | + "outputs": [ |
| 29 | + { |
| 30 | + "data": { |
| 31 | + "text/plain": [ |
| 32 | + "\"There are many potential causes of foot pain, ranging from minor issues like blisters or calluses to more serious conditions like fractures, tendonitis, or nerve damage. Some common causes of foot pain include plantar fasciitis, Achilles tendonitis, stress fractures, and arthritis.\\n\\nIf your foot pain is persistent, severe, or affecting your daily activities, it's important to see a doctor for a proper diagnosis and treatment. As a specialist in surgery, I can perform a thorough evaluation, order any necessary imaging tests, and recommend a treatment plan tailored to your specific condition. Treatment options may include rest, physical therapy, medication, orthotics, or in some cases, surgery.\\n\\nIt's important not to ignore foot pain, as delaying treatment can lead to further complications. I recommend making an appointment with a healthcare provider to determine the underlying cause of your foot pain and to discuss the best course of action for your specific situation.\"" |
| 33 | + ] |
| 34 | + }, |
| 35 | + "execution_count": 21, |
| 36 | + "metadata": {}, |
| 37 | + "output_type": "execute_result" |
| 38 | + } |
| 39 | + ], |
35 | 40 | "source": [ |
36 | 41 | "deployment = 'gpt-3.5-turbo'\n", |
37 | 42 | "# Create your first prompt\n", |
38 | | - "text_prompt = \" My stomach hurts, what can be wrong?\"\n", |
39 | | - "from openai import AzureOpenAI\n", |
| 43 | + "text_prompt = \" My foot hurts, what can be wrong?\"\n", |
40 | 44 | "\n", |
41 | | - "response = openai.ChatCompletion.create(\n", |
42 | | - " engine=deployment,\n", |
43 | | - " messages = [\n", |
44 | | - " {\"role\":\"system\", \"content\":\"I'm a doctor, specialist on surgery\"},\n", |
45 | | - " {\"role\":\"user\",\"content\":text_prompt},])\n", |
| 45 | + "response = client.chat.completions.create(\n", |
| 46 | + " model=deployment,\n", |
| 47 | + " messages=[\n", |
| 48 | + " {\"role\": \"system\", \"content\": \"I'm a doctor, specialist on surgery\"},\n", |
| 49 | + " {\"role\": \"user\", \"content\": text_prompt},\n", |
| 50 | + " ]\n", |
| 51 | + ")\n", |
46 | 52 | "\n", |
47 | 53 | "\n", |
48 | | - "response['choices'][0]['message']['content']" |
| 54 | + "response.choices[0].message.content" |
49 | 55 | ] |
50 | 56 | } |
51 | 57 | ], |
52 | 58 | "metadata": { |
53 | 59 | "kernelspec": { |
54 | | - "display_name": "Python 3", |
| 60 | + "display_name": "ai", |
55 | 61 | "language": "python", |
56 | 62 | "name": "python3" |
57 | 63 | }, |
|
65 | 71 | "name": "python", |
66 | 72 | "nbconvert_exporter": "python", |
67 | 73 | "pygments_lexer": "ipython3", |
68 | | - "version": "3.10.13" |
| 74 | + "version": "3.11.13" |
69 | 75 | }, |
70 | 76 | "orig_nbformat": 4 |
71 | 77 | }, |
|
0 commit comments