File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed
Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " langsmith" ,
3- "version" : " 0.3.58 " ,
3+ "version" : " 0.3.59 " ,
44 "description" : " Client library to connect to the LangSmith LLM Tracing and Evaluation Platform." ,
55 "packageManager" : " yarn@1.22.19" ,
66 "files" : [
Original file line number Diff line number Diff line change @@ -186,6 +186,20 @@ export function LangSmithMiddleware(config?: {
186186 const chunks : LanguageModelV2StreamPart [ ] = [ ] ;
187187 const transformStream = new TransformStream ( {
188188 async transform ( chunk : LanguageModelV2StreamPart , controller ) {
189+ if (
190+ chunk . type === "tool-input-start" ||
191+ chunk . type === "text-start"
192+ ) {
193+ // Only necessary to log the first token event
194+ if (
195+ runTree ?. events == null ||
196+ ( Array . isArray ( runTree . events ) && runTree . events . length === 0 )
197+ ) {
198+ runTree ?. addEvent ( { name : "new_token" } ) ;
199+ }
200+ } else if ( chunk . type === "finish" ) {
201+ runTree ?. addEvent ( { name : "end" } ) ;
202+ }
189203 chunks . push ( chunk ) ;
190204 controller . enqueue ( chunk ) ;
191205 } ,
Original file line number Diff line number Diff line change @@ -20,4 +20,4 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
2020export { getDefaultProjectName } from "./utils/project.js" ;
2121
2222// Update using yarn bump-version
23- export const __version__ = "0.3.58 " ;
23+ export const __version__ = "0.3.59 " ;
You can’t perform that action at this time.
0 commit comments