Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutgon committed Jan 13, 2025
1 parent 2899bd9 commit 962fe63
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 55 deletions.
1 change: 0 additions & 1 deletion packages/constants/src/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export enum ChainEventTypes {
Step = 'chain-step',
Complete = 'chain-complete',
StepComplete = 'chain-step-complete',
ToolsCalled = 'chain-tool-call',
}

export type ProviderData =
Expand Down
47 changes: 0 additions & 47 deletions packages/core/src/services/chains/ChainStreamConsumer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,39 +125,6 @@ export class ChainStreamConsumer {
controller.close()
}

static toolsCalled({
response,
config,
controller,
}: {
controller: ReadableStreamDefaultController
response: ChainStepResponse<StreamType>
config: Config
}) {
const content = parseResponseText(response)

enqueueChainEvent(controller, {
event: StreamEventTypes.Latitude,
data: {
type: ChainEventTypes.ToolsCalled,
config,
documentLogUuid: response.documentLogUuid,
response,
messages: [
{
role: MessageRole.assistant,
toolCalls:
response.streamType === 'text' ? response.toolCalls || [] : [],
// Review after rebase with alex's fixes
content,
},
],
},
})

controller.close()
}

static chainError({
controller,
e,
Expand Down Expand Up @@ -240,20 +207,6 @@ export class ChainStreamConsumer {
})
}

toolsCalled({
step,
response,
}: {
step: ValidatedStep
response: ChainStepResponse<StreamType>
}) {
ChainStreamConsumer.toolsCalled({
controller: this.controller,
response,
config: step.conversation.config as Config,
})
}

chainError(e: unknown) {
return ChainStreamConsumer.chainError({
controller: this.controller,
Expand Down
10 changes: 3 additions & 7 deletions packages/core/src/services/chains/buildStep/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,17 @@ export async function buildStepExecution({
const toolCalls = getToolCalls({ response: finalResponse })
const hasTools = isPromptl && toolCalls.length > 0

if (isPromptl && toolCalls.length > 0) {
if (hasTools) {
await cacheChain({ workspace, chain, documentLogUuid, toolCalls })
streamConsumer.toolsCalled({
step,
response: finalResponse,
})

return finalResponse
}

// Instead of ChainCompleted emit chain completed with stop reason tool-call
if (step.chainCompleted || hasTools) {
streamConsumer.chainCompleted({
step,
response: finalResponse,
// TODO: Add this
finishReason
})

return finalResponse
Expand Down

0 comments on commit 962fe63

Please sign in to comment.