Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,14 @@ sequenceDiagram
participant S as 画像生成サービス

U->>A: @agent 銀髪の騎士のキャラクター画像をちょうだい
A-->>U: 足りない内容を決めるカード(Slack・Teams はモーダル、Discord はボタン)
A-->>U: 足りない内容を決めるカード(モーダルを開く)
U->>A: 三面図
A->>S: 三面図を頼む
S-->>A: 画像
A-->>U: 画像をスレッドに貼る
```

用途・目的・何を描くかが揃っていればすぐ描く。足りなければ「画像生成したい」だけでもカードが出て、Slack・Teams ではフォームで残りを決める。Discord では、何を描くかは会話で、目的はボタンで決める。
用途・目的・何を描くかが揃っていればすぐ描く。足りなければ「画像生成したい」だけでもカードが出て、フォームで残りを決める。

| 用途 | 目的 |
| ------------ | ---------------------------------- |
Expand All @@ -307,7 +307,7 @@ sequenceDiagram
| アイテム | 単体・三面図 |
| イラスト | なし(頼まれたとおりに描く) |

形は「横長で」のように頼むか、Slack・Teams なら目的と一緒に選べる。カードから描くのに失敗したら、「描き直す」でやり直せる。
形は「横長で」のように頼むか、フォームで目的と一緒に選べる。カードから描くのに失敗したら、「描き直す」でやり直せる。

## セットアップ

Expand Down
4 changes: 4 additions & 0 deletions apps/agent/evals/conversation/aspects.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
"title": "ほかのスレッドの似た依頼",
"rule": "propose_plan が related を返したら、重なる依頼が無ければ related_checked で起票し直す。重なる依頼があれば起票せず、その stage(計画中・未着手・実装中・完了・見送り)に合った案内をして利用者に選ばせる。完了した依頼(子 Issue がすべて閉じたものを含む)に足す道を選ばれたら、作り方を聞かずに follow_up で planner を通さず起票する"
},
"image": {
"title": "画像は generate_image",
"rule": "画像を頼まれたら、内容が足りなくても何も聞き返さずに generate_image を呼ぶ。足りない内容はカードのフォームで決めてもらう"
},
"help": {
"title": "何ができるかは show_help",
"rule": "何ができるか・使い方を聞かれたら、未登録の人にも show_help を呼んでその reply だけを返し(ヘルプはそのあとに投稿される)、自分で並べない"
Expand Down
9 changes: 9 additions & 0 deletions apps/agent/evals/conversation/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ export interface CaseIssue {
title?: string;
}

/** The chat platforms the thread of a case can be on. */
export const CASE_PLATFORMS = ["slack", "discord"] as const;

/** The statuses a booking of a case can be in. */
export const CASE_BOOKING_STATUSES = [
"awaiting_approval",
Expand Down Expand Up @@ -96,6 +99,8 @@ export interface CaseRelatedRequest {

/** The thread's state and the user's posts of a case. */
export interface CaseInput {
/** Where the thread is. Defaults to `slack`. */
platform?: (typeof CASE_PLATFORMS)[number];
/** Whether the author of the posts is registered. Defaults to `true`. */
registered?: boolean;
/** Whether the channel is bound to the case's repository (`acme/app`). Defaults to `true`. */
Expand Down Expand Up @@ -268,6 +273,10 @@ export function parseCase(id: string, raw: unknown, where = id): EvalCase {
if (!isObject(input)) {
return fail("input がありません");
}
const platforms: readonly unknown[] = CASE_PLATFORMS;
if (input.platform !== undefined && !platforms.includes(input.platform)) {
return fail(`input.platform は ${CASE_PLATFORMS.join(", ")} のどれかです`);
}
const files = input.files;
if (
files !== undefined &&
Expand Down
32 changes: 32 additions & 0 deletions apps/agent/evals/conversation/cases/im-discord-no-description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"aspect": "image",
"note": "Discord で何を描くかが無い頼みも、何も聞き返さずにカードを出す(運用で、カードを出さずにテイストや用途を聞いた)",
"input": {
"platform": "discord",
"posts": [
"画像生成したい"
]
},
"expect": {
"calls": [
{
"name": "generate_image",
"input": {
"description": {
"$absent": true
}
}
}
],
"reply": {
"excludes_any": [
"テイスト",
"用途",
"目的",
"画風",
"スタイル",
"サイズ"
]
}
}
}
31 changes: 31 additions & 0 deletions apps/agent/evals/conversation/cases/im-slack-no-description.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"aspect": "image",
"note": "フォームのある Slack では、何も聞き返さずにカードを出す",
"input": {
"posts": [
"画像生成したい"
]
},
"expect": {
"calls": [
{
"name": "generate_image",
"input": {
"description": {
"$absent": true
}
}
}
],
"reply": {
"excludes_any": [
"テイスト",
"用途",
"目的",
"画風",
"スタイル",
"サイズ"
]
}
}
}
57 changes: 49 additions & 8 deletions apps/agent/evals/conversation/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import { DecisionStore } from "../../src/decisions/store";
import { parentIssueBody } from "../../src/github/parent-issue";
import { HotPepperGourmet } from "../../src/hotpepper/gourmet";
import { fakeHotPepper } from "../../src/hotpepper/gourmet.test-helper";
import type { ImageGenerator } from "../../src/images/generators";
import { ImageRequestStore } from "../../src/images/store";
import { ThreadImageStore } from "../../src/images/thread-images";
import { QuestionDesk } from "../../src/questions/desk";
import { ThreadStore } from "../../src/questions/store";
import {
Expand Down Expand Up @@ -47,11 +50,27 @@ import type { CaseBooking, CaseInput, CaseRelatedRequest } from "./case";
/** The repository the case's channel is bound to and its request is filed in. */
export const CASE_REPO: RepoName = "acme/app";

const channel = { platform: "slack", channelId: "C0DEV" } as const;
const requester: ChatUser = { platform: "slack", userId: "U0ALICE" };
const outsider: ChatUser = { platform: "slack", userId: "U0MALLORY" };
const threadId = "slack:C0DEV:1700000000.000100";
const threadUrl = "https://acme.slack.com/archives/C0DEV/p1700000000000100";
const places = {
slack: {
channel: { platform: "slack", channelId: "C0DEV" },
requester,
outsider,
threadId,
threadUrl: "https://acme.slack.com/archives/C0DEV/p1700000000000100",
},
discord: {
channel: { platform: "discord", channelId: "1300000000000000000" },
requester: { platform: "discord", userId: "1500000000000000001" },
outsider: { platform: "discord", userId: "1500000000000000002" },
threadId:
"discord:1200000000000000000:1300000000000000000:1400000000000000000",
threadUrl:
"https://discord.com/channels/1200000000000000000/1400000000000000000",
},
} as const;
const otherThreadId = "slack:C0DEV:1690000000.000100";

/** A call a fake other than GitHub recorded instead of reaching an outside service. */
Expand All @@ -66,6 +85,7 @@ export interface FakeEffect {
| "issue_links"
| "errand"
| "rakuten"
| "image"
| "hotpepper";
call: string;
input: unknown;
Expand All @@ -89,9 +109,10 @@ export interface CaseFixture {

/**
* Builds the thread a case describes, over in-memory SQLite and fakes for GitHub, the materials, Notion, Google,
* the reminder schedule, errand and 楽天トラベル, so that no tool reaches anything outside the process.
* the reminder schedule, errand, 楽天トラベル and the image models, so that no tool reaches anything outside the process.
*
* The request is opened by `alice` on {@link CASE_REPO}; an unregistered case's posts come from another user.
* A `discord` case's turn is on Discord; its request and bookings stay those of `alice` on Slack.
* Questions are asked through `QuestionDesk.ask` and decisions recorded in the thread's `decisions`, as the
* planner's and the issue worker's results would. The request's parent issue and the case's issues are held by
* the fake GitHub, so read_tree, replan and amend_issue find them; every link a tool reads gives a material.
Expand All @@ -105,12 +126,14 @@ export async function caseFixture(
messages: MessagesClient,
model: ModelId,
): Promise<CaseFixture> {
const place = places[input.platform ?? "slack"];
const { db, sqlite } = fakeD1();
let time = Date.UTC(2026, 11, 1, 1, 0, 0);
const now = () => time++;
registerUsersIn(sqlite, [
{ platform: "slack", userId: "U0ALICE", githubLogin: "alice-gh" },
{ platform: "slack", userId: "U0BOB", githubLogin: "bob-gh" },
{ ...places.discord.requester, githubLogin: "alice-gh" },
]);
const users = new D1UserRegistry({ db, now });
const run = threadDatabase();
Expand Down Expand Up @@ -139,7 +162,7 @@ export async function caseFixture(
threadId,
locale,
});
const binding = { ...channel, repo: CASE_REPO };
const binding = { ...place.channel, repo: CASE_REPO };
const channels = new ConfigChannelResolver({
channels: input.channel_bound === false ? [] : [binding],
});
Expand Down Expand Up @@ -242,6 +265,12 @@ export async function caseFixture(
};
};
}
const generator: ImageGenerator = {
async generate(request) {
effects.push({ target: "image", call: "generate", input: request });
return { data: PNG, mimeType: "image/png" };
},
};
const deps: ConversationDeps = {
env: {} as Env,
messages,
Expand Down Expand Up @@ -351,17 +380,29 @@ export async function caseFixture(
bookings: fakeBookings(bookingStore, effects),
hotels: fakeHotels(effects, now),
restaurants: fakeRestaurants(effects),
images: {
generators: {
character: generator,
background: generator,
item: generator,
general: generator,
},
requests: new ImageRequestStore(run, now, locale),
images: new ThreadImageStore(run, now),
toEnglish: async (text) => text,
loadReference: async () => ({ data: PNG, mimeType: "image/png" }),
},
defaultModel: model,
now,
locale,
};
const author = input.registered === false ? outsider : requester;
const author = input.registered === false ? place.outsider : place.requester;
return {
conversation: new Conversation(deps),
turn: {
threadId,
threadUrl,
channel,
threadId: place.threadId,
threadUrl: place.threadUrl,
channel: place.channel,
user: author,
history: (input.history ?? []).map((entry) =>
entry.role === "agent"
Expand Down
Loading
Loading