diff --git a/Basics/A gradio webapp with Azure ChatGPT.ipynb b/Basics/A gradio webapp with Azure ChatGPT.ipynb
new file mode 100644
index 0000000..0849a55
--- /dev/null
+++ b/Basics/A gradio webapp with Azure ChatGPT.ipynb
@@ -0,0 +1,216 @@
+{
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "73cb6403",
+ "metadata": {},
+ "source": [
+ "# A gradio webapp with Azure ChatGPT"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "2684f6ee",
+ "metadata": {},
+ "source": [
+ "
"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "51e9adf2",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "import openai\n",
+ "import os\n",
+ "import gradio as gr\n",
+ "import openai\n",
+ "import random\n",
+ "import time\n",
+ "import sys\n",
+ "\n",
+ "from dotenv import load_dotenv"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "6100958c",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "sys.version"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "id": "9d3ed4c4",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "load_dotenv(\"azure.env\")\n",
+ "\n",
+ "openai.api_type: str = \"azure\"\n",
+ "openai.api_key = os.getenv(\"OPENAI_API_KEY\")\n",
+ "openai.api_base = os.getenv(\"OPENAI_API_BASE\")\n",
+ "openai.api_version = os.getenv(\"OPENAI_API_VERSION\")"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "id": "9fcd25e8",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "deployment_id = \"gpt-35-turbo-16k\""
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 11,
+ "id": "99b623f7",
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "system_message = {\"role\": \"system\", \"content\": \"You are an AI assistant.\"}\n",
+ "\n",
+ "# https://huggingface.co/spaces/gradio/theme-gallery\n",
+ "\n",
+ "with gr.Blocks() as azure_openai_bot:\n",
+ " chatbot = gr.Chatbot()\n",
+ " msg = gr.Textbox()\n",
+ " clear = gr.Button(\"Clear\")\n",
+ "\n",
+ " state = gr.State([])\n",
+ "\n",
+ " def user(user_message, history):\n",
+ " return \"\", history + [[user_message, None]]\n",
+ "\n",
+ " def bot(history, messages_history):\n",
+ " user_message = history[-1][0]\n",
+ " bot_message, messages_history = ask_gpt(user_message, messages_history)\n",
+ " messages_history += [{\"role\": \"assistant\", \"content\": bot_message}]\n",
+ " history[-1][1] = bot_message\n",
+ " time.sleep(1)\n",
+ " return history, messages_history\n",
+ "\n",
+ " def ask_gpt(message, messages_history):\n",
+ " messages_history += [{\"role\": \"user\", \"content\": message}]\n",
+ " response = openai.ChatCompletion.create(\n",
+ " model=deployment_id,\n",
+ " messages=messages_history,\n",
+ " deployment_id=model,\n",
+ " )\n",
+ " print(response[\"choices\"][0][\"message\"][\"content\"], messages_history)\n",
+ " return response[\"choices\"][0][\"message\"][\"content\"], messages_history\n",
+ "\n",
+ " def init_history(messages_history):\n",
+ " messages_history = []\n",
+ " messages_history += [system_message]\n",
+ " return messages_history\n",
+ "\n",
+ " msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(\n",
+ " bot, [chatbot, state], [chatbot, state]\n",
+ " )\n",
+ "\n",
+ " clear.click(lambda: None, None, chatbot, queue=False).success(\n",
+ " init_history, [state], [state]\n",
+ " )"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "id": "bd6ed314",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Running on local URL: http://127.0.0.1:7862\n",
+ "Running on public URL: https://6e95fa214026e93372.gradio.live\n",
+ "\n",
+ "This share link expires in 72 hours. For free permanent hosting and GPU upgrades (NEW!), check out Spaces: https://huggingface.co/spaces\n"
+ ]
+ },
+ {
+ "data": {
+ "text/html": [
+ "
"
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ },
+ {
+ "data": {
+ "text/plain": []
+ },
+ "execution_count": 12,
+ "metadata": {},
+ "output_type": "execute_result"
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Hello! How may I assist you today? [{'role': 'user', 'content': 'Hello'}]\n",
+ "I am an AI language model developed by OpenAI. I am designed to answer questions, engage in conversations, and provide information on a wide range of topics. How can I assist you today? [{'role': 'user', 'content': 'Hello'}, {'role': 'assistant', 'content': 'Hello! How may I assist you today?'}, {'role': 'user', 'content': 'who are you?'}]\n",
+ "Azure OpenAI refers to the partnership between Microsoft Azure, a cloud computing service, and OpenAI, an artificial intelligence research organization. This partnership was formed to provide developers and businesses with access to advanced AI models and tools through the Azure platform.\n",
+ "\n",
+ "Through Azure OpenAI, developers can utilize OpenAI's powerful GPT-3 (Generative Pre-trained Transformer 3) model, which is designed to generate human-like text and respond to prompts, making it suitable for a wide range of applications. By leveraging Azure's infrastructure and resources, developers can easily integrate and deploy AI models and build innovative solutions using OpenAI's technologies.\n",
+ "\n",
+ "Overall, Azure OpenAI aims to empower developers to create intelligent applications that harness the capabilities of OpenAI's state-of-the-art models, while utilizing the scalable and robust infrastructure provided by Microsoft Azure. [{'role': 'user', 'content': 'Hello'}, {'role': 'assistant', 'content': 'Hello! How may I assist you today?'}, {'role': 'user', 'content': 'who are you?'}, {'role': 'assistant', 'content': 'I am an AI language model developed by OpenAI. I am designed to answer questions, engage in conversations, and provide information on a wide range of topics. How can I assist you today?'}, {'role': 'user', 'content': 'What is azure open ai?'}]\n",
+ "GPT-3, which stands for Generative Pre-trained Transformer 3, is a state-of-the-art language model developed by OpenAI. It is one of the most advanced and powerful AI models available today. GPT-3 has been trained on a massive amount of text data from the internet, allowing it to generate human-like text and respond to prompts in a wide range of contexts.\n",
+ "\n",
+ "GPT-3 uses a deep learning architecture called the Transformer, which is based on a neural network model. It has 175 billion parameters, making it one of the largest language models ever created. These parameters enable GPT-3 to understand and generate complex, coherent, and context-aware text.\n",
+ "\n",
+ "The model's capabilities go beyond traditional tasks such as language translation and sentiment analysis. GPT-3 can write essays, generate computer code, answer questions, create conversational agents, provide language-based assistance, and more. It can be used for a variety of applications, including content generation, chatbots, virtual assistants, and natural language understanding.\n",
+ "\n",
+ "Developers can access GPT-3 through the OpenAI API and use it to integrate advanced language processing capabilities into their applications, products, or services. However, it's important to note that GPT-3 has limitations and may produce incorrect or biased responses, so careful consideration and monitoring are necessary when using it in real-world scenarios. [{'role': 'user', 'content': 'Hello'}, {'role': 'assistant', 'content': 'Hello! How may I assist you today?'}, {'role': 'user', 'content': 'who are you?'}, {'role': 'assistant', 'content': 'I am an AI language model developed by OpenAI. I am designed to answer questions, engage in conversations, and provide information on a wide range of topics. How can I assist you today?'}, {'role': 'user', 'content': 'What is azure open ai?'}, {'role': 'assistant', 'content': \"Azure OpenAI refers to the partnership between Microsoft Azure, a cloud computing service, and OpenAI, an artificial intelligence research organization. This partnership was formed to provide developers and businesses with access to advanced AI models and tools through the Azure platform.\\n\\nThrough Azure OpenAI, developers can utilize OpenAI's powerful GPT-3 (Generative Pre-trained Transformer 3) model, which is designed to generate human-like text and respond to prompts, making it suitable for a wide range of applications. By leveraging Azure's infrastructure and resources, developers can easily integrate and deploy AI models and build innovative solutions using OpenAI's technologies.\\n\\nOverall, Azure OpenAI aims to empower developers to create intelligent applications that harness the capabilities of OpenAI's state-of-the-art models, while utilizing the scalable and robust infrastructure provided by Microsoft Azure.\"}, {'role': 'user', 'content': 'Tell me about GTP3'}]\n"
+ ]
+ }
+ ],
+ "source": [
+ "azure_openai_bot.launch(share=True)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "348260b0",
+ "metadata": {},
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3.10 - SDK v2",
+ "language": "python",
+ "name": "python310-sdkv2"
+ },
+ "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.10.10"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/Basics/bot.png b/Basics/bot.png
new file mode 100644
index 0000000..9531b7e
Binary files /dev/null and b/Basics/bot.png differ