Skip to content

Commit 6f6642b

Browse files
committed
wip
1 parent 2348100 commit 6f6642b

3 files changed

Lines changed: 20 additions & 20 deletions

File tree

src/contract/OutlineCompletion.contract.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
import { IBaseMessage } from "./BaseMessage.contract";
21
import { IBaseCompletionArgs } from "./BaseCompletion.contract";
32
import { OutlineName, IOutlineFormat } from "../interfaces/Outline.interface";
4-
import { OutlineMessageRole } from "./OutlineMessage.contract";
3+
import { IOutlineMessage, OutlineMessageRole } from "./OutlineMessage.contract";
54

65
/**
76
* Interface representing the arguments for outline (JSON) completions.
87
* Extends base completion args with outline-specific fields for structured JSON output.
98
* Used for completions that return data conforming to a predefined schema.
10-
* @template Message - The type of message, extending IBaseMessage with any role type. Defaults to IBaseMessage with string role.
119
* @interface IOutlineCompletionArgs
1210
*/
13-
export interface IOutlineCompletionArgs<
14-
Message extends IBaseMessage<any> = IBaseMessage<OutlineMessageRole>
15-
> extends IBaseCompletionArgs<Message> {
11+
export interface IOutlineCompletionArgs extends IBaseCompletionArgs<IOutlineMessage> {
1612
/**
1713
* The outline schema name (required).
1814
* Defines the structure of the expected JSON response.

src/contract/SwarmCompletion.contract.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
import { IBaseMessage } from "./BaseMessage.contract";
21
import { IBaseCompletionArgs } from "./BaseCompletion.contract";
32
import { AgentName } from "../interfaces/Agent.interface";
43
import { ITool } from "../model/Tool.model";
5-
import { SwarmMessageRole } from "./SwarmMessage.contract";
4+
import { ISwarmMessage, SwarmMessageRole } from "./SwarmMessage.contract";
65
import { ExecutionMode } from "../interfaces/Session.interface";
76

87
/**
98
* Interface representing the arguments for swarm (chat) completions.
109
* Extends base completion args with swarm-specific fields for agent-based interactions.
1110
* Used for agent completions with tool support, client tracking, and multi-agent context.
12-
* @template Message - The type of message, extending IBaseMessage with any role type. Defaults to IBaseMessage with string role.
1311
* @interface ISwarmCompletionArgs
1412
*/
15-
export interface ISwarmCompletionArgs<
16-
Message extends IBaseMessage<any> = IBaseMessage<SwarmMessageRole>
17-
> extends IBaseCompletionArgs<Message> {
13+
export interface ISwarmCompletionArgs extends IBaseCompletionArgs<ISwarmMessage> {
1814
/**
1915
* The agent name (required).
2016
* Identifies the agent context for the completion.

src/interfaces/Completion.interface.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { IBaseMessage } from "../contract/BaseMessage.contract";
22
import { IBaseCompletionArgs } from "../contract/BaseCompletion.contract";
33
import { addCompletion } from "../functions/setup/addCompletion";
4-
import { ISwarmCompletionArgs } from "../contract/SwarmCompletion.contract";
54
import { ISwarmMessage } from "../contract/SwarmMessage.contract";
65
import { IOutlineCompletionArgs } from "../contract/OutlineCompletion.contract";
6+
import { ISwarmCompletionArgs } from "src/contract/SwarmCompletion.contract";
77

88
/**
99
* Interface representing a completion mechanism.
@@ -29,8 +29,12 @@ export interface ICompletionCallbacks<Message extends IBaseMessage<any> = IBaseM
2929
* Interface representing the schema for configuring a completion mechanism.
3030
* Defines how completions are generated within the swarm.
3131
* @template Message - The type of message, extending IBaseMessage with any role type. Defaults to IBaseMessage for maximum flexibility.
32+
* @template Args - The type of completion arguments, defaults to any completion args type.
3233
*/
33-
export interface ICompletionSchema<Message extends IBaseMessage<string> = IBaseMessage<any>> {
34+
export interface ICompletionSchema<
35+
Message extends IBaseMessage<string> = IBaseMessage<any>,
36+
Args extends IBaseCompletionArgs<IBaseMessage<string>> = IBaseCompletionArgs<IBaseMessage<string>>
37+
> {
3438
/** The unique name of the completion mechanism within the swarm.*/
3539
completionName: CompletionName;
3640

@@ -39,12 +43,7 @@ export interface ICompletionSchema<Message extends IBaseMessage<string> = IBaseM
3943
* Generates a model response using the given context and tools.
4044
* @throws {Error} If completion generation fails (e.g., due to invalid arguments, model errors, or tool issues).
4145
*/
42-
getCompletion(
43-
args:
44-
| IBaseCompletionArgs<IBaseMessage<string>>
45-
| IOutlineCompletionArgs<IBaseMessage<string>>
46-
| ISwarmCompletionArgs<IBaseMessage<string>>
47-
): Promise<Message>;
46+
getCompletion(args: Args): Promise<Message>;
4847

4948
/*
5049
* Flag if the completion is a JSON completion.
@@ -65,3 +64,12 @@ export interface ICompletionSchema<Message extends IBaseMessage<string> = IBaseM
6564
* Used to identify and reference specific completion implementations.
6665
*/
6766
export type CompletionName = string;
67+
68+
69+
addCompletion({
70+
completionName: "test",
71+
getCompletion: async (params: ISwarmCompletionArgs): Promise<ISwarmMessage> => {
72+
params.messages[0].role === "assistant"
73+
return null as never;
74+
}
75+
})

0 commit comments

Comments
 (0)