cloud-pc-templates-sdk
v3.7.0
Published
<img width="1565" height="557" alt="image" src="https://github.com/user-attachments/assets/2f864b40-89ff-41ef-8e20-70f376102830" />
Readme
cloud-pc-templates-sdk to interact with the running login modes, vectordb and agents
Steps:
- Launch a login mode:
npx cloud-pc-templates ai login loginMode ollamalocal- Create a new project and install the dependency
mkdir new-app
cd new-app
npm init -y
npm install cloud-pc-templates-sdk- Then implement the code in index.js
let { Sdk } = require("cloud-pc-templates-sdk");
async function main() {
let sdk = new Sdk("ollamalocal");
let response = await sdk.chat("Hello");
console.log(response);
}
main();or for streaming
let { Sdk } = require("cloud-pc-templates-sdk");
async function main() {
let sdk = new Sdk("ollamalocal");
await sdk.chat("Hello",null,(token) => {
process.stdout.write(token);
});
}
main();The second argument for sdk.chat() is model id passing that null takes the first model from the list of model returned by the login mode.
For vector db use below steps
- Start vector db
npx cloud-pc-templates@latest ai agents startVectorDb- Create new app add dependency
mkdir new-app
cd new-app
npm init -y
npm install cloud-pc-templates-sdk- create index.js with below content
let { Sdk } = require("cloud-pc-templates-sdk");
async function main() {
let sdk = new Sdk("ollamalocal");
let response1 = await sdk.getVectorDbApiDocSuggestion("Create a java application");
console.log("vector db suggestion",response1);
let response2 = await sdk.getVectorDbApiDocSuggestion("Create a java application","text");
console.log("vector db suggestion text",response2);
}
main();For agents use the following
- Start all agents
npx cloud-pc-templates ai agents startAllOn linuxor for windows
npx cloud-pc-templates@latest ai agents startAllOn docker- Create new app add dependency
mkdir new-app
cd new-app
npm init -y
npm install cloud-pc-templates-sdk- create agents.js with below content and run
let { Sdk } = require("cloud-pc-templates-sdk");
async function main() {
let sdk = new Sdk("ollamalocal");
let health = await sdk.getAllAgents().healthcheck();
console.log("Agents Health", health);
let agent = sdk.getAgentById('web-explorer');
let apiDoc = await agent.getApiDoc();
console.log("Agent API Doc", apiDoc);
let agentApiHitInsights = await agent.getApiHitInsights();
console.log("Agent API Insights", agentApiHitInsights);
}
main();output:
Added 'sdk.callAgent' to call an agent with a prompt, the first argument here is the model-id and second one is the prompt. Model ids can be found in agents.mjs
Steps:
- Start any loginmode, e.g. ollamacloud
npx cloud-pc-templates ai login loginMode ollamacloud - Start all agents
Or for windows, run the belownpm cloud-pc-templates ai agents startAllOn linuxnpm cloud-pc-templates ai agents startAllOn docker - Start the vector db
npx cloud-pc-templates ai agents startVectorDb - create a new app and in it create an agentcall.js like below
File content:mkdir new-app cd new-app npm init -y npm install cloud-pc-templates-sdklet { Sdk } = require("cloud-pc-templates-sdk"); async function main() { let sdk = new Sdk("ollamacloud"); sdk.setSelectedModel("gpt-oss:120b"); let agentResponse = await sdk.callAgent( 'playwright connector', 'Go to https://cloud-pc-templates.com/ and tell me what all you see' ); console.log(agentResponse); } main();
Sample output:
Latest addition is orchestrator api(chatAgentMode function), try it with steps below:
mkdir new-app
cd new-app
npm init -y
npm install cloud-pc-templates-sdkFile content:
llet { Sdk } = require("cloud-pc-templates-sdk");
async function main() {
let sdk = new Sdk("ollamacloud");
sdk.setSelectedModel('gpt-oss:120b');
let response = await sdk.chatAgentMode("create an spring java project with test apis",(whatIsBeingDone)=>{
console.log("I am asking the agent to ",whatIsBeingDone);
});
console.log(response);
let history = sdk.getChatHistory();
console.log(history);
}
main();