diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..c46b364 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,13 @@ +ARG VARIANT="focal" +FROM buildpack-deps:${VARIANT}-curl + +LABEL dev.containers.features="common" + +COPY first-run-notice.txt /tmp/scripts/ + +# Move first run notice to right spot +RUN mkdir -p "/usr/local/etc/vscode-dev-containers/" \ + && mv -f /tmp/scripts/first-run-notice.txt /usr/local/etc/vscode-dev-containers/ + +# Remove scripts now that we're done with them +RUN rm -rf /tmp/scripts diff --git a/.devcontainer/bootstrap b/.devcontainer/bootstrap new file mode 100755 index 0000000..0651f3c --- /dev/null +++ b/.devcontainer/bootstrap @@ -0,0 +1,8 @@ +#!/bin/bash + +ROOT_DIR=/workspaces/codespaces-models + +npm install ${ROOT_DIR} + +pip install -r ${ROOT_DIR}/requirements.txt + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index c30f181..c166428 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,44 @@ { - "image": "mcr.microsoft.com/devcontainers/universal:2", - "updateContentCommand": "npm install; pip install -r requirements.txt", - "postStartCommand": "npm install; pip install -r requirements.txt", + "build": { + "dockerfile": "./Dockerfile", + "context": "." + }, + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "username": "codespace", + "userUid": "1000", + "userGid": "1000" + }, + "ghcr.io/devcontainers/features/node:1": { + "version": "20" + }, + "ghcr.io/devcontainers/features/python:1": { + "version": "3.11.9", + "installJupyterLab": "false" + }, + "ghcr.io/devcontainers/features/git:1": { + "version": "latest", + "ppa": "false" + }, + "ghcr.io/devcontainers/features/git-lfs:1": { + "version": "latest" + }, + "ghcr.io/devcontainers/features/github-cli:1": { + "version": "latest" + } + }, + "overrideFeatureInstallOrder": [ + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/devcontainers/features/git", + "ghcr.io/devcontainers/features/node", + "ghcr.io/devcontainers/features/python", + "ghcr.io/devcontainers/features/git-lfs", + "ghcr.io/devcontainers/features/github-cli" + ], + "remoteUser": "codespace", + "containerUser": "codespace", + "updateContentCommand": "${containerWorkspaceFolder}/.devcontainer/bootstrap", + "postStartCommand": "${containerWorkspaceFolder}/.devcontainer/bootstrap", "customizations": { "codespaces": { "disableAutomaticConfiguration": true, @@ -16,10 +53,19 @@ "ms-toolsai.prompty" ], "settings": { + /* + NOTE: excluding these Python environments causes Jupyter to select the remaining environment by default + The default environment will be: /usr/local/python/current/bin/python + */ + "jupyter.kernels.excludePythonEnvironments": [ + "/usr/local/python/current/bin/python3", + "/usr/bin/python3", + "/bin/python3" + ], "workbench.editorAssociations": { "*.md": "vscode.markdown.preview.editor" } } } } -} +} \ No newline at end of file diff --git a/.devcontainer/first-run-notice.txt b/.devcontainer/first-run-notice.txt new file mode 100644 index 0000000..cbce6df --- /dev/null +++ b/.devcontainer/first-run-notice.txt @@ -0,0 +1,4 @@ +👋 Welcome to your shiny new Codespace for interacting with GitHub Models! We've got everything fired up and ready for you to explore AI Models hosted on Azure AI. + +Take a look at the README to find all of the information you need to get started. + diff --git a/.gitignore b/.gitignore index 91ac0c7..1cbb59b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ -.vscode/ +.vscode/* +!.vscode/extensions.json +!.vscode/launch.json __pycache__/ .env .DS_Store diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..3e91883 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "unwantedRecommendations": [ + "ms-azuretools.vscode-docker" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9c2fb3a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,25 @@ +{ + "configurations": [ + { + "name": "Run JavaScript Sample", + "program": "${file}", + "cwd": "${fileDirname}", + "envFile": "${workspaceFolder}/.env", + "outputCapture": "std", + "request": "launch", + "skipFiles": [ + "/**" + ], + "type": "node" + }, + { + "name": "Run Python Sample", + "program": "${file}", + "cwd": "${fileDirname}", + "envFile": "${workspaceFolder}/.env", + "redirectOutput": false, + "request": "launch", + "type": "debugpy" + } + ] +} diff --git a/cookbooks/python/langchain/lc_openai_getting_started.ipynb b/cookbooks/python/langchain/lc_openai_getting_started.ipynb index 3bd5b59..9b88840 100644 --- a/cookbooks/python/langchain/lc_openai_getting_started.ipynb +++ b/cookbooks/python/langchain/lc_openai_getting_started.ipynb @@ -52,7 +52,7 @@ "os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"GITHUB_TOKEN\")\n", "os.environ[\"OPENAI_BASE_URL\"] = \"https://models.inference.ai.azure.com/\"\n", "\n", - "GPT_MODEL = \"gpt-4o\"\n", + "GPT_MODEL = \"gpt-4o-mini\"\n", "\n", "llm = ChatOpenAI(model=GPT_MODEL)" ] @@ -373,7 +373,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/llamaindex/rag_getting_started.ipynb b/cookbooks/python/llamaindex/rag_getting_started.ipynb index 66be913..e30e7d7 100644 --- a/cookbooks/python/llamaindex/rag_getting_started.ipynb +++ b/cookbooks/python/llamaindex/rag_getting_started.ipynb @@ -38,7 +38,7 @@ "\n", "To run RAG, you need 2 models: a chat model, and an embedding model. The GitHub Model service offers different options.\n", "\n", - "For instance you could use an Azure OpenAI chat model (`gpt-4o`) and embedding model (`text-embedding-3-small`), or a Cohere chat model (`Cohere-command-r-plus`) and embedding model (`Cohere-embed-v3-multilingual`).\n", + "For instance you could use an Azure OpenAI chat model (`gpt-4o-mini`) and embedding model (`text-embedding-3-small`), or a Cohere chat model (`Cohere-command-r-plus`) and embedding model (`Cohere-embed-v3-multilingual`).\n", "\n", "We'll proceed using some of the Azure OpenAI models below. You can find [how to leverage Cohere models in the LlamaIndex documentation](https://docs.llamaindex.ai/en/stable/examples/llm/cohere/).\n", "\n", @@ -89,7 +89,7 @@ "logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))\n", "\n", "llm = OpenAI(\n", - " model=\"gpt-4o\",\n", + " model=\"gpt-4o-mini\",\n", " api_key=os.getenv(\"OPENAI_API_KEY\"),\n", " api_base=os.getenv(\"OPENAI_BASE_URL\"),\n", ")\n", @@ -258,7 +258,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/mistralai/evaluation.ipynb b/cookbooks/python/mistralai/evaluation.ipynb index 5ba2d81..a7520e1 100644 --- a/cookbooks/python/mistralai/evaluation.ipynb +++ b/cookbooks/python/mistralai/evaluation.ipynb @@ -525,7 +525,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/mistralai/function_calling.ipynb b/cookbooks/python/mistralai/function_calling.ipynb index 639d10f..da54f10 100644 --- a/cookbooks/python/mistralai/function_calling.ipynb +++ b/cookbooks/python/mistralai/function_calling.ipynb @@ -349,7 +349,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/mistralai/prefix_use_cases.ipynb b/cookbooks/python/mistralai/prefix_use_cases.ipynb index f41e0f0..8937a2a 100644 --- a/cookbooks/python/mistralai/prefix_use_cases.ipynb +++ b/cookbooks/python/mistralai/prefix_use_cases.ipynb @@ -868,7 +868,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/mistralai/prompting_capabilities.ipynb b/cookbooks/python/mistralai/prompting_capabilities.ipynb index f0ca1c9..4d90b85 100644 --- a/cookbooks/python/mistralai/prompting_capabilities.ipynb +++ b/cookbooks/python/mistralai/prompting_capabilities.ipynb @@ -505,7 +505,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/openai/Data_extraction_transformation.ipynb b/cookbooks/python/openai/Data_extraction_transformation.ipynb index a419f3b..5d6999b 100644 --- a/cookbooks/python/openai/Data_extraction_transformation.ipynb +++ b/cookbooks/python/openai/Data_extraction_transformation.ipynb @@ -100,7 +100,7 @@ "os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"GITHUB_TOKEN\")\n", "os.environ[\"OPENAI_BASE_URL\"] = \"https://models.inference.ai.azure.com/\"\n", "\n", - "GPT_MODEL = \"gpt-4o\"\n", + "GPT_MODEL = \"gpt-4o-mini\"\n", "\n", "client = OpenAI()" ] @@ -193,7 +193,7 @@ " \"\"\"\n", " \n", " response = client.chat.completions.create(\n", - " model=\"gpt-4o\",\n", + " model=\"gpt-4o-mini\",\n", " response_format={ \"type\": \"json_object\" },\n", " messages=[\n", " {\n", @@ -491,7 +491,7 @@ " \"\"\"\n", " \n", " response = client.chat.completions.create(\n", - " model=\"gpt-4o\",\n", + " model=\"gpt-4o-mini\",\n", " response_format={ \"type\": \"json_object\" },\n", " messages=[\n", " {\n", @@ -813,7 +813,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/openai/Developing_hallucination_guardrails.ipynb b/cookbooks/python/openai/Developing_hallucination_guardrails.ipynb index c7af07a..085cfae 100644 --- a/cookbooks/python/openai/Developing_hallucination_guardrails.ipynb +++ b/cookbooks/python/openai/Developing_hallucination_guardrails.ipynb @@ -54,7 +54,7 @@ "os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"GITHUB_TOKEN\")\n", "os.environ[\"OPENAI_BASE_URL\"] = \"https://models.inference.ai.azure.com/\"\n", "\n", - "GPT_MODEL = \"gpt-4o\"\n", + "GPT_MODEL = \"gpt-4o-mini\"\n", "\n", "client = OpenAI()" ] @@ -179,7 +179,7 @@ " {\"role\": \"assistant\", \"content\": assistant_policy_example_1},\n", " {\"role\": \"user\", \"content\": input_message},\n", " ],\n", - " model=\"gpt-4o\"\n", + " model=\"gpt-4o-mini\"\n", " )\n", " \n", " return response.choices[0].message.content\n", @@ -378,7 +378,7 @@ " ]\n", "\n", " response = client.chat.completions.create(\n", - " model=\"gpt-4o\",\n", + " model=\"gpt-4o-mini\",\n", " messages=messages,\n", " temperature=0.7,\n", " n=10,\n", @@ -695,7 +695,7 @@ " ]\n", "\n", " response = client.chat.completions.create(\n", - " model=\"gpt-4o\",\n", + " model=\"gpt-4o-mini\",\n", " messages=messages,\n", " temperature=0.7,\n", " n=10\n", @@ -844,7 +844,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/openai/How_to_call_functions_with_chat_models.ipynb b/cookbooks/python/openai/How_to_call_functions_with_chat_models.ipynb index 6735f38..8392466 100644 --- a/cookbooks/python/openai/How_to_call_functions_with_chat_models.ipynb +++ b/cookbooks/python/openai/How_to_call_functions_with_chat_models.ipynb @@ -78,7 +78,7 @@ "os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"GITHUB_TOKEN\")\n", "os.environ[\"OPENAI_BASE_URL\"] = \"https://models.inference.ai.azure.com/\"\n", "\n", - "GPT_MODEL = \"gpt-4o\"\n", + "GPT_MODEL = \"gpt-4o-mini\"\n", "\n", "client = OpenAI()" ] @@ -451,7 +451,7 @@ "source": [ "### Parallel Function Calling\n", "\n", - "Newer models such as gpt-4o or gpt-3.5-turbo can call multiple functions in one turn." + "Newer models such as gpt-4o-mini or gpt-3.5-turbo can call multiple functions in one turn." ] }, { @@ -700,7 +700,7 @@ "}]\n", "\n", "response = client.chat.completions.create(\n", - " model='gpt-4o', \n", + " model='gpt-4o-mini', \n", " messages=messages, \n", " tools= tools, \n", " tool_choice=\"auto\"\n", @@ -747,7 +747,7 @@ " # Step 4: Invoke the chat completions API with the function response appended to the messages list\n", " # Note that messages with role 'tool' must be a response to a preceding message with 'tool_calls'\n", " model_response_with_function_call = client.chat.completions.create(\n", - " model=\"gpt-4o\",\n", + " model=\"gpt-4o-mini\",\n", " messages=messages,\n", " ) # get a new response from the model where it can see the function response\n", " print(model_response_with_function_call.choices[0].message.content)\n", @@ -766,7 +766,7 @@ "source": [ "## Next Steps\n", "\n", - "See our other notebook [Data extraction and transformation](Data_extraction_transformation.ipynb) which shows how to extract data from documents using gpt-4o." + "See our other notebook [Data extraction and transformation](Data_extraction_transformation.ipynb) which shows how to extract data from documents using gpt-4o-mini." ] } ], @@ -786,7 +786,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/cookbooks/python/openai/How_to_stream_completions.ipynb b/cookbooks/python/openai/How_to_stream_completions.ipynb index ef953d4..b4cbf3a 100644 --- a/cookbooks/python/openai/How_to_stream_completions.ipynb +++ b/cookbooks/python/openai/How_to_stream_completions.ipynb @@ -49,7 +49,7 @@ "os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"GITHUB_TOKEN\")\n", "os.environ[\"OPENAI_BASE_URL\"] = \"https://models.inference.ai.azure.com/\"\n", "\n", - "GPT_MODEL = \"gpt-4o\"\n", + "GPT_MODEL = \"gpt-4o-mini\"\n", "\n", "client = OpenAI()" ] @@ -169,7 +169,7 @@ "source": [ "### 3. How much time is saved by streaming a chat completion\n", "\n", - "Now let's ask `gpt-4o` to count to 100 again, and see how long it takes." + "Now let's ask `gpt-4o-mini` to count to 100 again, and see how long it takes." ] }, { @@ -255,7 +255,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" }, "orig_nbformat": 4, "vscode": { diff --git a/cookbooks/python/openai/README.md b/cookbooks/python/openai/README.md index 745da8a..9642c35 100644 --- a/cookbooks/python/openai/README.md +++ b/cookbooks/python/openai/README.md @@ -7,6 +7,6 @@ The samples were modified slightly to better run with the GitHub Models service. - [How to process image and video with GPT-4](how_to_process_image_and_video_with_gpt4o.ipynb): This notebook shows how to process images and videos with GPT-4. - [How to call functions with chat models](How_to_call_functions_with_chat_models.ipynb): This notebook shows how to get GPT-4o to determing which of a set of functions to call to answer a user's question. -- [Data extraction and transformation](Data_extraction_transformation.ipynb): This notebook shows how to extract data from documents using gpt-4o. +- [Data extraction and transformation](Data_extraction_transformation.ipynb): This notebook shows how to extract data from documents using gpt-4o-mini. - [How to stream completions](How_to_stream_completions.ipynb): This notebook shows detailed instructions on how to stream chat completions. - [Developing Hallucination Guardrails](Developing_hallucination_guardrails.ipynb): Develop an output guardrail that specifically checks model outputs for hallucinations diff --git a/cookbooks/python/openai/how_to_process_image_and_video_with_gpt4o.ipynb b/cookbooks/python/openai/how_to_process_image_and_video_with_gpt4o.ipynb index 393198a..5a1e0fb 100644 --- a/cookbooks/python/openai/how_to_process_image_and_video_with_gpt4o.ipynb +++ b/cookbooks/python/openai/how_to_process_image_and_video_with_gpt4o.ipynb @@ -55,7 +55,7 @@ "os.environ[\"OPENAI_API_KEY\"] = os.getenv(\"GITHUB_TOKEN\")\n", "os.environ[\"OPENAI_BASE_URL\"] = \"https://models.inference.ai.azure.com/\"\n", "\n", - "GPT_MODEL = \"gpt-4o\"\n", + "GPT_MODEL = \"gpt-4o-mini\"\n", "\n", "client = OpenAI()" ] @@ -76,7 +76,7 @@ "source": [ "def describe_image(image_url):\n", " response = client.chat.completions.create(\n", - " model=\"gpt-4o\",\n", + " model=\"gpt-4o-mini\",\n", " messages=[\n", " { \"role\": \"system\", \"content\": \"You are a helpful assistant.\" },\n", " { \"role\": \"user\", \"content\": [ \n", @@ -107,7 +107,7 @@ "source": [ "### Use a local image\n", "\n", - "If you want to use a local image, you can use the following Python code to convert it to base64 so it can be passed to the API. Alternative file conversion tools are available online. Let's try ask gpt-4o about the image below.\n", + "If you want to use a local image, you can use the following Python code to convert it to base64 so it can be passed to the API. Alternative file conversion tools are available online. Let's try ask gpt-4o-mini about the image below.\n", "\n", "![](data/sad-puppy.png)" ] @@ -153,29 +153,29 @@ "\n", "```json\n", "{\n", - " \"id\": \"chatcmpl-9jomPUi41IW2oekvr9rACvnEJz2k1\",\n", + " \"id\": \"chatcmpl-9vT1HlFN3bzRXTbYQgtRwPLfnGMxk\",\n", " \"choices\": [\n", " {\n", " \"finish_reason\": \"stop\",\n", " \"index\": 0,\n", " \"logprobs\": null,\n", " \"message\": {\n", - " \"content\": \"The picture shows an adorable, light brown puppy with big, expressive eyes, looking up with a somewhat pleading or curious expression. The puppy is sitting on a mat on a wooden floor, and there is an empty gray bowl in front of it. The setting seems to be indoors, possibly a kitchen or dining area, with a blurred background that includes some furniture, giving the space a cozy look. The puppy's fur is soft and fluffy, adding to its overall cuteness.\",\n", + " \"content\": \"The picture features a fluffy, light-colored puppy sitting on a rug. In front of the puppy is a dark-colored food bowl. The setting appears warm and cozy, with wooden furniture and a neutral-colored wall in the background. The overall mood conveys a sense of comfort and playfulness.\",\n", " \"role\": \"assistant\",\n", " \"function_call\": null,\n", " \"tool_calls\": null\n", " }\n", " }\n", " ],\n", - " \"created\": 1720706985,\n", - " \"model\": \"gpt-4o-2024-05-13\",\n", + " \"created\": 1723483275,\n", + " \"model\": \"gpt-4o-mini\",\n", " \"object\": \"chat.completion\",\n", " \"service_tier\": null,\n", - " \"system_fingerprint\": \"fp_298125635f\",\n", + " \"system_fingerprint\": \"fp_276aa25277\",\n", " \"usage\": {\n", - " \"completion_tokens\": 95,\n", - " \"prompt_tokens\": 276,\n", - " \"total_tokens\": 371\n", + " \"completion_tokens\": 57,\n", + " \"prompt_tokens\": 262,\n", + " \"total_tokens\": 319\n", " }\n", "}\n", "```\n", @@ -203,7 +203,7 @@ "\n", "def describe_image_detail(image_url, detail = \"auto\"):\n", " response = client.chat.completions.create(\n", - " model=\"gpt-4o\",\n", + " model=\"gpt-4o-mini\",\n", " messages=[\n", " { \"role\": \"system\", \"content\": \"You are a helpful assistant.\" },\n", " { \"role\": \"user\", \"content\": [ \n", @@ -350,7 +350,7 @@ " },\n", " ]\n", " \n", - " result = client.chat.completions.create(model=\"gpt-4o\", messages=PROMPT_MESSAGES)\n", + " result = client.chat.completions.create(model=\"gpt-4o-mini\", messages=PROMPT_MESSAGES)\n", " print(f\"used {result.usage.prompt_tokens} prompt tokens and {result.usage.completion_tokens} completion tokens.\\n\")\n", " print(result.choices[0].message.content)\n", " plot += result.choices[0].message.content + \"\\n\" \n", @@ -406,7 +406,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.13" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/requirements.txt b/requirements.txt index 72e2339..c66a430 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -azure-ai-inference==1.0.0b3 -openai==1.37.1 -mistralai==0.4.2 -python-dotenv==1.0.1 \ No newline at end of file +azure-ai-inference~=1.0.0b3 +openai~=1.37.1 +mistralai~=0.4.2 +python-dotenv~=1.0.1 +ipykernel~=6.29.5 \ No newline at end of file diff --git a/samples/README.md b/samples/README.md index 826a9c3..42f3f50 100644 --- a/samples/README.md +++ b/samples/README.md @@ -19,7 +19,7 @@ Use this Codespace to edit the samples and see what happens! Here are a few sugg Try switching to a different model by finding a line like the one below and changing the model selected. You can find other models to try at [GitHub Marketplace](https://github.com/marketplace/models). ```json - "model": "gpt-4o" + "model": "gpt-4o-mini" ``` ### Try a different prompt diff --git a/samples/curl/README.md b/samples/curl/README.md index bed32be..1729ca7 100644 --- a/samples/curl/README.md +++ b/samples/curl/README.md @@ -2,9 +2,10 @@ This folder contains samples for interacting with GitHub Models using cURL. -- [basic.sh](basic.sh): Provide a simple prompt to gpt-4o and display the chat response. -- [multi_turn.sh](multi_turn.sh): Provide a conversation history to gpt-4o, and display the response to the most recent chat prompt. -- [streaming.sh](streaming.sh): Respond to a simple prompt to gpt-4o and provide the response one token at a time. +- [basic.sh](basic.sh): Provide a simple prompt to gpt-4o-mini and display the chat response. +- [multi_turn.sh](multi_turn.sh): Provide a conversation history to gpt-4o-mini, and display the response to the most recent chat prompt. +- [streaming.sh](streaming.sh): Respond to a simple prompt to gpt-4o-mini and provide the response one token at a time. +- [image_sample.sh](image_sample.sh): Have gpt-4o-mini respond to a prompt that includes image data. ## Running a sample diff --git a/samples/curl/basic.sh b/samples/curl/basic.sh index 27a3021..e95d9f3 100755 --- a/samples/curl/basic.sh +++ b/samples/curl/basic.sh @@ -1,3 +1,4 @@ +#!/bin/bash curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ @@ -12,5 +13,5 @@ curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ "content": "What is the capital of France?" } ], - "model": "gpt-4o" + "model": "gpt-4o-mini" }' diff --git a/samples/curl/image_sample.sh b/samples/curl/image_sample.sh new file mode 100755 index 0000000..1d08725 --- /dev/null +++ b/samples/curl/image_sample.sh @@ -0,0 +1,24 @@ +#!/bin/bash +SCRIPT_DIR=$(dirname $0) +PAYLOAD_FILE="payload.json" +IMAGE_DATA="`cat \"${SCRIPT_DIR}/sample.png\" | base64`" +echo '{ + "messages": [ + { + "role": "system", + "content": "You are a helpful assistant that describes images in details." + }, + { + "role": "user", + "content": [{"text": "What''s in this image?", "type": "text"}, {"image_url": {"url":"data:image/png;base64,'"${IMAGE_DATA}"'","detail":"low"}, "type": "image_url"}] + } + ], + "model": "gpt-4o-mini" + }' > "$PAYLOAD_FILE" + +curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ + -d @payload.json +echo +rm -f "$PAYLOAD_FILE" \ No newline at end of file diff --git a/samples/curl/multi_turn.sh b/samples/curl/multi_turn.sh index 18400fc..a12aba6 100755 --- a/samples/curl/multi_turn.sh +++ b/samples/curl/multi_turn.sh @@ -1,3 +1,4 @@ +#!/bin/bash curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ @@ -20,5 +21,5 @@ curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ "content": "What about Spain?" } ], - "model": "gpt-4o" + "model": "gpt-4o-mini" }' diff --git a/samples/curl/sample.png b/samples/curl/sample.png new file mode 100644 index 0000000..e686630 Binary files /dev/null and b/samples/curl/sample.png differ diff --git a/samples/curl/streaming.sh b/samples/curl/streaming.sh index 92d9153..826324c 100755 --- a/samples/curl/streaming.sh +++ b/samples/curl/streaming.sh @@ -1,3 +1,4 @@ +#!/bin/bash curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ @@ -13,5 +14,5 @@ curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ } ], "stream": true, - "model": "gpt-4o" + "model": "gpt-4o-mini" }' diff --git a/samples/js/azure_ai_inference/README.md b/samples/js/azure_ai_inference/README.md index 9fac0b5..33c4639 100644 --- a/samples/js/azure_ai_inference/README.md +++ b/samples/js/azure_ai_inference/README.md @@ -20,6 +20,6 @@ To run a JavaScript sample, run a command like the following in your terminal: node samples/js/azure_ai_inference/multi_turn.js ``` -* [basic.js](basic.js): basic call to the gpt-4o chat completion API +* [basic.js](basic.js): basic call to the gpt-4o-mini chat completion API * [multi_turn.js](multi_turn.js): multi-turn conversation with the chat completion API * [streaming.js](streaming.js): generate a response in streaming mode, token by token \ No newline at end of file diff --git a/samples/js/azure_ai_inference/basic.js b/samples/js/azure_ai_inference/basic.js index b9d3980..3c7334e 100644 --- a/samples/js/azure_ai_inference/basic.js +++ b/samples/js/azure_ai_inference/basic.js @@ -12,9 +12,9 @@ const endpoint = "https://models.inference.ai.azure.com"; Cohere: Cohere-command-r, Cohere-command-r-plus Meta: Meta-Llama-3-70B-Instruct, Meta-Llama-3-8B-Instruct, Meta-Llama-3.1-405B-Instruct, Meta-Llama-3.1-70B-Instruct, Meta-Llama-3.1-8B-Instruct Mistral AI: Mistral-large, Mistral-large-2407, Mistral-Nemo, Mistral-small - Azure OpenAI: gpt-4o, gpt-4o-mini + Azure OpenAI: gpt-4o-mini, gpt-4o Microsoft: Phi-3-medium-128k-instruct, Phi-3-medium-4k-instruct, Phi-3-mini-128k-instruct, Phi-3-mini-4k-instruct, Phi-3-small-128k-instruct, Phi-3-small-8k-instruct */ -const modelName = "gpt-4o"; +const modelName = "gpt-4o-mini"; export async function main() { diff --git a/samples/js/azure_ai_inference/chat_with_image_file.js b/samples/js/azure_ai_inference/chat_with_image_file.js index 701a198..435cf67 100644 --- a/samples/js/azure_ai_inference/chat_with_image_file.js +++ b/samples/js/azure_ai_inference/chat_with_image_file.js @@ -1,6 +1,7 @@ import ModelClient from "@azure-rest/ai-inference"; import { AzureKeyCredential } from "@azure/core-auth"; import fs from 'fs'; +import path from 'path'; const token = process.env["GITHUB_TOKEN"]; const endpoint = "https://models.inference.ai.azure.com"; @@ -10,8 +11,8 @@ const endpoint = "https://models.inference.ai.azure.com"; you need to use a model that supports image inputs. The following image models are available in the GitHub Models service: - Azure OpenAI: gpt-4o, gpt-4o-mini */ -const modelName = "gpt-4o"; + Azure OpenAI: gpt-4o-mini, gpt-4o */ +const modelName = "gpt-4o-mini"; export async function main() { @@ -24,7 +25,7 @@ export async function main() { { role: "user", content: [ { type: "text", text: "What's in this image?"}, { type: "image_url", image_url: { - url: getImageDataUrl("/workspaces/codespaces-models/samples/js/azure_ai_inference/sample.png", "png"), details: "low"}} + url: getImageDataUrl(path.join(import.meta.dirname, "sample.png"), "png"), details: "low"}} ] } ], diff --git a/samples/js/azure_ai_inference/multi_turn.js b/samples/js/azure_ai_inference/multi_turn.js index 63379a7..0546add 100644 --- a/samples/js/azure_ai_inference/multi_turn.js +++ b/samples/js/azure_ai_inference/multi_turn.js @@ -12,9 +12,9 @@ const endpoint = "https://models.inference.ai.azure.com"; Cohere: Cohere-command-r, Cohere-command-r-plus Meta: Meta-Llama-3-70B-Instruct, Meta-Llama-3-8B-Instruct, Meta-Llama-3.1-405B-Instruct, Meta-Llama-3.1-70B-Instruct, Meta-Llama-3.1-8B-Instruct Mistral AI: Mistral-large, Mistral-large-2407, Mistral-Nemo, Mistral-small - Azure OpenAI: gpt-4o, gpt-4o-mini + Azure OpenAI: gpt-4o-mini, gpt-4o Microsoft: Phi-3-medium-128k-instruct, Phi-3-medium-4k-instruct, Phi-3-mini-128k-instruct, Phi-3-mini-4k-instruct, Phi-3-small-128k-instruct, Phi-3-small-8k-instruct */ -const modelName = "gpt-4o"; +const modelName = "gpt-4o-mini"; export async function main() { diff --git a/samples/js/azure_ai_inference/streaming.js b/samples/js/azure_ai_inference/streaming.js index d2d3118..e8d0bf1 100644 --- a/samples/js/azure_ai_inference/streaming.js +++ b/samples/js/azure_ai_inference/streaming.js @@ -13,9 +13,9 @@ const endpoint = "https://models.inference.ai.azure.com"; Cohere: Cohere-command-r, Cohere-command-r-plus Meta: Meta-Llama-3-70B-Instruct, Meta-Llama-3-8B-Instruct, Meta-Llama-3.1-405B-Instruct, Meta-Llama-3.1-70B-Instruct, Meta-Llama-3.1-8B-Instruct Mistral AI: Mistral-large, Mistral-large-2407, Mistral-Nemo, Mistral-small - Azure OpenAI: gpt-4o, gpt-4o-mini + Azure OpenAI: gpt-4o-mini, gpt-4o Microsoft: Phi-3-medium-128k-instruct, Phi-3-medium-4k-instruct, Phi-3-mini-128k-instruct, Phi-3-mini-4k-instruct, Phi-3-small-128k-instruct, Phi-3-small-8k-instruct */ -const modelName = "gpt-4o"; +const modelName = "gpt-4o-mini"; export async function main() { diff --git a/samples/js/azure_ai_inference/tools.js b/samples/js/azure_ai_inference/tools.js index 329b60f..1bfb198 100644 --- a/samples/js/azure_ai_inference/tools.js +++ b/samples/js/azure_ai_inference/tools.js @@ -11,8 +11,8 @@ const endpoint = "https://models.inference.ai.azure.com"; Cohere: Cohere-command-r, Cohere-command-r-plus Mistral AI: Mistral-large, Mistral-large-2407, Mistral-Nemo, Mistral-small - Azure OpenAI: gpt-4o, gpt-4o-mini */ -const modelName = "gpt-4o"; + Azure OpenAI: gpt-4o-mini, gpt-4o */ +const modelName = "gpt-4o-mini"; function getFlightInfo({originCity, destinationCity}){ if (originCity === "Seattle" && destinationCity === "Miami"){ diff --git a/samples/js/mistralai/README.md b/samples/js/mistralai/README.md index 8091195..c33f716 100644 --- a/samples/js/mistralai/README.md +++ b/samples/js/mistralai/README.md @@ -15,6 +15,6 @@ To run a JavaScript sample, run a command like the following in your terminal: node samples/js/mistralai/multi_turn.js ``` -* [basic.js](basic.js): basic call to the gpt-4o chat completion API +* [basic.js](basic.js): basic call to the gpt-4o-mini chat completion API * [multi_turn.js](multi_turn.js): multi-turn conversation with the chat completion API * [streaming.js](streaming.js): generate a response in streaming mode, token by token \ No newline at end of file diff --git a/samples/js/openai/README.md b/samples/js/openai/README.md index fd5d802..26c898c 100644 --- a/samples/js/openai/README.md +++ b/samples/js/openai/README.md @@ -16,6 +16,6 @@ To run a JavaScript sample, run a command like the following in your terminal: node samples/js/openai/multi_turn.js ``` -* [basic.js](basic.js): basic call to the gpt-4o chat completion API +* [basic.js](basic.js): basic call to the gpt-4o-mini chat completion API * [multi_turn.js](multi_turn.js): multi-turn conversation with the chat completion API * [streaming.js](streaming.js): generate a response in streaming mode, token by token \ No newline at end of file diff --git a/samples/js/openai/basic.js b/samples/js/openai/basic.js index a0941c2..9f35965 100644 --- a/samples/js/openai/basic.js +++ b/samples/js/openai/basic.js @@ -4,7 +4,7 @@ const token = process.env["GITHUB_TOKEN"]; const endpoint = "https://models.inference.ai.azure.com"; /* Pick one of the Azure OpenAI models from the GitHub Models service */ -const modelName = "gpt-4o"; +const modelName = "gpt-4o-mini"; export async function main() { diff --git a/samples/js/openai/chat_with_image_file.js b/samples/js/openai/chat_with_image_file.js index 515646f..3ee863c 100644 --- a/samples/js/openai/chat_with_image_file.js +++ b/samples/js/openai/chat_with_image_file.js @@ -1,11 +1,12 @@ import fs from 'fs'; +import path from 'path'; import OpenAI from "openai"; const token = process.env["GITHUB_TOKEN"]; const endpoint = "https://models.inference.ai.azure.com"; /* Pick one of the Azure OpenAI models from the GitHub Models service */ -const modelName = "gpt-4o"; +const modelName = "gpt-4o-mini"; export async function main() { @@ -17,7 +18,7 @@ export async function main() { { role: "user", content: [ { type: "text", text: "What's in this image?"}, { type: "image_url", image_url: { - url: getImageDataUrl("/workspaces/codespaces-models/samples/js/azure_ai_inference/sample.png", "png"), details: "low"}} + url: getImageDataUrl(path.join(import.meta.dirname, "sample.png"), "png"), details: "low"}} ] } ], diff --git a/samples/js/openai/multi_turn.js b/samples/js/openai/multi_turn.js index 35a68d0..3128281 100644 --- a/samples/js/openai/multi_turn.js +++ b/samples/js/openai/multi_turn.js @@ -4,7 +4,7 @@ const token = process.env["GITHUB_TOKEN"]; const endpoint = "https://models.inference.ai.azure.com"; /* Pick one of the Azure OpenAI models from the GitHub Models service */ -const modelName = "gpt-4o"; +const modelName = "gpt-4o-mini"; export async function main() { diff --git a/samples/js/openai/streaming.js b/samples/js/openai/streaming.js index ebb0da2..98597fb 100644 --- a/samples/js/openai/streaming.js +++ b/samples/js/openai/streaming.js @@ -4,7 +4,7 @@ const token = process.env["GITHUB_TOKEN"]; const endpoint = "https://models.inference.ai.azure.com"; /* Pick one of the Azure OpenAI models from the GitHub Models service */ -const modelName = "gpt-4o"; +const modelName = "gpt-4o-mini"; export async function main() { diff --git a/samples/js/openai/tools.js b/samples/js/openai/tools.js index ace2793..21fe0a8 100644 --- a/samples/js/openai/tools.js +++ b/samples/js/openai/tools.js @@ -4,7 +4,7 @@ const token = process.env["GITHUB_TOKEN"]; const endpoint = "https://models.inference.ai.azure.com"; /* Pick one of the Azure OpenAI models from the GitHub Models service */ -const modelName = "gpt-4o"; +const modelName = "gpt-4o-mini"; function getFlightInfo({originCity, destinationCity}){ if (originCity === "Seattle" && destinationCity === "Miami"){ diff --git a/samples/python/azure_ai_inference/README.md b/samples/python/azure_ai_inference/README.md index 192533d..1c3059c 100644 --- a/samples/python/azure_ai_inference/README.md +++ b/samples/python/azure_ai_inference/README.md @@ -16,6 +16,6 @@ To run these scripts, open your terminal and run a command like: python3 samples/python/azure_ai_inference/basic.py ``` -* [basic.py](basic.py): basic call to the gpt-4o chat completion API +* [basic.py](basic.py): basic call to the gpt-4o-mini chat completion API * [multi_turn.py](multi_turn.py): multi-turn conversation with the chat completion API * [streaming.py](streaming.py): generate a response in streaming mode, token by token diff --git a/samples/python/azure_ai_inference/basic.py b/samples/python/azure_ai_inference/basic.py index 407204e..2109b0e 100644 --- a/samples/python/azure_ai_inference/basic.py +++ b/samples/python/azure_ai_inference/basic.py @@ -17,9 +17,9 @@ # Cohere: Cohere-command-r, Cohere-command-r-plus # Meta: Meta-Llama-3-70B-Instruct, Meta-Llama-3-8B-Instruct, Meta-Llama-3.1-405B-Instruct, Meta-Llama-3.1-70B-Instruct, Meta-Llama-3.1-8B-Instruct # Mistral AI: Mistral-large, Mistral-large-2407, Mistral-Nemo, Mistral-small -# Azure OpenAI: gpt-4o, gpt-4o-mini +# Azure OpenAI: gpt-4o-mini, gpt-4o # Microsoft: Phi-3-medium-128k-instruct, Phi-3-medium-4k-instruct, Phi-3-mini-128k-instruct, Phi-3-mini-4k-instruct, Phi-3-small-128k-instruct, Phi-3-small-8k-instruct -model_name = "gpt-4o" +model_name = "gpt-4o-mini" client = ChatCompletionsClient( endpoint=endpoint, @@ -28,14 +28,8 @@ response = client.complete( messages=[ - { - "role": "system", - "content": "You are a helpful assistant.", - }, - { - "role": "user", - "content": "What is the capital of France?", - }, + SystemMessage(content="You are a helpful assistant."), + UserMessage(content="What is the capital of France?"), ], model=model_name, # Optional parameters diff --git a/samples/python/azure_ai_inference/chat_with_image_file.py b/samples/python/azure_ai_inference/chat_with_image_file.py index 1604731..90fd40b 100644 --- a/samples/python/azure_ai_inference/chat_with_image_file.py +++ b/samples/python/azure_ai_inference/chat_with_image_file.py @@ -21,8 +21,8 @@ # you need to use a model that supports image inputs. The following image models are # available in the GitHub Models service: # -# Azure OpenAI: gpt-4o, gpt-4o-mini -model_name = "gpt-4o" +# Azure OpenAI: gpt-4o-mini, gpt-4o +model_name = "gpt-4o-mini" client = ChatCompletionsClient( endpoint=endpoint, @@ -39,7 +39,7 @@ TextContentItem(text="What's in this image?"), ImageContentItem( image_url=ImageUrl.load( - image_file="/workspaces/codespaces-models/samples/python/azure_ai_inference/sample.png", + image_file=os.path.join(os.path.dirname(__file__), "sample.png"), image_format="png", detail=ImageDetailLevel.LOW) ), diff --git a/samples/python/azure_ai_inference/getting_started.ipynb b/samples/python/azure_ai_inference/getting_started.ipynb index 21eb23d..3469ff0 100644 --- a/samples/python/azure_ai_inference/getting_started.ipynb +++ b/samples/python/azure_ai_inference/getting_started.ipynb @@ -77,7 +77,7 @@ "- Cohere: `Cohere-command-r`, `Cohere-command-r-plus`\n", "- Meta: `Meta-Llama-3-70B-Instruct`, `Meta-Llama-3-8B-Instruct`, `Meta-Llama-3.1-405B-Instruct`, `Meta-Llama-3.1-70B-Instruct`, `Meta-Llama-3.1-8B-Instruct`\n", "- Mistral AI: `Mistral-large`, `Mistral-large-2407`, `Mistral-Nemo`, `Mistral-small`\n", - "- Azure OpenAI: `gpt-4o`, `gpt-4o-mini`\n", + "- Azure OpenAI: `gpt-4o-mini`, `gpt-4o`\n", "- Microsoft: `Phi-3-medium-128k-instruct`, `Phi-3-medium-4k-instruct`, `Phi-3-mini-128k-instruct`, `Phi-3-mini-4k-instruct`, `Phi-3-small-128k-instruct`, `Phi-3-small-8k-instruct`" ] }, @@ -88,7 +88,7 @@ "outputs": [], "source": [ "# pick one of them\n", - "model_name = \"gpt-4o\"" + "model_name = \"gpt-4o-mini\"" ] }, { @@ -110,14 +110,8 @@ "source": [ "response = client.complete(\n", " messages=[\n", - " {\n", - " \"role\": \"system\",\n", - " \"content\": \"You are a helpful assistant.\",\n", - " },\n", - " {\n", - " \"role\": \"user\",\n", - " \"content\": \"What is the capital of France?\",\n", - " },\n", + " SystemMessage(content=\"You are a helpful assistant.\"),\n", + " UserMessage(content=\"What is the capital of France?\"),\n", " ],\n", " model=model_name,\n", " # Optional parameters\n", @@ -169,7 +163,7 @@ "\n", "Some models of the GitHub Models service support image inputs. The following image models are available in the GitHub Models service:\n", " \n", - "- Azure OpenAI: `gpt-4o`, `gpt-4o-mini`" + "- Azure OpenAI: `gpt-4o-mini`, `gpt-4o`" ] }, { @@ -179,7 +173,7 @@ "outputs": [], "source": [ "# Select a model\n", - "model_name = \"gpt-4o\"" + "model_name = \"gpt-4o-mini\"" ] }, { @@ -278,7 +272,7 @@ "The following compatible models are available in the GitHub Models service:\n", "- Cohere: `Cohere-command-r`, `Cohere-command-r-plus`\n", "- Mistral AI: `Mistral-large`, `Mistral-large-2407`, `Mistral-Nemo`, `Mistral-small`\n", - "- Azure OpenAI: `gpt-4o`, `gpt-4o-mini`" + "- Azure OpenAI: `gpt-4o-mini`, `gpt-4o`" ] }, { @@ -288,7 +282,7 @@ "outputs": [], "source": [ "# pick one of them\n", - "model_name = \"gpt-4o\"" + "model_name = \"gpt-4o-mini\"" ] }, { @@ -340,14 +334,10 @@ "\n", "\n", "messages = [\n", - " {\n", - " \"role\": \"system\",\n", - " \"content\": \"You an assistant that helps users find flight information.\",\n", - " },\n", - " {\n", - " \"role\": \"user\",\n", - " \"content\": \"I'm interested in going to Miami. What is the next flight there from Seattle?\",\n", - " },\n", + " SystemMessage(content=\"You an assistant that helps users find flight information.\"),\n", + " UserMessage(\n", + " content=\"I'm interested in going to Miami. What is the next flight there from Seattle?\"\n", + " ),\n", "]\n", "\n", "response = client.complete(\n", @@ -430,7 +420,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/samples/python/azure_ai_inference/multi_turn.py b/samples/python/azure_ai_inference/multi_turn.py index 09e6969..41a16be 100644 --- a/samples/python/azure_ai_inference/multi_turn.py +++ b/samples/python/azure_ai_inference/multi_turn.py @@ -19,9 +19,9 @@ # Cohere: Cohere-command-r, Cohere-command-r-plus # Meta: Meta-Llama-3-70B-Instruct, Meta-Llama-3-8B-Instruct, Meta-Llama-3.1-405B-Instruct, Meta-Llama-3.1-70B-Instruct, Meta-Llama-3.1-8B-Instruct # Mistral AI: Mistral-large, Mistral-large-2407, Mistral-Nemo, Mistral-small -# Azure OpenAI: gpt-4o, gpt-4o-mini +# Azure OpenAI: gpt-4o-mini, gpt-4o # Microsoft: Phi-3-medium-128k-instruct, Phi-3-medium-4k-instruct, Phi-3-mini-128k-instruct, Phi-3-mini-4k-instruct, Phi-3-small-128k-instruct, Phi-3-small-8k-instruct -model_name = "gpt-4o" +model_name = "gpt-4o-mini" client = ChatCompletionsClient( endpoint=endpoint, diff --git a/samples/python/azure_ai_inference/streaming.py b/samples/python/azure_ai_inference/streaming.py index 3a3f17f..0cc172b 100644 --- a/samples/python/azure_ai_inference/streaming.py +++ b/samples/python/azure_ai_inference/streaming.py @@ -17,9 +17,9 @@ # Cohere: Cohere-command-r, Cohere-command-r-plus # Meta: Meta-Llama-3-70B-Instruct, Meta-Llama-3-8B-Instruct, Meta-Llama-3.1-405B-Instruct, Meta-Llama-3.1-70B-Instruct, Meta-Llama-3.1-8B-Instruct # Mistral AI: Mistral-large, Mistral-large-2407, Mistral-Nemo, Mistral-small -# Azure OpenAI: gpt-4o, gpt-4o-mini +# Azure OpenAI: gpt-4o-mini, gpt-4o # Microsoft: Phi-3-medium-128k-instruct, Phi-3-medium-4k-instruct, Phi-3-mini-128k-instruct, Phi-3-mini-4k-instruct, Phi-3-small-128k-instruct, Phi-3-small-8k-instruct -model_name = "gpt-4o" +model_name = "gpt-4o-mini" client = ChatCompletionsClient( endpoint=endpoint, diff --git a/samples/python/azure_ai_inference/tools.py b/samples/python/azure_ai_inference/tools.py index 1d5fc61..c71566f 100644 --- a/samples/python/azure_ai_inference/tools.py +++ b/samples/python/azure_ai_inference/tools.py @@ -29,8 +29,8 @@ # # Cohere: Cohere-command-r, Cohere-command-r-plus # Mistral AI: Mistral-large, Mistral-large-2407, Mistral-Nemo, Mistral-small -# Azure OpenAI: gpt-4o, gpt-4o-mini -model_name = "gpt-4o" +# Azure OpenAI: gpt-4o-mini, gpt-4o +model_name = "gpt-4o-mini" client = ChatCompletionsClient( endpoint=endpoint, diff --git a/samples/python/mistralai/README.md b/samples/python/mistralai/README.md index e02502c..cd2c751 100644 --- a/samples/python/mistralai/README.md +++ b/samples/python/mistralai/README.md @@ -16,6 +16,6 @@ To run these scripts, open your terminal and run a command like: python3 samples/python/mistralai/basic.py ``` -* [basic.py](basic.py): basic call to the gpt-4o chat completion API +* [basic.py](basic.py): basic call to the Mistral-small chat completion API * [multi_turn.py](multi_turn.py): multi-turn conversation with the chat completion API * [streaming.py](streaming.py): generate a response in streaming mode, token by token diff --git a/samples/python/mistralai/getting_started.ipynb b/samples/python/mistralai/getting_started.ipynb index 099c8a8..021c6ce 100644 --- a/samples/python/mistralai/getting_started.ipynb +++ b/samples/python/mistralai/getting_started.ipynb @@ -347,7 +347,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/samples/python/openai/README.md b/samples/python/openai/README.md index 37dd82c..42d18c8 100644 --- a/samples/python/openai/README.md +++ b/samples/python/openai/README.md @@ -17,7 +17,7 @@ To run these scripts, open your terminal and run a command like: python3 samples/python/openai/basic.py ``` -* [basic.py](basic.py): basic call to the gpt-4o chat completion API +* [basic.py](basic.py): basic call to the gpt-4o-mini chat completion API * [chat_with_image_file.py](chat_with_image_file.py): image file as input * [multi_turn.py](multi_turn.py): multi-turn conversation with the chat completion API * [streaming.py](streaming.py): generate a response in streaming mode, token by token diff --git a/samples/python/openai/basic.py b/samples/python/openai/basic.py index 2d2b14f..916b52f 100644 --- a/samples/python/openai/basic.py +++ b/samples/python/openai/basic.py @@ -8,7 +8,7 @@ endpoint = "https://models.inference.ai.azure.com" # Pick one of the Azure OpenAI models from the GitHub Models service -model_name = "gpt-4o" +model_name = "gpt-4o-mini" client = OpenAI( base_url=endpoint, diff --git a/samples/python/openai/chat_with_image_file.py b/samples/python/openai/chat_with_image_file.py index a87a93e..5e676b5 100644 --- a/samples/python/openai/chat_with_image_file.py +++ b/samples/python/openai/chat_with_image_file.py @@ -9,7 +9,7 @@ endpoint = "https://models.inference.ai.azure.com" # Pick one of the Azure OpenAI models from the GitHub Models service -model_name = "gpt-4o" +model_name = "gpt-4o-mini" # Create a client client = OpenAI( diff --git a/samples/python/openai/embeddings_getting_started.ipynb b/samples/python/openai/embeddings_getting_started.ipynb index 044a511..f68e095 100644 --- a/samples/python/openai/embeddings_getting_started.ipynb +++ b/samples/python/openai/embeddings_getting_started.ipynb @@ -146,7 +146,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/samples/python/openai/getting_started.ipynb b/samples/python/openai/getting_started.ipynb index d349d26..337c2b8 100644 --- a/samples/python/openai/getting_started.ipynb +++ b/samples/python/openai/getting_started.ipynb @@ -58,7 +58,7 @@ "os.environ[\"OPENAI_BASE_URL\"] = \"https://models.inference.ai.azure.com/\"\n", "\n", "\n", - "model_name = \"gpt-4o\" # or \"gpt-4o-mini\"\n", + "model_name = \"gpt-4o-mini\" # or \"gpt-4o\"\n", "client = OpenAI()" ] }, @@ -152,7 +152,7 @@ "source": [ "## 6. Using images as inputs\n", "\n", - "The `gpt-4o` model supports using images as inputs. To run a chat completion using\n", + "The `gpt-4o-mini` model supports using images as inputs. To run a chat completion using\n", "a local image file, use the following sample. To send it to the service, you'll need to encode the image as **data URI**, which is a string that starts with `data:image/png;base64,` followed by the base64-encoded image.\n", "We are using this small image as an example: \n", "\n", @@ -167,7 +167,7 @@ "outputs": [], "source": [ "import base64\n", - "model_name = \"gpt-4o\"\n", + "model_name = \"gpt-4o-mini\"\n", "\n", "\n", "def get_image_data_url(image_file: str, image_format: str) -> str:\n", @@ -269,7 +269,7 @@ "source": [ "## 8. Tools and Function Calling\n", "\n", - "A language model like `gpt-4o` can be given a set of tools it can ask the calling program to invoke,\n", + "A language model like `gpt-4o-mini` can be given a set of tools it can ask the calling program to invoke,\n", "for running specific actions depending on the context of the conversation.\n", "This sample demonstrates how to define a function tool and how to act on a request from the model to invoke it.\n" ] @@ -418,7 +418,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.9" } }, "nbformat": 4, diff --git a/samples/python/openai/multi_turn.py b/samples/python/openai/multi_turn.py index 7947d71..8be60b8 100644 --- a/samples/python/openai/multi_turn.py +++ b/samples/python/openai/multi_turn.py @@ -10,7 +10,7 @@ endpoint = "https://models.inference.ai.azure.com" # Pick one of the Azure OpenAI models from the GitHub Models service -model_name = "gpt-4o" +model_name = "gpt-4o-mini" # Create a client client = OpenAI( diff --git a/samples/python/openai/streaming.py b/samples/python/openai/streaming.py index 8794978..d8663d8 100644 --- a/samples/python/openai/streaming.py +++ b/samples/python/openai/streaming.py @@ -8,7 +8,7 @@ endpoint = "https://models.inference.ai.azure.com" # Pick one of the Azure OpenAI models from the GitHub Models service -model_name = "gpt-4o" +model_name = "gpt-4o-mini" # Create a client client = OpenAI( diff --git a/samples/python/openai/tools.py b/samples/python/openai/tools.py index 4c9c147..0a70a76 100644 --- a/samples/python/openai/tools.py +++ b/samples/python/openai/tools.py @@ -10,7 +10,7 @@ endpoint = "https://models.inference.ai.azure.com" # Pick one of the Azure OpenAI models from the GitHub Models service -model_name = "gpt-4o" +model_name = "gpt-4o-mini" # Create a client client = OpenAI(