The PORT to access director endpoints is 8501.
JavaScript SDK Setup
Install SDK from npm
npm install view-sdk
Initialize Configuration Sdk
import { ViewDirectorSdk } from "view-sdk";
const director = new ViewDirectorSdk(
"00000000-0000-0000-0000-000000000000", //tenant Id
"default", //access token
"http://localhost:8501/" //endpoint
);
Python setup
Install SDK from pip
pip install view-sdk
Initialize Configuration Sdk
import view_sdk
from view_sdk import director
sdk = view_sdk.configure( access_key="default",base_url="localhost", tenant_guid= "00000000-0000-0000-0000-000000000000")
List Connections
To list connections call GET /v1.0/connections
curl --location --request GET 'http://view.homedns.org:8501/v1.0/connections' \
--header 'Content-Type: application/json' \
--header 'x-token: *******' \
'
import { ViewDirectorSdk } from "view-sdk";
const director = new ViewDirectorSdk(
"00000000-0000-0000-0000-000000000000", //tenant Id
"default", //access token
"http://localhost:8501/" //endpoint
);
director.accessToken = "******";
const listConnections = async () => {
try {
const response = await director.retrieveConnections();
console.log(response);
} catch (error) {
console.error("Error listing connections:", error);
}
};
listConnections();
import view_sdk
from view_sdk import director
sdk = view_sdk.configure( access_key="default",base_url="localhost", tenant_guid= "00000000-0000-0000-0000-000000000000")
def listConnections():
result = director.Connections.retrieve_all("******")
print(result)
listConnections()
Generate Embeddings
To generate embeddings call GET /v1.0/tenants/[tenant-guid]/embeddings/
curl --location 'http://view.homedns.org:8501/v1.0/tenants/00000000-0000-0000-0000-000000000000/embeddings/' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"Model": "all-MiniLM-L6-v2",
"ApiKey": "",
"Contents": [
"This is a sample chunk of text, hello!",
"Oh wow, here'\''s another chunk of text",
"And yet again, a third chunk of text"
]
}'
import { ViewDirectorSdk } from "view-sdk";
const director = new ViewDirectorSdk(
"00000000-0000-0000-0000-000000000000", //tenant Id
"default", //access token
"http://localhost:8501/" //endpoint
);
const generateEmbedding = async () => {
try {
const response = await director.generateEmbedding({
Model: "all-MiniLM-L6-v2",
ApiKey: "",
Contents: ["This is a sample chunk of text, hello!"],
});
console.log(response);
} catch (error) {
console.error("Error generating embedding:", error);
}
};
generateEmbedding();
import view_sdk
from view_sdk import director
sdk = view_sdk.configure( access_key="default",base_url="localhost", tenant_guid= "00000000-0000-0000-0000-000000000000")
def generateEmbeddings():
result = director.GenerateEmbeddings.create(
Model= "all-MiniLM-L6-v2",
ApiKey= "",
Contents= [
"This is a sample chunk of text, hello!",
"Oh wow, here's another chunk of text",
"And yet again, a third chunk of text"
]
)
print(result)
generateEmbeddings()