File tree Expand file tree Collapse file tree 4 files changed +36
-5
lines changed
Expand file tree Collapse file tree 4 files changed +36
-5
lines changed Original file line number Diff line number Diff line change 11# @langtrase/typescript-sdk
22
3+ ## 6.3.5
4+
5+ ### Patch Changes
6+
7+ - add support for ` sendMessage ` inside ` PreviewGenerativeModel ` vertexai
8+
39## 6.3.4
410
511### Patch Changes
12+
613- change startChat span name
714
815## 6.3.3
Original file line number Diff line number Diff line change 11{
22 "name" : " @langtrase/typescript-sdk" ,
3- "version" : " 6.3.4 " ,
3+ "version" : " 6.3.5 " ,
44 "description" : " A typescript SDK for Langtrace" ,
55 "main" : " dist/index.js" ,
66 "types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import dotenv from 'dotenv'
33import { VertexAI , FunctionDeclarationSchemaType } from '@google-cloud/vertexai'
44
55dotenv . config ( )
6- init ( { batch : false , write_spans_to_console : false } )
6+ init ( { batch : false , write_spans_to_console : true } )
77
88const project = 'vertex-test-454100'
99const location = 'us-central1'
@@ -13,6 +13,8 @@ const vertexAI = new VertexAI({ project, location })
1313
1414const generativeModel = vertexAI . getGenerativeModel ( { model : textModel } )
1515
16+ const previewGenerationModel = vertexAI . preview . getGenerativeModel ( { model : textModel } )
17+
1618const functionDeclarations = [
1719 {
1820 functionDeclarations : [
@@ -83,7 +85,7 @@ export const basicImageVertexAIChat = async (): Promise<void> => {
8385
8486export const basicVertexAIStartChat = async ( ) : Promise < void > => {
8587 try {
86- const chat = generativeModel . startChat ( )
88+ const chat = previewGenerationModel . startChat ( )
8789 const chatInput = 'capital of France?'
8890 const result = await chat . sendMessage ( chatInput )
8991 const response = result . response
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ class VertexAIInstrumentation extends InstrumentationBase<any> {
5959 startChatPatch (
6060 originalMethod ,
6161 this . tracer ,
62- APIS . vertexai . SEND_MESSAGE . METHOD ,
62+ APIS . vertexai . START_CHAT . METHOD ,
6363 this . instrumentationVersion ,
6464 name ,
6565 moduleVersion ,
@@ -70,7 +70,7 @@ class VertexAIInstrumentation extends InstrumentationBase<any> {
7070 startChatPatch (
7171 originalMethod ,
7272 this . tracer ,
73- APIS . vertexai . SEND_MESSAGE . METHOD ,
73+ APIS . vertexai . START_CHAT . METHOD ,
7474 this . instrumentationVersion ,
7575 name ,
7676 moduleVersion ,
@@ -148,6 +148,28 @@ class VertexAIInstrumentation extends InstrumentationBase<any> {
148148 moduleVersion ,
149149 ) ,
150150 )
151+
152+ this . _wrap ( vertexai . ChatSessionPreview . prototype , 'sendMessage' , ( originalMethod : ( ...args : any [ ] ) => any ) =>
153+ generateContentPatch (
154+ originalMethod ,
155+ this . tracer ,
156+ APIS . vertexai . SEND_MESSAGE . METHOD ,
157+ this . instrumentationVersion ,
158+ name ,
159+ moduleVersion ,
160+ ) ,
161+ )
162+
163+ this . _wrap ( vertexai . ChatSessionPreview . prototype , 'sendMessageStream' , ( originalMethod : ( ...args : any [ ] ) => any ) =>
164+ generateContentPatch (
165+ originalMethod ,
166+ this . tracer ,
167+ APIS . vertexai . SEND_MESSAGE_STREAM . METHOD ,
168+ this . instrumentationVersion ,
169+ name ,
170+ moduleVersion ,
171+ ) ,
172+ )
151173 }
152174
153175 private _unpatch ( vertexai : any ) : void {
You can’t perform that action at this time.
0 commit comments