Comparing version 0.1.0 to 0.2.0
48
api.js
@@ -205,2 +205,48 @@ const config = require("./config.js"); | ||
async function embedImage(filepath, apiKey) { | ||
const image = fs.readFileSync(filepath, { | ||
encoding: "base64" | ||
}); | ||
const response = await axios({ | ||
method: "POST", | ||
url: `${config.get("RF_CLIP_URL")}/embed_image`, | ||
params: { | ||
api_key: apiKey | ||
}, | ||
data: { | ||
clip_version_id: "ViT-B-16", | ||
image: [ | ||
{ | ||
type: "base64", | ||
value: image | ||
} | ||
] | ||
}, | ||
headers: { | ||
"Content-Type": "application/json" | ||
} | ||
}); | ||
return response.data; | ||
} | ||
async function embedText(text, apiKey) { | ||
const response = await axios({ | ||
method: "POST", | ||
url: `${config.get("RF_CLIP_URL")}/embed_text`, | ||
params: { | ||
api_key: apiKey | ||
}, | ||
data: { | ||
clip_version_id: "ViT-B-16", | ||
text: text | ||
}, | ||
headers: { | ||
"Content-Type": "application/json" | ||
} | ||
}); | ||
return response.data; | ||
} | ||
module.exports = api = { | ||
@@ -217,3 +263,5 @@ getWorkspace, | ||
semanticSegmentation, | ||
embedImage, | ||
embedText, | ||
uploadAnnotationRaw | ||
}; |
@@ -15,3 +15,4 @@ const Conf = require("conf"); | ||
RF_INSTANCE_SEGMENTATION_URL: "https://outline.roboflow.com", | ||
RF_SEMANTIC_SEGMENTATION_URL: "https://segment.roboflow.com" | ||
RF_SEMANTIC_SEGMENTATION_URL: "https://segment.roboflow.com", | ||
RF_CLIP_URL: "https://infer.roboflow.com/clip" | ||
}; | ||
@@ -60,2 +61,6 @@ | ||
"https://segment.roboflow.com" | ||
), | ||
RF_CLIP_URL: getCascadingConfigValue( | ||
"RF_CLIP_URL", | ||
"https://infer.roboflow.com/clip" | ||
) | ||
@@ -62,0 +67,0 @@ }; |
{ | ||
"name": "roboflow", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Roboflow.com node module", | ||
@@ -11,6 +11,6 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/roboflow-ai/roboflow-node.git" | ||
"url": "git+https://github.com/roboflow/roboflow-node.git" | ||
}, | ||
"dependencies": { | ||
"axios": "^0.27.2", | ||
"axios": "^0.27.2", | ||
"conf": "^10.2.0", | ||
@@ -21,3 +21,4 @@ "form-data": "^4.0.0", | ||
"devDependencies": { | ||
"jest": "^29.2.2", | ||
"dotenv": "^16.3.1", | ||
"jest": "^29.6.1", | ||
"prettier": "^2.7.1" | ||
@@ -34,5 +35,5 @@ }, | ||
"bugs": { | ||
"url": "https://github.com/roboflow-ai/roboflow-node/issues" | ||
"url": "https://github.com/roboflow/roboflow-node/issues" | ||
}, | ||
"homepage": "https://github.com/roboflow-ai/roboflow-node#readme" | ||
"homepage": "https://github.com/roboflow/roboflow-node#readme" | ||
} |
# Roboflow node library | ||
Roboflow makes computer vision accessible to all developers. | ||
[https://roboflow.ai](https://roboflow.ai) | ||
[https://roboflow.com](https://roboflow.com) | ||
@@ -30,1 +30,12 @@ **This project is under active development, use at your own risk** | ||
- `semanticSegmentation(filepath, modelUrl, apiKey)` | ||
- `embedImage(filepath, apiKey)` | ||
- `embedText(text, apiKey)` | ||
## Development | ||
### Testing | ||
The repo includes a series of `jest` tests to make sure the api wrapper functions work as expected. To run the tests you must setup a `.env` file with the following variables and run `npm run test`: | ||
- `apiKey` a valid roboflow api key | ||
- `workspace` a valid roboflow workspace which can be accessed with the given `apiKey` | ||
- `project` a valid roboflow project within the given `workspace` | ||
- `version` a valid version of the given roboflow project which has a model trained | ||
- `testImage` the relative path to a test image inside the `__tests__` directory such as `test.jpeg` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
21334
10
351
40
3
9