Skip to content

feat: add AI response content monitoring service #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

EndlessJour9527
Copy link
Collaborator

No description provided.

殷健华 added 3 commits June 16, 2025 23:50
- Rename TaskDecomposer.ts to taskDecomposer.ts to match import statement
- Fix TypeScript compilation error TS1261 about case-sensitive file naming
Copy link
Collaborator

@yorkie yorkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

从要统计的数据来看,应该是一个 call graph/tree,从设计的数据结构上并没有体现 graph/tree 的结构,需要重新设计下。

@yorkie
Copy link
Collaborator

yorkie commented Jun 17, 2025

另外,从最终统计的数据,并没有针对间隔的 DOM 操作的时间间隔进行统计

Copy link
Collaborator

@yorkie yorkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,还需要在对应的文档中简单补充下如果可以获取 trace 后的日志

export type SpanContext = TraceOptions & {
name: string,
traceType: TraceType,
metadata?: Record<string, any>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 any 能否定义出类型?

metadata?: Record<string, any>
};

export class TaskFlowSpan implements Span {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么 Span 是 Interface,startTime 和 endTime 相关的逻辑都应该实现在 Span,而 TaskFlowSpan 只需要和 TaskFlow 直接相关的部分。

this.start();
}

public metric(key: string, value: any) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个函数是做什么的?

this.errorInfo = err;
}

public start() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

start 不需要 public 吧?

this.metrics[key] = value;
}

public error(err: Error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public error(err: Error) {
public reportError(err: Error) {


export class TaskFlowSpan implements Span {
public metrics: Record<string, any> = {};
public errorInfo: Error | null = null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是否要考虑是 errors 而不是一个,因为在一段时间内,可以报多个错误

}
}

public addTimePointId(timePointId: string) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

现在 Timepoint 和 Span 的关系到底是怎么样的呢?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉可以 Span 的 startTime/endTime 变成 startPoint/endPoint

time: number;
id: string;
referenceId: string;
static counter: number = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static counter: number = 0;
static Counter: number = 0;

静态成员需要大写

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,这个是内部使用,需要使用 private

this.type = options.type;
this.time = options.time;
this.referenceId = options.requestId;
this.id = (TimePoint.counter++).toString();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 id 可以直接使用 number 就好


interface CallNode {
requestId: string;
TaskFlowSpan: TaskFlowSpan[];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
TaskFlowSpan: TaskFlowSpan[];
span: TaskFlowSpan[];

另外,CallNode 应该直接依赖 Span 吧?还有这里为什么是一个数组?

children: CallNode[];
}
export class TraceManager {
#callGragh: CallNode[] = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#callGragh: CallNode[] = [];
#callGraghs: CallNode[] = [];

这里一个 callGraph 代表的是一次 call 吧?

* define the trace options
*/
export type TraceOptions = {
requestId?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

request 是 trace 的概念还是 generate-html 内的概念呢?

* @description
* TraceGenerateDomType is a subset of TraceType.
* */
export type TraceType = TraceGenerateDomType;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

全局的 TraceType 需要和 GenerateDom 解藕

try {
for await (const sourceChunk of sourceStream) {
if (sourceChunk.type === 'text') {
for (const processedLine of jsonlProcessor.processChunk(sourceChunk.text)) {
if (isDebugging) {
reportThreepioInfo('Processing text chunk', sourceChunk.text, 'requestId', requestId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里需要明确来自外部输入

殷健华 added 2 commits June 27, 2025 18:00
context: SpanContext,
};

export class SpanImp implements Span {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么不直接实现 Span?

startTime: this.startPoint,
endTime: this.endPoint,
errorInfo: this.errorInfo,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
};

time: this.time,
id: this.id,
referenceId: this.referenceId,
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
};

parentRequestId: input,
requestId: input,
plannerParser: new StreamPlannerParser()
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
})
});

}, async (span) => {
span.setAttributes({ systemPrompt, ...plannerParam });
await this.#processPlannerStream({ requestId, parentRequestId: input, ...plannerParam }, plannerItemStream);
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
})
});

fragmentType: FragmentType; // Type of fragment to generate
moudle: ParsedModule; // Module information
input: string,
systemPrompt: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
systemPrompt: string
systemPrompt: string,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants