Skip to content

Commit 8166f91

Browse files
authored
Merge pull request #39612 from github/repo-sync
Repo sync
2 parents c4eb8ff + 97e4733 commit 8166f91

File tree

1 file changed

+62
-52
lines changed

1 file changed

+62
-52
lines changed

content/github-models/quickstart.md

Lines changed: 62 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -76,41 +76,34 @@ To call models programmatically, you’ll need:
7676

7777
1. Paste the following workflow into the file you just created.
7878

79-
```yaml
80-
name: GitHub Models Demo
79+
```yaml copy
80+
name: Use GitHub Models
8181
8282
on: [push]
8383
8484
permissions:
85-
contents: read
8685
models: read
8786
8887
jobs:
89-
summarize-repo:
88+
call-model:
9089
runs-on: ubuntu-latest
9190
steps:
92-
- name: Checkout code
93-
uses: {% data reusables.actions.action-checkout %}
94-
95-
- name: Summarize the repository README
91+
- name: Call AI model
92+
env:
93+
GITHUB_TOKEN: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
9694
run: |
97-
SUMMARY_INPUT=$(head -c 4000 README.md)
98-
PROMPT="Summarize this repository in one sentence. Here is the README:\n$SUMMARY_INPUT"
99-
PAYLOAD=$(jq -n --arg prompt "$PROMPT" '{
100-
model: "openai/gpt-4.1",
101-
messages: [
102-
{role: "user", content: $prompt}
103-
]
104-
}')
105-
RESPONSE=$(curl -sL \
106-
-X POST \
107-
-H "Accept: application/vnd.github+json" \
108-
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
109-
-H "X-GitHub-Api-Version: 2022-11-28" \
110-
-H "Content-Type: application/json" \
111-
https://models.github.ai/inference/chat/completions \
112-
-d "$PAYLOAD")
113-
echo "$RESPONSE" | jq -r '.choices[0].message.content'
95+
curl "https://models.github.ai/inference/chat/completions" \
96+
-H "Content-Type: application/json" \
97+
-H "Authorization: Bearer $GITHUB_TOKEN" \
98+
-d '{
99+
"messages": [
100+
{
101+
"role": "user",
102+
"content": "Explain the concept of recursion."
103+
}
104+
],
105+
"model": "openai/gpt-4o"
106+
}'
114107
```
115108

116109
> [!NOTE]
@@ -128,13 +121,21 @@ This example shows how to send a prompt to a model and use the response in your
128121

129122
1. Paste the following example prompt into the file you just created.
130123

131-
```yaml
132-
name: One-line summary
133-
description: Ask the model to summarize a paragraph in one sentence.
124+
```yaml copy
125+
name: Text Summarizer
126+
description: Summarizes input text concisely
127+
model: gpt-4o-mini
128+
modelParameters:
129+
temperature: 0.5
134130
messages:
131+
- role: system
132+
content: You are a text summarizer. Your only job is to summarize text given to you.
135133
- role: user
136-
content: 'Summarize the following text in one sentence: {{input}}'
137-
model: openai/gpt-4o
134+
content: |
135+
Summarize the given text, beginning with "Summary -":
136+
<text>
137+
{% raw %}{{input}}{% endraw %}
138+
</text>
138139
```
139140

140141
1. Commit and push the file to your repository.
@@ -156,28 +157,37 @@ Evaluations help you measure how different models respond to the same inputs so
156157

157158
1. Update the file to match the following example.
158159

159-
```yaml
160-
name: One-line summary
161-
description: Ask the model to summarize a paragraph in one sentence.
162-
messages:
163-
- role: user
164-
content: 'Summarize the following text in one sentence: {{input}}'
165-
model: openai/gpt-4o
166-
testData:
167-
- input: >-
168-
The museum opened a new dinosaur exhibit this weekend. Families from all
169-
over the city came to see the life-sized fossils and interactive displays.
170-
expected: >-
171-
The museum's new dinosaur exhibit attracted many families with its fossils
172-
and interactive displays.
173-
- input: >-
174-
Lucy baked cookies for the school fundraiser. She spent the entire evening
175-
in the kitchen to make sure there were enough for everyone.
176-
expected: Lucy baked cookies all evening to support the school fundraiser.
177-
evaluators:
178-
- name: Similarity
179-
uses: github/similarity
180-
```
160+
```yaml copy
161+
name: Text Summarizer
162+
description: Summarizes input text concisely
163+
model: gpt-4o-mini
164+
modelParameters:
165+
temperature: 0.5
166+
messages:
167+
- role: system
168+
content: You are a text summarizer. Your only job is to summarize text given to you.
169+
- role: user
170+
content: |
171+
Summarize the given text, beginning with "Summary -":
172+
<text>
173+
{% raw %}{{input}}{% endraw %}
174+
</text>
175+
testData:
176+
- input: |
177+
The quick brown fox jumped over the lazy dog.
178+
The dog was too tired to react.
179+
expected: Summary - A fox jumped over a lazy, unresponsive dog.
180+
- input: |
181+
The museum opened a new dinosaur exhibit this weekend. Families from all
182+
over the city came to see the life-sized fossils and interactive displays.
183+
expected: Summary - The museum's new dinosaur exhibit attracted many families with its fossils and interactive displays.
184+
evaluators:
185+
- name: Output should start with 'Summary -'
186+
string:
187+
startsWith: 'Summary -'
188+
- name: Similarity
189+
uses: github/similarity
190+
```
181191
182192
1. Commit and push the file to your repository.
183193

0 commit comments

Comments
 (0)