-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Conversation
- Rename TaskDecomposer.ts to taskDecomposer.ts to match import statement - Fix TypeScript compilation error TS1261 about case-sensitive file naming
There was a problem hiding this 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 的结构,需要重新设计下。
lib/runtime2/threepio/capabilities/generate-domcument/RequestFlowManager.ts
Outdated
Show resolved
Hide resolved
lib/runtime2/threepio/capabilities/generate-domcument/RequestFlowManager.ts
Outdated
Show resolved
Hide resolved
另外,从最终统计的数据,并没有针对间隔的 DOM 操作的时间间隔进行统计 |
There was a problem hiding this 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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 any 能否定义出类型?
lib/runtime2/threepio/capabilities/generate-domcument/parsers/interface.ts
Outdated
Show resolved
Hide resolved
metadata?: Record<string, any> | ||
}; | ||
|
||
export class TaskFlowSpan implements Span { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public error(err: Error) { | |
public reportError(err: Error) { |
|
||
export class TaskFlowSpan implements Span { | ||
public metrics: Record<string, any> = {}; | ||
public errorInfo: Error | null = null; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在 Timepoint 和 Span 的关系到底是怎么样的呢?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static counter: number = 0; | |
static Counter: number = 0; |
静态成员需要大写
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TaskFlowSpan: TaskFlowSpan[]; | |
span: TaskFlowSpan[]; |
另外,CallNode 应该直接依赖 Span 吧?还有这里为什么是一个数组?
children: CallNode[]; | ||
} | ||
export class TraceManager { | ||
#callGragh: CallNode[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#callGragh: CallNode[] = []; | |
#callGraghs: CallNode[] = []; |
这里一个 callGraph 代表的是一次 call 吧?
* define the trace options | ||
*/ | ||
export type TraceOptions = { | ||
requestId?: string; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里需要明确来自外部输入
lib/runtime2/threepio/trace/Span.ts
Outdated
context: SpanContext, | ||
}; | ||
|
||
export class SpanImp implements Span { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么不直接实现 Span?
lib/runtime2/threepio/trace/Span.ts
Outdated
startTime: this.startPoint, | ||
endTime: this.endPoint, | ||
errorInfo: this.errorInfo, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
}; |
time: this.time, | ||
id: this.id, | ||
referenceId: this.referenceId, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
}; |
parentRequestId: input, | ||
requestId: input, | ||
plannerParser: new StreamPlannerParser() | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}) | |
}); |
}, async (span) => { | ||
span.setAttributes({ systemPrompt, ...plannerParam }); | ||
await this.#processPlannerStream({ requestId, parentRequestId: input, ...plannerParam }, plannerItemStream); | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}) | |
}); |
fragmentType: FragmentType; // Type of fragment to generate | ||
moudle: ParsedModule; // Module information | ||
input: string, | ||
systemPrompt: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
systemPrompt: string | |
systemPrompt: string, |
No description provided.