Skip to content

Commit 01ec940

Browse files
committed
Merge branch 'main' into feat/update-vitest
* main: (37 commits) Version Packages (Effect-TS#5869) Fix the arbitrary generator for BigDecimal to allow negative scales (Effect-TS#5875) Widen otel logs peer dep range (Effect-TS#5863) Ensure Devtools Tracer does not cut off span options (Effect-TS#5864) Version Packages (Effect-TS#5848) Update generated OpenAI schema definitions (Effect-TS#5850) Update generated OpenRouter definitions and fix logprob schema (Effect-TS#5849) add Workflow.scope, a seperate Scope that only closes on completion (Effect-TS#5846) ensure PersistedQueue memory driver removes items (Effect-TS#5847) Version Packages (Effect-TS#5838) support idempotent offers to PersistedQueue (Effect-TS#5837) Version Packages (Effect-TS#5836) consider clean http interrupts (already responded) as successful responses (Effect-TS#5835) Version Packages (Effect-TS#5830) reset redis staging area on a schedule for PersistedQueue (Effect-TS#5829) Version Packages (Effect-TS#5828) add TestRunner & SingleRunner modules (Effect-TS#5827) Version Packages (Effect-TS#5825) improve ordering guarantees for SqlPersistedQueue (Effect-TS#5824) Version Packages (Effect-TS#5822) ... # Conflicts: # pnpm-lock.yaml
2 parents 77e1fd6 + 18783c9 commit 01ec940

File tree

85 files changed

+16468
-7336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+16468
-7336
lines changed

.github/actions/setup/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ inputs:
55
description: The version of Node.js to install
66
required: true
77
default: 23.7.0
8+
registry-url:
9+
description: Optional registry to set up for auth.
810

911
runs:
1012
using: composite
@@ -16,6 +18,7 @@ runs:
1618
with:
1719
cache: pnpm
1820
node-version: ${{ inputs.node-version }}
21+
registry-url: ${{ inputs.registry-url }}
1922
- name: Install dependencies
2023
shell: bash
2124
run: pnpm install

.github/workflows/release.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ jobs:
2222
- uses: actions/checkout@v4
2323
- name: Install dependencies
2424
uses: ./.github/actions/setup
25+
with:
26+
registry-url: "https://registry.npmjs.org"
27+
- name: Upgrade npm for OIDC support
28+
run: npm install -g npm@latest
2529
- name: Create Release Pull Request or Publish
2630
uses: changesets/action@v1
2731
with:
2832
version: pnpm changeset-version
2933
publish: pnpm changeset-publish
3034
env:
3135
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

packages/ai/ai/src/Prompt.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,7 @@ export const setSystem: {
17881788
* prompt,
17891789
* "You are a helpful assistant. "
17901790
* )
1791+
* // result content: "You are a helpful assistant. You are an expert in programming."
17911792
* ```
17921793
*
17931794
* @since 1.0.0
@@ -1797,18 +1798,19 @@ export const prependSystem: {
17971798
(content: string): (self: Prompt) => Prompt
17981799
(self: Prompt, content: string): Prompt
17991800
} = dual(2, (self: Prompt, content: string): Prompt => {
1800-
const messages: Array<Message> = []
1801+
let system: SystemMessage | undefined = undefined
18011802
for (const message of self.content) {
18021803
if (message.role === "system") {
1803-
const system = makeMessage("system", {
1804+
system = makeMessage("system", {
18041805
content: content + message.content
18051806
})
1806-
messages.push(system)
1807-
} else {
1808-
messages.push(message)
1807+
break
18091808
}
18101809
}
1811-
return makePrompt(messages)
1810+
if (Predicate.isUndefined(system)) {
1811+
system = makeMessage("system", { content })
1812+
}
1813+
return makePrompt([system, ...self.content])
18121814
})
18131815

18141816
/**
@@ -1824,7 +1826,7 @@ export const prependSystem: {
18241826
*
18251827
* const systemPrompt = Prompt.make([{
18261828
* role: "system",
1827-
* content: "You are a helpful assistant."
1829+
* content: "You are an expert in programming."
18281830
* }])
18291831
*
18301832
* const userPrompt = Prompt.make("Hello, world!")
@@ -1833,8 +1835,9 @@ export const prependSystem: {
18331835
*
18341836
* const replaced = Prompt.appendSystem(
18351837
* prompt,
1836-
* " You are an expert in programming."
1838+
* " You are a helpful assistant."
18371839
* )
1840+
* // result content: "You are an expert in programming. You are a helpful assistant."
18381841
* ```
18391842
*
18401843
* @since 1.0.0
@@ -1844,16 +1847,17 @@ export const appendSystem: {
18441847
(content: string): (self: Prompt) => Prompt
18451848
(self: Prompt, content: string): Prompt
18461849
} = dual(2, (self: Prompt, content: string): Prompt => {
1847-
const messages: Array<Message> = []
1850+
let system: SystemMessage | undefined = undefined
18481851
for (const message of self.content) {
18491852
if (message.role === "system") {
1850-
const system = makeMessage("system", {
1853+
system = makeMessage("system", {
18511854
content: message.content + content
18521855
})
1853-
messages.push(system)
1854-
} else {
1855-
messages.push(message)
1856+
break
18561857
}
18571858
}
1858-
return makePrompt(messages)
1859+
if (Predicate.isUndefined(system)) {
1860+
system = makeMessage("system", { content })
1861+
}
1862+
return makePrompt([system, ...self.content])
18591863
})

packages/ai/ai/test/Prompt.test.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,101 @@ describe("Prompt", () => {
9999
assert.deepStrictEqual(merged, prompt)
100100
})
101101
})
102+
103+
describe("appendSystem", () => {
104+
it("should append text to existing system message", () => {
105+
const prompt = Prompt.make([
106+
{ role: "system", content: "You are an expert in programming." },
107+
{ role: "user", content: "Hello, world!" }
108+
])
109+
110+
const result = Prompt.appendSystem(prompt, " You are a helpful assistant.")
111+
112+
assert.deepStrictEqual(
113+
result.content[0],
114+
Prompt.makeMessage("system", {
115+
content: "You are an expert in programming. You are a helpful assistant."
116+
})
117+
)
118+
})
119+
120+
it("should create a new system message if none exists", () => {
121+
const prompt = Prompt.make([
122+
{ role: "user", content: "Hello, world!" }
123+
])
124+
125+
const result = Prompt.appendSystem(prompt, "You are a helpful assistant.")
126+
127+
assert.deepStrictEqual(
128+
result.content[0],
129+
Prompt.makeMessage("system", {
130+
content: "You are a helpful assistant."
131+
})
132+
)
133+
})
134+
135+
it("should work with empty prompt", () => {
136+
const prompt = Prompt.empty
137+
138+
const result = Prompt.appendSystem(prompt, "You are a helpful assistant.")
139+
140+
assert.deepStrictEqual(
141+
result.content[0],
142+
Prompt.makeMessage("system", { content: "You are a helpful assistant." })
143+
)
144+
})
145+
})
146+
147+
describe("prependSystem", () => {
148+
it("should prepend text to existing system message", () => {
149+
const prompt = Prompt.make([
150+
{
151+
role: "system",
152+
content: "You are an expert in programming."
153+
},
154+
{
155+
role: "user",
156+
content: "Hello, world!"
157+
}
158+
])
159+
160+
const result = Prompt.prependSystem(prompt, "You are a helpful assistant. ")
161+
162+
assert.deepStrictEqual(
163+
result.content[0],
164+
Prompt.makeMessage("system", {
165+
content: "You are a helpful assistant. You are an expert in programming."
166+
})
167+
)
168+
})
169+
170+
it("should create a new system message if none exists", () => {
171+
const prompt = Prompt.make([
172+
{
173+
role: "user",
174+
content: "Hello, world!"
175+
}
176+
])
177+
178+
const result = Prompt.prependSystem(prompt, "You are a helpful assistant.")
179+
180+
assert.deepStrictEqual(
181+
result.content[0],
182+
Prompt.makeMessage("system", {
183+
content: "You are a helpful assistant."
184+
})
185+
)
186+
})
187+
188+
it("should work with empty prompt", () => {
189+
const prompt = Prompt.empty
190+
191+
const result = Prompt.prependSystem(prompt, "You are a helpful assistant.")
192+
193+
assert.deepStrictEqual(
194+
result.content[0],
195+
Prompt.makeMessage("system", { content: "You are a helpful assistant." })
196+
)
197+
})
198+
})
102199
})

packages/ai/openai/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# @effect/ai-openai
22

3+
## 0.36.0
4+
5+
### Minor Changes
6+
7+
- [#5850](https://github.com/Effect-TS/effect/pull/5850) [`1ddd4e4`](https://github.com/Effect-TS/effect/commit/1ddd4e477a9677fb3820f80450a378d3550d31a7) Thanks @IMax153! - Update the generated OpenAI schema definitions
8+
9+
### Patch Changes
10+
11+
- Updated dependencies [[`96c9537`](https://github.com/Effect-TS/effect/commit/96c9537f73a87a651c348488bdce7efbfd8360d1)]:
12+
- @effect/experimental@0.57.10
13+
314
## 0.35.0
415

516
### Patch Changes

packages/ai/openai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@effect/ai-openai",
33
"type": "module",
4-
"version": "0.35.0",
4+
"version": "0.36.0",
55
"license": "MIT",
66
"description": "Effect modules for working with AI apis",
77
"homepage": "https://effect.website",
Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
11
diff --git a/packages/ai/openai/src/Generated.ts b/packages/ai/openai/src/Generated.ts
2-
index bff596c3d..938a26f44 100644
2+
index 1f2580576..a24c4f359 100644
33
--- a/packages/ai/openai/src/Generated.ts
44
+++ b/packages/ai/openai/src/Generated.ts
5-
@@ -897,7 +897,7 @@ export class CreateTranscriptionResponseVerboseJson
5+
@@ -915,9 +915,9 @@ export class CreateTranscriptionResponseVerboseJson
66
{}
77

8-
export class CreateTranscription200
9-
- extends S.Union(CreateTranscriptionResponseJson, CreateTranscriptionResponseVerboseJson)
10-
+ extends S.Union(CreateTranscriptionResponseVerboseJson, CreateTranscriptionResponseJson)
11-
{}
12-
13-
export class CreateTranslationRequestModelEnum extends S.Literal("whisper-1") {}
14-
@@ -4844,7 +4844,8 @@ export class Includable extends S.Literal(
15-
"file_search_call.results",
16-
"message.input_image.image_url",
17-
"message.output_text.logprobs",
18-
- "reasoning.encrypted_content"
19-
+ "reasoning.encrypted_content",
20-
+ "web_search_call.action.sources"
8+
export class CreateTranscription200 extends S.Union(
9+
- CreateTranscriptionResponseJson,
10+
+ CreateTranscriptionResponseVerboseJson,
11+
CreateTranscriptionResponseDiarizedJson,
12+
- CreateTranscriptionResponseVerboseJson
13+
+ CreateTranscriptionResponseJson
2114
) {}
2215

23-
export class ListConversationItemsParams extends S.Struct({
16+
export class CreateTranslationRequestModelEnum extends S.Literal("whisper-1") {}

0 commit comments

Comments
 (0)