Skip to content

Commit 45ff623

Browse files
committed
feat: prompt basic inference request
Signed-off-by: Rishav Dhar <19497993+rdhar@users.noreply.github.com>
1 parent 24c5b94 commit 45ff623

2 files changed

Lines changed: 66 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Inference Request via GitHub Action
77

88
> [!TIP]
9-
> Run an inference request to GitHub Models via GitHub Action.
9+
> Run [inference requests](https://docs.github.com/en/rest/models/inference#run-an-inference-request "GitHub API documentation.") to [GitHub Models](https://github.com/marketplace?type=models "GitHub models catalog.") with this GitHub Action.
1010
1111
</br>
1212

@@ -43,4 +43,4 @@ View [all notable changes](https://github.com/op5dev/inference-request/releases
4343

4444
- This project is licensed under the **permissive** [Apache License 2.0](LICENSE "Apache License 2.0.").
4545
- All works herein are my own, shared of my own volition, and [contributors](https://github.com/op5dev/inference-request/graphs/contributors "Contributors.").
46-
- Copyright 2016-present [Rishav Dhar](https://github.com/rdhar "Rishav Dhar's GitHub profile.") — All wrongs reserved.
46+
- Copyright 2016-present [Rishav Dhar](https://rdhar.dev "Rishav Dhar's profile.") — All wrongs reserved.

action.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
name: Inference Request via GitHub Action
3+
author: Rishav Dhar (https://rdhar.dev)
4+
description: Run inference requests to GitHub Models with this GitHub Action.
5+
6+
inputs:
7+
github-api-version:
8+
default: "2022-11-28"
9+
description: "GitHub API version (e.g., `2022-11-28`)."
10+
required: false
11+
github-token:
12+
default: ${{ github.token }}
13+
description: "GitHub token (e.g., `secrets.GITHUB_TOKEN`)."
14+
required: false
15+
messages:
16+
default: "[]"
17+
description: 'Messages to send to the model in JSON format (e.g., `[{"role": "user", "content": "Hello!"}]`).'
18+
required: true
19+
model:
20+
default: "openai/o4-mini"
21+
description: "Model to use for inference (e.g., `openai/o4-mini`)."
22+
required: true
23+
org:
24+
default: ""
25+
description: "Organization to which the request should be attributed (e.g., `op5dev`)."
26+
required: false
27+
28+
runs:
29+
using: composite
30+
steps:
31+
- id: request
32+
shell: bash
33+
env:
34+
API_VERSION: ${{ inputs.github-api-version }}
35+
GH_HOST: ${{ github.server_url }}
36+
GH_TOKEN: ${{ inputs.github-token }}
37+
ORG: ${{ inputs.org != '' && format('orgs/{0}/', inputs.org) || '' }}
38+
run: |
39+
GH_HOST=$(echo $GH_HOST | sed 's/.*:\/\///')
40+
41+
response_raw=$(curl --request POST --location https://models.github.ai/${ORG}inference/chat/completions \
42+
--header "Accept: application/vnd.github+json" \
43+
--header "Authorization: Bearer $GH_TOKEN" \
44+
--header "Content-Type: application/json" \
45+
--header "X-GitHub-Api-Version: $API_VERSION" \
46+
--data '{
47+
"messages": '"${{ inputs.messages }}"',
48+
"model": '"${{ inputs.model }}"'
49+
}')
50+
51+
echo "response_raw=$response_raw" >> $GITHUB_OUTPUT
52+
echo "response=$response_raw | jq --raw-output '.choices[0].message.content'" >> $GITHUB_OUTPUT
53+
54+
outputs:
55+
response:
56+
description: "Placeholder."
57+
value: ${{ steps.request.outputs.response }}
58+
response-raw:
59+
description: "Placeholder."
60+
value: ${{ steps.request.outputs.response_raw }}
61+
62+
branding:
63+
color: white
64+
icon: loader

0 commit comments

Comments
 (0)