GitHub Model Catalog - Getting Started (2024)

GitHub Models - Limited Public Beta SIGNUP TODAY

Welcome toGitHub Models! We've got everything fired up and ready for you to explore AI Models hosted on Azure AI. So as Student developer you already have access to amazing GitHub Resources like Codespaces and Copilot from http://education.github.comnow you get started on developing with Generative AI and Language Models with the Model Catalog.


Access and onboarding

GitHub Models provide free access to a set of AI models for anyone with a GitHub account.
This makes it significantly easier to get familiar with AI models without having to create Azure Resources or download models from Hugging Face.

The GitHub Model; is your opportunity to test out these models for free.

Key features of GitHub Models
Seamless integration with Codespaces allows for quick learning and engagement.

  • The ease of local use, for free, in code they may have already written.
  • The ability to switch between model providers using the same API call via the Azure AI inference API, eliminating the need to change code between providers.

GitHub Model Catalog - Getting Started (1)

For more information about the Models available on GitHub Models, check out theGitHub Model Marketplace


Models Available

Each model has a dedicated playground and sample code available in a dedicated codespaces environment and utilizes the Azure Inference APIso swapping models is simply changing the model name.

GitHub Model Catalog - Getting Started (2)


Getting Started

There are a few basic examples that are ready for you to run. You can find them in the samples directory within the codespaces environment.

If you want to jump straight to your favorite language, you can find the examples in the following Languages:

  • Python
  • JavaScript
  • cURL

The dedicated Codespaces Environment is an excellent way to get started running the samples and models.

GitHub Model Catalog - Getting Started (3)


Sample Code

Below are example code snippets for a few use cases. For additional information about Azure AI Inference SDK, see full documentation and samples.

Setup

  1. Create a personal access token You do not need to give any permissions to the token. Note that the token will be sent to a Microsoft service.

To use the code snippets below, create an environment variable to set your token as the key for the client code.


If you're using bash:

export GITHUB_TOKEN="<your-github-token-goes-here>"

If you're in powershell:

$Env:GITHUB_TOKEN="<your-github-token-goes-here>"

If you're using Windows command prompt:

set GITHUB_TOKEN=<your-github-token-goes-here>

Python Sample

Install dependencies

Install the Azure AI Inference SDK using pip (Requires: Python >=3.8):

pip install azure-ai-inference

Run a basic code sample

This sample demonstrates a basic call to the chat completion API. It is leveraging the GitHub AI model inference endpoint and your GitHub token. The call is synchronous.

import osfrom azure.ai.inference import ChatCompletionsClientfrom azure.ai.inference.models import SystemMessage, UserMessagefrom azure.core.credentials import AzureKeyCredentialendpoint = "https://models.inference.ai.azure.com"# Replace Model_Name model_name = "Phi-3-small-8k-instruct"token = os.environ["GITHUB_TOKEN"]client = ChatCompletionsClient( endpoint=endpoint, credential=AzureKeyCredential(token),)response = client.complete( messages=[ SystemMessage(content="You are a helpful assistant."), UserMessage(content="What is the capital of France?"), ], model=model_name, temperature=1., max_tokens=1000, top_p=1.)print(response.choices[0].message.content)

Run a multi-turn conversation

This sample demonstrates a multi-turn conversation with the chat completion API. When using the model for a chat application, you'll need to manage the history of that conversation and send the latest messages to the model.

import osfrom azure.ai.inference import ChatCompletionsClientfrom azure.ai.inference.models import AssistantMessage, SystemMessage, UserMessagefrom azure.core.credentials import AzureKeyCredentialtoken = os.environ["GITHUB_TOKEN"]endpoint = "https://models.inference.ai.azure.com"# Replace Model_Namemodel_name = "Phi-3-small-8k-instruct"client = ChatCompletionsClient( endpoint=endpoint, credential=AzureKeyCredential(token),)messages = [ SystemMessage(content="You are a helpful assistant."), UserMessage(content="What is the capital of France?"), AssistantMessage(content="The capital of France is Paris."), UserMessage(content="What about Spain?"),]response = client.complete(messages=messages, model=model_name)print(response.choices[0].message.content)

Stream the output

For a better user experience, you will want to stream the response of the model so that the first token shows up early and you avoid waiting for long responses.

import osfrom azure.ai.inference import ChatCompletionsClientfrom azure.ai.inference.models import SystemMessage, UserMessagefrom azure.core.credentials import AzureKeyCredentialtoken = os.environ["GITHUB_TOKEN"]endpoint = "https://models.inference.ai.azure.com"# Replace Model_Namemodel_name = "Phi-3-small-8k-instruct"client = ChatCompletionsClient( endpoint=endpoint, credential=AzureKeyCredential(token),)response = client.complete( stream=True, messages=[ SystemMessage(content="You are a helpful assistant."), UserMessage(content="Give me 5 good reasons why I should exercise every day."), ], model=model_name,)for update in response: if update.choices: print(update.choices[0].delta.content or "", end="")client.close()

JavaScript

Install dependencies

Install Node.js.

Copy the following lines of text and save them as a file package.json inside your folder.

{ "type": "module", "dependencies": { "@azure-rest/ai-inference": "latest", "@azure/core-auth": "latest", "@azure/core-sse": "latest" }}

Note: @azure/core-sse is only needed when you stream the chat completions response.


Open a terminal window in this folder and run npm install.


For each of the code snippets below, copy the content into a file sample.js and run with node sample.js.

Run a basic code sample

This sample demonstrates a basic call to the chat completion API. It is leveraging the GitHub AI model inference endpoint and your GitHub token. The call is synchronous.

import ModelClient from "@azure-rest/ai-inference";import { AzureKeyCredential } from "@azure/core-auth";const token = process.env["GITHUB_TOKEN"];const endpoint = "https://models.inference.ai.azure.com";// Update your modelnameconst modelName = "Phi-3-small-8k-instruct";export async function main() { const client = new ModelClient(endpoint, new AzureKeyCredential(token)); const response = await client.path("/chat/completions").post({ body: { messages: [ { role:"system", content: "You are a helpful assistant." }, { role:"user", content: "What is the capital of France?" } ], model: modelName, temperature: 1., max_tokens: 1000, top_p: 1. } }); if (response.status !== "200") { throw response.body.error; } console.log(response.body.choices[0].message.content);}main().catch((err) => { console.error("The sample encountered an error:", err);});

Run a multi-turn conversation

This sample demonstrates a multi-turn conversation with the chat completion API. When using the model for a chat application, you'll need to manage the history of that conversation and send the latest messages to the model.

import ModelClient from "@azure-rest/ai-inference";import { AzureKeyCredential } from "@azure/core-auth";const token = process.env["GITHUB_TOKEN"];const endpoint = "https://models.inference.ai.azure.com";// Update your modelnameconst modelName = "Phi-3-small-8k-instruct";export async function main() { const client = new ModelClient(endpoint, new AzureKeyCredential(token)); const response = await client.path("/chat/completions").post({ body: { messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "What is the capital of France?" }, { role: "assistant", content: "The capital of France is Paris." }, { role: "user", content: "What about Spain?" }, ], model: modelName, } }); if (response.status !== "200") { throw response.body.error; } for (const choice of response.body.choices) { console.log(choice.message.content); }}main().catch((err) => { console.error("The sample encountered an error:", err);});

Stream the output

For a better user experience, you will want to stream the response of the model so that the first token shows up early and you avoid waiting for long responses.

import ModelClient from "@azure-rest/ai-inference";import { AzureKeyCredential } from "@azure/core-auth";import { createSseStream } from "@azure/core-sse";const token = process.env["GITHUB_TOKEN"];const endpoint = "https://models.inference.ai.azure.com";// Update your modelnameconst modelName = "Phi-3-small-8k-instruct";export async function main() { const client = new ModelClient(endpoint, new AzureKeyCredential(token)); const response = await client.path("/chat/completions").post({ body: { messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: "Give me 5 good reasons why I should exercise every day." }, ], model: modelName, stream: true } }).asNodeStream(); const stream = response.body; if (!stream) { throw new Error("The response stream is undefined"); } if (response.status !== "200") { stream.destroy(); throw new Error(`Failed to get chat completions, http operation failed with ${response.status} code`); } const sseStream = createSseStream(stream); for await (const event of sseStream) { if (event.data === "[DONE]") { return; } for (const choice of (JSON.parse(event.data)).choices) { process.stdout.write(choice.delta?.content ?? ``); } }}main().catch((err) => { console.error("The sample encountered an error:", err);});

REST

Run a basic code sample

Paste the following into a shell:

curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the capital of France?" } ], "model": "Phi-3-small-8k-instruct" }'

Run a multi-turn conversation

Call the chat completion API and pass the chat history:

curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "What is the capital of France?" }, { "role": "assistant", "content": "The capital of France is Paris." }, { "role": "user", "content": "What about Spain?" } ], "model": "Phi-3-small-8k-instruct" }'

Stream the output

This is an example of calling the endpoint and streaming the response.

curl -X POST "https://models.inference.ai.azure.com/chat/completions" \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $GITHUB_TOKEN" \ -d '{ "messages": [ { "role": "system", "content": "You are a helpful assistant." }, { "role": "user", "content": "Give me 5 good reasons why I should exercise every day." } ], "stream": true, "model": "Phi-3-small-8k-instruct" }'

FREE Usage and Rate limits for GitHub Models

Therate limits for the playground and free API usageare intended to help you experiment with models and prototype your AI application. For use beyond those limits, and to bring your application to scale, you must provision resources from an Azure account, and authenticate from there instead of your GitHub personal access token. You don't need to change anything else in your code. Use this link to discover how to go beyond the free tier limits in Azure AI.

GitHub Model Catalog - Getting Started (2024)

References

Top Articles
Vainillatrap
Fwp Kalispell Mt
Funny Roblox Id Codes 2023
Golden Abyss - Chapter 5 - Lunar_Angel
Www.paystubportal.com/7-11 Login
Joi Databas
DPhil Research - List of thesis titles
Shs Games 1V1 Lol
Evil Dead Rise Showtimes Near Massena Movieplex
Steamy Afternoon With Handsome Fernando
Which aspects are important in sales |#1 Prospection
Detroit Lions 50 50
18443168434
Zürich Stadion Letzigrund detailed interactive seating plan with seat & row numbers | Sitzplan Saalplan with Sitzplatz & Reihen Nummerierung
Grace Caroline Deepfake
978-0137606801
Nwi Arrests Lake County
Justified Official Series Trailer
London Ups Store
Committees Of Correspondence | Encyclopedia.com
Pizza Hut In Dinuba
Jinx Chapter 24: Release Date, Spoilers & Where To Read - OtakuKart
How Much You Should Be Tipping For Beauty Services - American Beauty Institute
Free Online Games on CrazyGames | Play Now!
Sizewise Stat Login
VERHUURD: Barentszstraat 12 in 'S-Gravenhage 2518 XG: Woonhuis.
Jet Ski Rental Conneaut Lake Pa
Unforeseen Drama: The Tower of Terror’s Mysterious Closure at Walt Disney World
Ups Print Store Near Me
C&T Wok Menu - Morrisville, NC Restaurant
How Taraswrld Leaks Exposed the Dark Side of TikTok Fame
Dashboard Unt
10 Best Places to Go and Things to Know for a Trip to the Hickory M...
Black Lion Backpack And Glider Voucher
Gopher Carts Pensacola Beach
Duke University Transcript Request
Lincoln Financial Field, section 110, row 4, home of Philadelphia Eagles, Temple Owls, page 1
Jambus - Definition, Beispiele, Merkmale, Wirkung
Netherforged Lavaproof Boots
Ark Unlock All Skins Command
Craigslist Red Wing Mn
D3 Boards
Jail View Sumter
Nancy Pazelt Obituary
Birmingham City Schools Clever Login
Thotsbook Com
Vérificateur De Billet Loto-Québec
Funkin' on the Heights
Vci Classified Paducah
Www Pig11 Net
Ty Glass Sentenced
Latest Posts
Article information

Author: Reed Wilderman

Last Updated:

Views: 5674

Rating: 4.1 / 5 (72 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.