Skip to content

Commit ebdee49

Browse files
authored
Merge pull request #209 from Scale3-Labs/release-6.3.5
Release 6.3.5
2 parents 9ef55b4 + 7a7ba04 commit ebdee49

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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",

src/examples/vertexai/basic.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import dotenv from 'dotenv'
33
import { VertexAI, FunctionDeclarationSchemaType } from '@google-cloud/vertexai'
44

55
dotenv.config()
6-
init({ batch: false, write_spans_to_console: false })
6+
init({ batch: false, write_spans_to_console: true })
77

88
const project = 'vertex-test-454100'
99
const location = 'us-central1'
@@ -13,6 +13,8 @@ const vertexAI = new VertexAI({ project, location })
1313

1414
const generativeModel = vertexAI.getGenerativeModel({ model: textModel })
1515

16+
const previewGenerationModel = vertexAI.preview.getGenerativeModel({ model: textModel })
17+
1618
const functionDeclarations = [
1719
{
1820
functionDeclarations: [
@@ -83,7 +85,7 @@ export const basicImageVertexAIChat = async (): Promise<void> => {
8385

8486
export 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

src/instrumentation/vertexai/instrumentation.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)