-
Notifications
You must be signed in to change notification settings - Fork 877
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
feat: Add afterCompletion
callback option for runTools
to enable easily building multi-model / multi-agent flows
#1064
base: master
Are you sure you want to change the base?
Changes from 2 commits
60905f4
2d320db
048a4d4
8fceb31
e59654d
15852aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ export { | |
ParsingFunction, | ||
ParsingToolFunction, | ||
} from '../../../lib/RunnableFunction'; | ||
import { RunnerOptions } from '../../../lib/AbstractChatCompletionRunner'; | ||
import { ChatCompletionToolRunnerParams } from '../../../lib/ChatCompletionRunner'; | ||
export { ChatCompletionToolRunnerParams } from '../../../lib/ChatCompletionRunner'; | ||
import { ChatCompletionStreamingToolRunnerParams } from '../../../lib/ChatCompletionStreamingRunner'; | ||
|
@@ -119,19 +120,19 @@ export class Completions extends APIResource { | |
runTools< | ||
Params extends ChatCompletionToolRunnerParams<any>, | ||
ParsedT = ExtractParsedContentFromParams<Params>, | ||
>(body: Params, options?: Core.RequestOptions): ChatCompletionRunner<ParsedT>; | ||
>(body: Params, options?: RunnerOptions): ChatCompletionRunner<ParsedT>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This type has been wrong such that it causes a TS error when you try to pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah thanks for fixing! No the generator will leave this change in :) Would you mind opening a separate PR with this change so we can get it merged faster? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call! Will update now... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
runTools< | ||
Params extends ChatCompletionStreamingToolRunnerParams<any>, | ||
ParsedT = ExtractParsedContentFromParams<Params>, | ||
>(body: Params, options?: Core.RequestOptions): ChatCompletionStreamingRunner<ParsedT>; | ||
>(body: Params, options?: RunnerOptions): ChatCompletionStreamingRunner<ParsedT>; | ||
|
||
runTools< | ||
Params extends ChatCompletionToolRunnerParams<any> | ChatCompletionStreamingToolRunnerParams<any>, | ||
ParsedT = ExtractParsedContentFromParams<Params>, | ||
>( | ||
body: Params, | ||
options?: Core.RequestOptions, | ||
options?: RunnerOptions, | ||
): ChatCompletionRunner<ParsedT> | ChatCompletionStreamingRunner<ParsedT> { | ||
if (body.stream) { | ||
return ChatCompletionStreamingRunner.runTools( | ||
|
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.
I know this is just an example, but I think we'd want this to be an assistant message also
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.
Actually, I'm a bit unclear on this: I've been using
system
for these kinds of messages where I "inject" important context or attempt to give the model a strong nudge to go in a different direction or update its instructions partway through a chat, and that seems to work well for me. (I also display allassistant
messages in my FE by default and wouldn't want to display this message, but I could find a way around that if needed.) Could I potentially get better results in such cases by using theassistant
role and changing up how I word the message content accordingly? I'm consistently getting the model to respond intelligently to inline web research using my current approach, but I'm curious and honestly I've probably neglected theassistant
role a bit when it comes to manually inserted messages!