Skip to content

Commit 27965bc

Browse files
authored
updated docs for missing prompt.yml model parameters
1 parent a8bddad commit 27965bc

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,33 @@ supplied via the `input` parameter in YAML format. Additionally, you can
123123
provide file-based variables via `file_input`, where each key maps to a file
124124
path.
125125

126+
### Prompt.yml with model parameters
127+
128+
You can specify model parameters directly in your `.prompt.yml` files using the
129+
`modelParameters` key:
130+
131+
```yaml
132+
messages:
133+
- role: system
134+
content: Be as concise as possible
135+
- role: user
136+
content: 'Compare {{a}} and {{b}}, please'
137+
model: openai/gpt-4o
138+
modelParameters:
139+
maxCompletionTokens: 500
140+
temperature: 0.7
141+
```
142+
143+
| Key | Type | Description |
144+
| --------------------- | ------ | -------------------------------------------------------------- |
145+
| `maxCompletionTokens` | number | The maximum number of tokens to generate |
146+
| `maxTokens` | number | The maximum number of tokens to generate (deprecated) |
147+
| `temperature` | number | The sampling temperature to use (0-1) |
148+
| `topP` | number | The nucleus sampling parameter to use (0-1) |
149+
150+
> ![Note]
151+
> Parameters set in `modelParameters` take precedence over the corresponding action inputs.
152+
126153
### Using a system prompt file
127154

128155
In addition to the regular prompt, you can provide a system prompt file instead
@@ -287,7 +314,8 @@ the action:
287314
| `system-prompt-file` | Path to a file containing the system prompt. If both `system-prompt` and `system-prompt-file` are provided, `system-prompt-file` takes precedence | `""` |
288315
| `model` | The model to use for inference. Must be available in the [GitHub Models](https://github.com/marketplace?type=models) catalog | `openai/gpt-4o` |
289316
| `endpoint` | The endpoint to use for inference. If you're running this as part of an org, you should probably use the org-specific Models endpoint | `https://models.github.ai/inference` |
290-
| `max-tokens` | The max number of tokens to generate | 200 |
317+
| `max-tokens` | The maximum number of tokens to generate (deprecated, use `max-completion-tokens` instead) | 200 |
318+
| `max-completion-tokens` | The maximum number of tokens to generate | `""` |
291319
| `temperature` | The sampling temperature to use (0-1) | `""` |
292320
| `top-p` | The nucleus sampling parameter to use (0-1) | `""` |
293321
| `enable-github-mcp` | Enable Model Context Protocol integration with GitHub tools | `false` |

src/inference.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as core from '@actions/core'
22
import OpenAI from 'openai'
3-
import {GitHubMCPClient, executeToolCalls, ToolCall} from './mcp.js'
3+
import { GitHubMCPClient, executeToolCalls, ToolCall } from './mcp.js'
44

55
interface ChatMessage {
66
role: 'system' | 'user' | 'assistant' | 'tool'
@@ -10,15 +10,15 @@ interface ChatMessage {
1010
}
1111

1212
export interface InferenceRequest {
13-
messages: Array<{role: 'system' | 'user' | 'assistant' | 'tool'; content: string}>
13+
messages: Array<{ role: 'system' | 'user' | 'assistant' | 'tool'; content: string }>
1414
modelName: string
1515
maxTokens?: number // Deprecated
1616
maxCompletionTokens?: number
1717
endpoint: string
1818
token: string
1919
temperature?: number
2020
topP?: number
21-
responseFormat?: {type: 'json_schema'; json_schema: unknown} // Processed response format for the API
21+
responseFormat?: { type: 'json_schema'; json_schema: unknown } // Processed response format for the API
2222
customHeaders?: Record<string, string> // Custom HTTP headers to include in API requests
2323
}
2424

@@ -34,18 +34,17 @@ export interface InferenceResponse {
3434
}>
3535
}
3636

37-
// Note: solution around models using different underlying max tokens properties
3837

3938
/**
4039
* Build according to what input was passed, default to max_tokens.
4140
* Only one of max_tokens or max_completion_tokens will be set.
4241
*/
43-
function buildMaxTokensParam(request: InferenceRequest): {max_tokens?: number; max_completion_tokens?: number} {
42+
function buildMaxTokensParam(request: InferenceRequest): { max_tokens?: number; max_completion_tokens?: number } {
4443
if (request.maxCompletionTokens != null) {
45-
return {max_completion_tokens: request.maxCompletionTokens}
44+
return { max_completion_tokens: request.maxCompletionTokens }
4645
}
4746
if (request.maxTokens != null) {
48-
return {max_tokens: request.maxTokens}
47+
return { max_tokens: request.maxTokens }
4948
}
5049
return {}
5150
}
@@ -115,7 +114,7 @@ export async function mcpInference(
115114
model: request.modelName,
116115
temperature: request.temperature,
117116
top_p: request.topP,
118-
...buildMaxTokensParam(request),
117+
...buildMaxTokensParam(request), // Note: solution around models using different underlying max tokens properties
119118
}
120119

121120
// Add response format if specified (only on final iteration to avoid conflicts with tool calls)
@@ -138,7 +137,7 @@ export async function mcpInference(
138137
messages.push({
139138
role: 'assistant',
140139
content: modelResponse || '',
141-
...(toolCalls && {tool_calls: toolCalls as ToolCall[]}),
140+
...(toolCalls && { tool_calls: toolCalls as ToolCall[] }),
142141
})
143142

144143
if (!toolCalls || toolCalls.length === 0) {

0 commit comments

Comments
 (0)