Skip to content

Commit 6bef1d0

Browse files
authored
Merge pull request #72 from actions/mr/linters
2 parents b1fc21b + a5af2ca commit 6bef1d0

30 files changed

+378
-589
lines changed
File renamed without changes.
File renamed without changes.

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ jobs:
8383
run: echo "hello" > prompt.txt
8484

8585
- name: Create System Prompt File
86-
run:
87-
echo "You are a helpful AI assistant for testing." > system-prompt.txt
86+
run: echo "You are a helpful AI assistant for testing." > system-prompt.txt
8887

8988
- name: Test Local Action with Prompt File
9089
id: test-action-prompt-file

.github/workflows/release-new-action-version.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ permissions:
1111

1212
jobs:
1313
update_tag:
14-
name:
15-
Update the major tag to include the ${{ github.event.release.tag_name }}
14+
name: Update the major tag to include the ${{ github.event.release.tag_name }}
1615
changes
1716
runs-on: ubuntu-latest
1817
steps:

.prettierrc.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,7 @@ model: openai/gpt-4o
8383
```yaml
8484
messages:
8585
- role: system
86-
content:
87-
You are a helpful assistant that describes animals using JSON format
86+
content: You are a helpful assistant that describes animals using JSON format
8887
- role: user
8988
content: |-
9089
Describe a {{animal}}

__fixtures__/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type * as core from '@actions/core'
2-
import { vi } from 'vitest'
2+
import {vi} from 'vitest'
33

44
export const debug = vi.fn<typeof core.debug>()
55
export const error = vi.fn<typeof core.error>()

__fixtures__/prompts/json-schema.prompt.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
messages:
22
- role: system
3-
content:
4-
You are a helpful assistant that describes animals using JSON format
3+
content: You are a helpful assistant that describes animals using JSON format
54
- role: user
65
content: |-
76
Describe a {{animal}}

__fixtures__/wait.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { vi } from 'vitest'
1+
import {vi} from 'vitest'
22

33
export const wait = vi.fn<typeof import('../src/wait.js').wait>()

__tests__/helpers-inference.test.ts

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,37 @@
1-
import { describe, it, expect } from 'vitest'
2-
import {
3-
buildMessages,
4-
buildResponseFormat,
5-
buildInferenceRequest
6-
} from '../src/helpers'
7-
import { PromptConfig } from '../src/prompt'
1+
import {describe, it, expect} from 'vitest'
2+
import {buildMessages, buildResponseFormat, buildInferenceRequest} from '../src/helpers'
3+
import {PromptConfig} from '../src/prompt'
84

95
describe('helpers.ts - inference request building', () => {
106
describe('buildMessages', () => {
117
it('should build messages from prompt config', () => {
128
const promptConfig: PromptConfig = {
139
messages: [
14-
{ role: 'system', content: 'System message' },
15-
{ role: 'user', content: 'User message' }
16-
]
10+
{role: 'system', content: 'System message'},
11+
{role: 'user', content: 'User message'},
12+
],
1713
}
1814

1915
const result = buildMessages(promptConfig)
2016
expect(result).toEqual([
21-
{ role: 'system', content: 'System message' },
22-
{ role: 'user', content: 'User message' }
17+
{role: 'system', content: 'System message'},
18+
{role: 'user', content: 'User message'},
2319
])
2420
})
2521

2622
it('should build messages from legacy format', () => {
2723
const result = buildMessages(undefined, 'System prompt', 'User prompt')
2824
expect(result).toEqual([
29-
{ role: 'system', content: 'System prompt' },
30-
{ role: 'user', content: 'User prompt' }
25+
{role: 'system', content: 'System prompt'},
26+
{role: 'user', content: 'User prompt'},
3127
])
3228
})
3329

3430
it('should use default system prompt when none provided', () => {
3531
const result = buildMessages(undefined, undefined, 'User prompt')
3632
expect(result).toEqual([
37-
{ role: 'system', content: 'You are a helpful assistant' },
38-
{ role: 'user', content: 'User prompt' }
33+
{role: 'system', content: 'You are a helpful assistant'},
34+
{role: 'user', content: 'User prompt'},
3935
])
4036
})
4137
})
@@ -47,24 +43,24 @@ describe('helpers.ts - inference request building', () => {
4743
responseFormat: 'json_schema',
4844
jsonSchema: JSON.stringify({
4945
name: 'test_schema',
50-
schema: { type: 'object' }
51-
})
46+
schema: {type: 'object'},
47+
}),
5248
}
5349

5450
const result = buildResponseFormat(promptConfig)
5551
expect(result).toEqual({
5652
type: 'json_schema',
5753
json_schema: {
5854
name: 'test_schema',
59-
schema: { type: 'object' }
60-
}
55+
schema: {type: 'object'},
56+
},
6157
})
6258
})
6359

6460
it('should return undefined for text format', () => {
6561
const promptConfig: PromptConfig = {
6662
messages: [],
67-
responseFormat: 'text'
63+
responseFormat: 'text',
6864
}
6965

7066
const result = buildResponseFormat(promptConfig)
@@ -73,7 +69,7 @@ describe('helpers.ts - inference request building', () => {
7369

7470
it('should return undefined when no response format specified', () => {
7571
const promptConfig: PromptConfig = {
76-
messages: []
72+
messages: [],
7773
}
7874

7975
const result = buildResponseFormat(promptConfig)
@@ -84,27 +80,25 @@ describe('helpers.ts - inference request building', () => {
8480
const promptConfig: PromptConfig = {
8581
messages: [],
8682
responseFormat: 'json_schema',
87-
jsonSchema: 'invalid json'
83+
jsonSchema: 'invalid json',
8884
}
8985

90-
expect(() => buildResponseFormat(promptConfig)).toThrow(
91-
'Invalid JSON schema'
92-
)
86+
expect(() => buildResponseFormat(promptConfig)).toThrow('Invalid JSON schema')
9387
})
9488
})
9589

9690
describe('buildInferenceRequest', () => {
9791
it('should build complete inference request from prompt config', () => {
9892
const promptConfig: PromptConfig = {
9993
messages: [
100-
{ role: 'system', content: 'System message' },
101-
{ role: 'user', content: 'User message' }
94+
{role: 'system', content: 'System message'},
95+
{role: 'user', content: 'User message'},
10296
],
10397
responseFormat: 'json_schema',
10498
jsonSchema: JSON.stringify({
10599
name: 'test_schema',
106-
schema: { type: 'object' }
107-
})
100+
schema: {type: 'object'},
101+
}),
108102
}
109103

110104
const result = buildInferenceRequest(
@@ -114,13 +108,13 @@ describe('helpers.ts - inference request building', () => {
114108
'gpt-4',
115109
100,
116110
'https://api.test.com',
117-
'test-token'
111+
'test-token',
118112
)
119113

120114
expect(result).toEqual({
121115
messages: [
122-
{ role: 'system', content: 'System message' },
123-
{ role: 'user', content: 'User message' }
116+
{role: 'system', content: 'System message'},
117+
{role: 'user', content: 'User message'},
124118
],
125119
modelName: 'gpt-4',
126120
maxTokens: 100,
@@ -130,9 +124,9 @@ describe('helpers.ts - inference request building', () => {
130124
type: 'json_schema',
131125
json_schema: {
132126
name: 'test_schema',
133-
schema: { type: 'object' }
134-
}
135-
}
127+
schema: {type: 'object'},
128+
},
129+
},
136130
})
137131
})
138132

@@ -144,19 +138,19 @@ describe('helpers.ts - inference request building', () => {
144138
'gpt-4',
145139
100,
146140
'https://api.test.com',
147-
'test-token'
141+
'test-token',
148142
)
149143

150144
expect(result).toEqual({
151145
messages: [
152-
{ role: 'system', content: 'System prompt' },
153-
{ role: 'user', content: 'User prompt' }
146+
{role: 'system', content: 'System prompt'},
147+
{role: 'user', content: 'User prompt'},
154148
],
155149
modelName: 'gpt-4',
156150
maxTokens: 100,
157151
endpoint: 'https://api.test.com',
158152
token: 'test-token',
159-
responseFormat: undefined
153+
responseFormat: undefined,
160154
})
161155
})
162156
})

0 commit comments

Comments
 (0)