-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(adapters): add VertexAI examples
Ref: #141 Signed-off-by: Tomas Dvorak <[email protected]>
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import "dotenv/config.js"; | ||
import { BaseMessage } from "bee-agent-framework/llms/primitives/message"; | ||
import { VertexAILLM } from "bee-agent-framework/adapters/vertexai/llm"; | ||
import { VertexAIChatLLM } from "bee-agent-framework/adapters/vertexai/chat"; | ||
|
||
const project = process.env.GCP_VERTEXAI_PROJECT; | ||
const location = process.env.GCP_VERTEXAI_LOCATION; | ||
|
||
if (!project || !location) { | ||
throw new Error("No ENVs has been set!"); | ||
} | ||
|
||
{ | ||
console.info("===RAW==="); | ||
const llm = new VertexAILLM({ | ||
modelId: "gemini-1.5-flash-001", | ||
project, | ||
location, | ||
parameters: {}, | ||
}); | ||
|
||
console.info("Meta", await llm.meta()); | ||
|
||
const response = await llm.generate("Hello world!", { | ||
stream: true, | ||
}); | ||
console.info(response.getTextContent()); | ||
} | ||
|
||
{ | ||
console.info("===CHAT==="); | ||
const llm = new VertexAIChatLLM({ | ||
modelId: "gemini-1.5-flash-001", | ||
project, | ||
location, | ||
}); | ||
|
||
console.info("Meta", await llm.meta()); | ||
|
||
const response = await llm.generate([ | ||
BaseMessage.of({ | ||
role: "user", | ||
text: "Hello world!", | ||
}), | ||
]); | ||
console.info(response.getTextContent()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters