Skip to content

Commit 26f63aa

Browse files
authored
update effect (#264)
1 parent 2b6310b commit 26f63aa

File tree

16 files changed

+951
-882
lines changed

16 files changed

+951
-882
lines changed

docker-compose.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
services:
22
grafana:
3-
image: grafana/otel-lgtm:0.11.5
3+
image: grafana/otel-lgtm:0.11.10
44
container_name: grafana
55
restart: unless-stopped
66
ports:
77
- "4000:3000"
8-
- "4317:4317"
98
- "4318:4318"

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"type": "module",
4-
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977",
4+
"packageManager": "pnpm@10.17.1+sha512.17c560fca4867ae9473a3899ad84a88334914f379be46d455cbf92e5cf4b39d34985d452d2583baf19967fa76cb5c17bc9e245529d0b98745721aa7200ecaf7a",
55
"scripts": {
66
"clean": "node scripts/clean.mjs",
77
"build": "pnpm --recursive --parallel --filter \"./packages/**/*\" run build",
@@ -16,19 +16,19 @@
1616
},
1717
"devDependencies": {
1818
"@babel/cli": "^7.28.3",
19-
"@babel/core": "^7.28.3",
19+
"@babel/core": "^7.28.4",
2020
"@babel/plugin-transform-export-namespace-from": "^7.27.1",
2121
"@babel/plugin-transform-modules-commonjs": "^7.27.1",
2222
"@effect/build-utils": "^0.8.9",
2323
"@effect/eslint-plugin": "^0.3.2",
24-
"@effect/language-service": "^0.36.0",
25-
"@eslint/js": "^9.34.0",
26-
"@types/node": "^24.3.0",
24+
"@effect/language-service": "^0.40.0",
25+
"@eslint/js": "^9.36.0",
26+
"@types/node": "^24.5.2",
2727
"@vitest/coverage-v8": "^3.2.4",
2828
"@vitest/expect": "^3.2.4",
2929
"ast-types": "^0.14.2",
3030
"babel-plugin-annotate-pure-calls": "^0.5.0",
31-
"eslint": "^9.34.0",
31+
"eslint": "^9.36.0",
3232
"eslint-import-resolver-typescript": "^4.4.4",
3333
"eslint-plugin-import-x": "^4.16.1",
3434
"eslint-plugin-local-rules": "^3.0.2",
@@ -40,8 +40,8 @@
4040
"tsup": "^8.5.0",
4141
"tsx": "^4.20.5",
4242
"typescript": "^5.9.2",
43-
"typescript-eslint": "^8.41.0",
44-
"vite": "^7.1.4",
43+
"typescript-eslint": "^8.44.1",
44+
"vite": "^7.1.7",
4545
"vitest": "^3.2.4"
4646
},
4747
"pnpm": {

packages/discord-bot/package.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010
"@chat/discord": "workspace:*",
1111
"@chat/domain": "workspace:*",
1212
"@chat/shared": "workspace:*",
13-
"@effect/ai": "^0.26.0",
14-
"@effect/ai-openai": "^0.29.0",
15-
"@effect/cluster": "^0.48.2",
16-
"@effect/experimental": "^0.54.6",
17-
"@effect/language-service": "^0.36.0",
18-
"@effect/opentelemetry": "^0.56.4",
19-
"@effect/platform": "^0.90.6",
20-
"@effect/platform-node": "^0.96.1",
21-
"@octokit/plugin-rest-endpoint-methods": "^16.0.0",
22-
"@octokit/types": "^14.1.0",
23-
"@types/node": "^24.3.0",
24-
"dfx": "^0.124.1",
25-
"effect": "^3.17.10",
13+
"@effect/ai": "^0.28.0",
14+
"@effect/ai-openai": "^0.31.0",
15+
"@effect/cluster": "^0.49.0",
16+
"@effect/experimental": "^0.55.0",
17+
"@effect/language-service": "^0.40.0",
18+
"@effect/opentelemetry": "^0.57.0",
19+
"@effect/platform": "^0.91.0",
20+
"@effect/platform-node": "^0.97.0",
21+
"@octokit/plugin-rest-endpoint-methods": "^16.1.0",
22+
"@octokit/types": "^15.0.0",
23+
"@types/node": "^24.5.2",
24+
"dfx": "^0.125.1",
25+
"effect": "^3.17.14",
2626
"fuzzysort": "^3.1.0",
2727
"html-entities": "^2.6.0",
2828
"octokit": "^5.0.3"
2929
},
3030
"dependencies": {
31-
"@effect/workflow": "^0.9.2"
31+
"@effect/workflow": "^0.10.0"
3232
}
3333
}

packages/discord-bot/src/Ai.ts

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DiscordApplication } from "@chat/discord/DiscordRest"
2-
import { AiInput, AiLanguageModel, Tokenizer } from "@effect/ai"
2+
import { LanguageModel, Prompt, Tokenizer } from "@effect/ai"
33
import { OpenAiClient, OpenAiLanguageModel } from "@effect/ai-openai"
44
import { HttpClient } from "@effect/platform"
55
import { NodeHttpClient } from "@effect/platform-node"
@@ -44,7 +44,7 @@ export class AiHelpers extends Effect.Service<AiHelpers>()("app/AiHelpers", {
4444
{ concurrency: "unbounded" }
4545
),
4646
Effect.map(({ messages, openingMessage }) =>
47-
AiInput.make(
47+
Prompt.make(
4848
[...(message ? [message] : []), ...messages, openingMessage]
4949
.reverse()
5050
.filter(
@@ -54,59 +54,73 @@ export class AiHelpers extends Effect.Service<AiHelpers>()("app/AiHelpers", {
5454
)
5555
.filter((msg) => msg.content.trim().length > 0)
5656
.map(
57-
(msg): AiInput.Message =>
57+
(msg): Prompt.Message =>
5858
msg.author.id === botUser.id
59-
? AiInput.AssistantMessage.make({
60-
parts: [new AiInput.TextPart({ text: msg.content })]
59+
? Prompt.makeMessage("assistant", {
60+
content: [Prompt.makePart("text", { text: msg.content })]
6161
})
62-
: AiInput.UserMessage.make({
63-
parts: [new AiInput.TextPart({ text: msg.content })],
64-
userName: msg.author.username
62+
: Prompt.makeMessage("user", {
63+
content: [
64+
Prompt.makePart("text", {
65+
text: `<@${msg.author.id}>: ${msg.content}`
66+
})
67+
]
6568
})
6669
)
6770
)
6871
)
6972
)
7073

7174
const generateTitle = (prompt: string) =>
72-
AiLanguageModel.generateText({
73-
prompt,
74-
system:
75-
`You are a helpful assistant for the Effect Typescript library Discord community.
75+
LanguageModel.generateText({
76+
prompt: [
77+
{
78+
role: "system",
79+
content:
80+
`You are a helpful assistant for the Effect Typescript library Discord community.
7681
7782
Create a short title summarizing the message. Do not include markdown in the title.`
83+
},
84+
{ role: "user", content: [{ type: "text", text: prompt }] }
85+
]
7886
}).pipe(
7987
Effect.provide(model),
8088
OpenAiLanguageModel.withConfigOverride({
81-
temperature: 0.25,
82-
max_tokens: 64
89+
temperature: 0.25
90+
// TODO
91+
// max_tokens: 64
8392
}),
8493
Effect.map((_) => cleanTitle(_.text)),
8594
Effect.withSpan("Ai.generateTitle", { attributes: { prompt } })
8695
)
8796

8897
const generateDocs = Effect.fn("AiHelpers.generateDocs")(function*(
8998
title: string,
90-
messages: AiInput.AiInput,
99+
messages: Prompt.Prompt,
91100
instruction =
92101
"Create a documentation article from the above chat messages. The article should be written in markdown and should contain code examples where appropiate."
93102
) {
94103
const tokenizer = yield* Tokenizer.Tokenizer
95104
const prompt = yield* tokenizer.truncate(
96-
AiInput.concat(messages, AiInput.make(instruction)),
105+
Prompt.merge(messages, Prompt.make(instruction)),
97106
30_000
98107
)
99-
const response = yield* AiLanguageModel.generateText({
100-
prompt,
101-
system:
102-
`You are a helpful assistant for the Effect Typescript library Discord community.
108+
const response = yield* LanguageModel.generateText({
109+
prompt: Prompt.merge(
110+
Prompt.make([{
111+
role: "system",
112+
content:
113+
`You are a helpful assistant for the Effect Typescript library Discord community.
103114
104115
The title of this chat is "${title}".`
116+
}]),
117+
prompt
118+
)
105119
})
106120
return response.text
107121
}, Effect.provide(model))
108122

109-
const generateSummary = (title: string, messages: AiInput.AiInput) =>
123+
const generateSummary = (title: string, messages: Prompt.Prompt) =>
110124
generateDocs(
111125
title,
112126
messages,

packages/discord-bot/src/Issueifier.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { DiscordGatewayLayer } from "@chat/discord/DiscordGateway"
22
import { DiscordApplication } from "@chat/discord/DiscordRest"
33
import { Messages } from "@chat/discord/Messages"
4-
import { AiInput, AiLanguageModel } from "@effect/ai"
4+
import { LanguageModel, Prompt } from "@effect/ai"
55
import { OpenAiLanguageModel } from "@effect/ai-openai"
66
import { Discord, DiscordREST, Ix } from "dfx"
77
import { InteractionsRegistry } from "dfx/gateway"
@@ -53,22 +53,28 @@ const make = Effect.gen(function*() {
5353
const input = chunk.pipe(
5454
Chunk.reverse,
5555
Chunk.map(
56-
(msg): AiInput.Message =>
57-
new AiInput.UserMessage({
58-
parts: [new AiInput.TextPart({ text: msg.content })],
59-
userName: msg.author.username
56+
(msg): Prompt.Message =>
57+
Prompt.makeMessage("user", {
58+
content: [Prompt.makePart("text", {
59+
text: `@${msg.author.username}: ${msg.content}`
60+
})]
6061
})
6162
),
62-
AiInput.make
63+
Prompt.make
6364
)
64-
const summary = yield* AiLanguageModel.generateObject({
65-
system:
66-
`You are a helpful assistant that summarizes Discord threads into concise titles and summaries for Github issues.
65+
const summary = yield* LanguageModel.generateObject({
66+
prompt: Prompt.merge(
67+
Prompt.make([{
68+
role: "system",
69+
content:
70+
`You are a helpful assistant that summarizes Discord threads into concise titles and summaries for Github issues.
6771
6872
In the summary, include some key takeaways or important points discussed in the thread.
6973
70-
The title of this conversation is: "${channelName}"`,
71-
prompt: input,
74+
The title of this conversation is: "${channelName}"`
75+
}]),
76+
input
77+
),
7278
schema: ThreadSummary
7379
}).pipe(
7480
Effect.provide(summaryModel)

packages/discord-bot/src/ReproRequester.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DiscordGatewayLayer } from "@chat/discord/DiscordGateway"
22
import { DiscordApplication } from "@chat/discord/DiscordRest"
3-
import { AiLanguageModel, Tokenizer } from "@effect/ai"
3+
import { LanguageModel, Prompt, Tokenizer } from "@effect/ai"
44
import { Discord, DiscordREST, Ix } from "dfx"
55
import { InteractionsRegistry } from "dfx/gateway"
66
import { Effect, Layer } from "effect"
@@ -58,9 +58,14 @@ const make = Effect.gen(function*() {
5858
const tokenizer = yield* Tokenizer.Tokenizer
5959
const input = yield* ai.generateAiInput(channel)
6060
const prompt = yield* tokenizer.truncate(input, 30_000)
61-
const response = yield* AiLanguageModel.generateText({
62-
prompt,
63-
system: systemInstruction
61+
const response = yield* LanguageModel.generateText({
62+
prompt: Prompt.merge(
63+
Prompt.make([{
64+
role: "system",
65+
content: systemInstruction
66+
}]),
67+
prompt
68+
)
6469
}).pipe(Effect.annotateLogs({ thread: channel.id }))
6570
yield* discord.updateOriginalWebhookMessage(
6671
application.id,

packages/discord-bot/src/Summarizer.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,18 @@ ${message.content}${imagesContent}`
157157
)
158158
),
159159
Effect.catchAllCause((cause) =>
160-
rest.updateOriginalWebhookMessage(application.id, context.token, {
161-
payload: {
162-
content:
163-
"Could not create summary. Here are the full error details:\n\n```" +
164-
Cause.pretty(cause) +
165-
"\n```"
160+
rest.updateOriginalWebhookMessage(
161+
application.id,
162+
context.token,
163+
{
164+
payload: {
165+
content:
166+
"Could not create summary. Here are the full error details:\n\n```" +
167+
Cause.pretty(cause) +
168+
"\n```"
169+
}
166170
}
167-
})
171+
)
168172
),
169173
Effect.withSpan("Summarizer.followUpResponse", {
170174
attributes: {

packages/discord-bot/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { AutoThreadsLive } from "./AutoThreads.ts"
55
import { DadJokesLive } from "./DadJokes.ts"
66
import { DocsLookupLive } from "./DocsLookup.ts"
77
import { IssueifierLive } from "./Issueifier.ts"
8+
import { MentionsLive } from "./Mentions.ts"
89
import { MessageLoggerLayer } from "./MessageLogger.ts"
910
import { NoEmbedLive } from "./NoEmbed.ts"
1011
import { NotificationsLayer } from "./Notifications.ts"
@@ -28,6 +29,7 @@ const MainLive = Layer.mergeAll(
2829
DocsLookupLive,
2930
IssueifierLive,
3031
MessageLoggerLayer,
32+
MentionsLive,
3133
NotificationsLayer,
3234
PlaygroundLive,
3335
RemindersLive,

packages/discord/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
"./*": "./src/*.ts"
1010
},
1111
"dependencies": {
12-
"@effect/platform": "^0.90.6",
13-
"@effect/platform-node": "^0.96.1",
14-
"dfx": "^0.124.1",
15-
"effect": "^3.17.10"
12+
"@effect/platform": "^0.91.0",
13+
"@effect/platform-node": "^0.97.0",
14+
"dfx": "^0.125.1",
15+
"effect": "^3.17.14"
1616
}
1717
}

packages/domain/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
"./*": "./src/*.ts"
1010
},
1111
"dependencies": {
12-
"@effect/ai": "^0.26.0",
13-
"@effect/cluster": "^0.48.2",
14-
"@effect/rpc": "^0.69.1",
15-
"@effect/sql": "^0.44.2",
16-
"@effect/workflow": "^0.9.2",
17-
"effect": "^3.17.10"
12+
"@effect/ai": "^0.28.0",
13+
"@effect/cluster": "^0.49.0",
14+
"@effect/rpc": "^0.70.0",
15+
"@effect/sql": "^0.45.0",
16+
"@effect/workflow": "^0.10.0",
17+
"effect": "^3.17.14"
1818
}
1919
}

0 commit comments

Comments
 (0)