clarifai / clarifai-javascript Goto Github PK
View Code? Open in Web Editor NEWOfficial Clarifai JavaScript client for browsers and node.js
Home Page: https://docs.clarifai.com
License: Other
Official Clarifai JavaScript client for browsers and node.js
Home Page: https://docs.clarifai.com
License: Other
Used React js for sending request.
app.models
.predict(
Clarifai.DEMOGRAPHICS_MODEL,
this.state.input)
.then(response => console.log(response))
.catch(err => console.log(err))
The above code work correctly with FACE_DETECT_MODEL.
hi,
using require('clarifai');
throw an exception
/home/ubuntu/workspace/node_modules/clarifai/index.js:1
(function (exports, require, module, __filename, __dirname) { let App = require('./src/App');
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/ubuntu/workspace/service/image_moderation.js:3:16)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at /home/ubuntu/workspace/service/index.js:15:27
at Array.forEach (native)
i try to use Clarifai in my react project .
const app = new Clarifai.App({
apiKey: "af5a54585af246268c4c47d1cb9bf816",
});
app.models.predicct(Clarifai.FACE_DETECT_MODEL, this.state.input).then(
function (response) {
console.log(response);
},
function (error) {}
);
i got error : Uncaught ReferenceError: process is not defined
Hi guys.
We use Clarifai 2.2.0 in our project:
{
...
"dependencies": {
...
"clarifai": "^2.2.0",
...
}
}
Today we noticed that version 2.3.0 released.
And immediately there was an error:
Error: Can't find npm module 'clarifai'. Did you forget to call 'Npm.depends' in package.js within the 'modules-runtime' package?
We also noticed that there is no dist
folder in node_modules:
I want to get all workflows in current app, but the app.workflow
not provide query.
I grab the req and res, the curl data:
curl -X GET \
https://api.clarifai.com/v2/users/{}/apps/{}/workflows \
-H 'Cache-Control: no-cache' \
-H 'authorization: Key {}' \
"isURLSameOrigin.js" file from axios throws error urlParsingNode.setAttribute is undefined
. where i found this suspicious looking code.
var urlParsingNode = document.createElement('a');
Hi,
I installed clarify with npm install clarifai
.
However I get the following error in my project.
TypeError: clarifai__WEBPACK_IMPORTED_MODULE_8___default.a.app is not a constructor
I am on a windows 10 pro intel machine.
I tried putting curly brackets import {Clarifai} from 'clarifai'
, I get an app error.
I tried const Clarifai = require('clarifai');
, I get the same webpack error.
Any idea how I can solve this issue?
Thanks
When updating modules developers need to quickly assess the impact.
Hello,
Could you please add it to npm?
Thanks
Juliej
Just this morning clarifai stopped working for me (specific error was "cannot find module 'clarifai' at ...")
I tried deleting/re-npm-installing my node_modules; same issue; I switched my package.json to install 2.1.6 instead of ^2.1.6 and now everything works again.
So I think something is not quite right with your recent 2.1.7 release.
I cannot progress with the creation of my React app because the declaration file is not downloading with the package. I tried 'npm install @types/clarifai' but it said that the latest wasn't available which was confusing.
I tried redoing the entire app to make sure but I am having the same issue. It is not installing with everything else or cannot be found by my text editor.
Why would it not be installing and what can I do to resolve this issue?
I wrote a little consumer for the clarifai
API that utilizes this library. Unfortunately, whenever I try to use it, it crashes with a red screen:
The client looks like this (currently, which resulted in the red screen, with no implementation):
import Clarifai from "clarifai";
const clarifai = new Clarifai.App(
"client_id",
"client_secret",
);
export const verifyPhotoBytes = (base64Photo, tags) => {
console.log("Verifying bytes");
return Promise.resolve("Hey");
// return clarifai.inputs
// .create({
// base64: base64Photo,
// })
// .then(
// response => {
// console.log(response);
// },
// error => {
// console.log(error);
// },
// );
};
The crash seems to happen if I try to create a new instance of Clarifai.App
. I'm on version 2.1.8
using yarn 0.24.6
When i add clarifai in my angular project give me the this error
index.js:8 Uncaught ReferenceError: global is not defined at Object../node_modules/clarifai/dist/index.js (index.js:8) at webpack_require (bootstrap:78) at Module../src/app/home/home.component.ts (main.js:231) at webpack_require (bootstrap:78) at Module../src/app/app.module.ts (app.component.ts:8) at webpack_require (bootstrap:78) at Module../src/main.ts (main.ts:1) at webpack_require (bootstrap:78) at Object.0 (main.ts:12) at webpack_require (bootstrap:78)
i try clarifai version: 2.9.0 , 2.0.9
ionic project's error =>
cannot read property 'App' of undefined
I tried to define it in various ways but allways different error.
How can i use clarifa in ionic project ?? pls help me
Hello. I am so glad to use your amazing service in Korea.
I have adapted your api to my humanoid robot's vision system.
I have changed the default language english to korean, but results from javascript api have shown just english. How can I resolve this problem?
I have an issue in which the first image or two URL address is not accepted and I am met with the following:
Failed to load resource: the server responded with a status of 400 (Bad Request)
When I click on the link provided, it leads to a page with this on a single line.
{"status":{"code":11103,"description":"Method not allowed","details":"Method Not Allowed"}}
However, if I try another image and then go back to the original image used the server accepts the image.
Why is my request not accepted until I try enough images?
The blog (http://blog.clarifai.com/the-ultimate-visual-recognition-api-guide/#2) mentions the ability to recognize text but I can't find the model to use for that?
Is the OCR model available but not documented? if so how can I use it?
Thanks ๐
Hi,
I tried to add own id into inputs in predict method but it seems that the sdk dose not support yet. However Jared mentions that REST API supports to insert id in prediction following below manner.
https://community.clarifai.com/t/is-there-any-way-to-insert-metadata-into-the-result-of-predtcion/776/4
{
"inputs": [
{
"id": "unique id",
"data": {
"image": {
"base64": "base64 string here"
}
}
}
]
}
Can you add this feature, please?
Regards,
how is the removal example from here: https://developer.clarifai.com/guide/models#models
supposed to work?
shouldn't:
update(obj) {
let url = ${this._config.apiEndpoint}${MODELS_PATH}
;
let modelData = [obj];
let data = {models: modelData.map(formatModel)};
if (data.concepts) {
data['action'] = obj.action || 'merge';
}
in Model.js be changed to:
update(obj) {
obj.id = this.id;
let url = ${this._config.apiEndpoint}${MODELS_PATH}
;
let modelData = [obj];
let data = {models: modelData.map(formatModel)};
if (data.models) {
data['action'] = obj.action || 'merge';
}
?
Hello,
I was doing a POC work to use clarifai in my personal project. And found that if I pass a single object argument to app.inputs.create, then the concepts are not tied to the image correctly. However, when I tried array argument to the method, it worked perfectly. Below is my code sample.
// Image is uploaded, but concepts are missing.
app.inputs.create({
url: 'url-for-image',
concepts: [{
id: 'cat',
value: true,
}],
});
// Image is uploaded with concepts as expected
app.inputs.create([
{
url: 'url-for-image',
concepts: [{
id: 'cat',
value: true,
}],
}
]);
The axios package in use is outdated & vulnerable.
Please update
app.models.list().then(response => {
console.log(response)
})
Response doesn't contain any models, even global ones. What am I missing?
Each of the examples concludes with something like this:
handleResponse,
handleError
However, it is not very clear how we handle a response. There are no response parameters in the getTags requests. How do we see a response/error?
I'm getting this error.
[ 'Error: Cannot find module \'./../package.json\'',
' at Function.Module._resolveFilename (module.js:472:15)',
' at Function.Module._load (module.js:420:25)',
' at Module.require (module.js:500:17)',
' at require (internal/module.js:20:19)',
' at Object.<anonymous> (/Users/Chance/Development/cosmunity/backend/node_modules/clarifai/dist/node/utils.js:15:17)'
The path referencing package.json
is correct in /src/utils.js
, but is incorrect in /dist/node/utils.js
because the file is 1 level deeper. I think this was introduced in 080e0ba. @zeiler
This bug breaks any package depending on Clarifai
When trying to list my applications, i receive the error
"Object has a duplicate ID; another object with same ID already exist.","details":"Object has a duplicate ID; another object with same ID already exist"
and i cannot list my applications on the platform.
And i cannot remove the duplicateds too, because i dont know what is the duplicated resource
https://imgur.com/a/9gW72FV
I'd like to use color in a project and I'm already using this client, is there any timing of when this will be added or any ideas how I can easily integrate color with this client without having to do authentication myself.
Thanks!
I'm using Clarifai in my React Native project. Essentially, I'm using react-native-camera to take a picture and then passing it to the Clarifai model to predict/identify objects in the picture. The picture is successfully taken and passed to the Clarifai model, but an error occurred in the following portion of the code.
const Clarifai = require('clarifai');
const app = new Clarifai.App({
apiKey: 'my clarifai apiKey',
});
app.models
.predict(Clarifai.GENERAL_MODEL, {base64: imageData})
.then((response: any) =>
displayAnswer(response.outputs[0].data.concepts[0].name),
)
.catch((err: any) => {
alert(err);
console.log('error:', err);
setLoading(false);
});
An error was caught in the .catch() statement. It seems like Axios is not imported correctly or the Axios package is not installed, but I have already installed the package. Below is my project's package.json dependencies:
"axios": "^1.6.5",
"clarifai": "^2.9.1",
"react": "18.2.0",
"react-native": "0.73.1",
"react-native-camera": "^4.2.1"
Hi, I'm implementing clarifai-javascript in an app with NativeScript and Angular 2.
It actually breaks the app with this error message:
Zone.js has detected that ZoneAwarePromise `(window|global).Promise` has been overwritten.
Most likely cause is that a Promise polyfill has been loaded after Zone.js (Polyfilling Promise api is not necessary when zone.js is loaded. If you must load one, do so before loading zone.js.)
I'm seeing that you are always using the es6-promise polyfill
var Promise = require('es6-promise').Promise;)
disregarding if an implementation (custom one in this case) is already available.
See this similar issue Stuk/jszip#303 (comment) and it's fix: Stuk/jszip#321
Cheers!
I had an issue with version 2.1.4dev (which is currently the default module on npm). I'm using Clarifai with react native; following import, I got this error:
UnableToResolveError: Unable to resolve module domain
from /Users/user/Documents/projectname/node_modules/asap/raw.js: Module does not exist in the module map or in these directories:
/Users/user/Documents/projectname/node_modules
, /Users/user/node_modules
This might be related to facebook/react-native#4968
To resolve try the following:
watchman watch-del-all
.node_modules
folder: rm -rf node_modules && npm install
.rm -fr $TMPDIR/react-*
or npm start --reset-cache
The problem here is domain has been deprecated in node.js but is used in [email protected] (a dependency of [email protected], which itself is a dependency of clarifai @2.1.4-dev). I was able to get around this issue by using [email protected], which uses a different promise library (I'm using yarn, the command was: yarn add [email protected]).
Here's a screenshot of the old dependency tree
Summary: most recent clarifai release uses a library which uses a deprecated node module
I kept experiencing this error:
Error: Request failed with status code 400
const Clarifai = require('clarifai')
const clarifai = new Clarifai.App({
apiKey: "[]"
});
function log(d) {
try {
console.log(JSON.stringify(d, null, 2));
} catch (e) {
console.log(d);
}
}
// Prediction on general model using video API
clarifai.models.predict(Clarifai.GENERAL_MODEL, 'https://gblobscdn.gitbook.com/spaces%2F-LisemUaXxC3S7Kk9xFz%2Favatar.png')
.then(log)
.catch(log);
Version: 2.9.1
Node.js: v14.13.1
Import Clarifai doesn't work as the npm package is depreciated
I try import clarifai to my react native project , when I try
const ClarifaiApp = new Clarifai.App({
apiKey: 'xxxx'
});
ClarifaiApp.models.predict(Clarifai.GENERAL_MODEL, "https://samples.clarifai.com/metro-north.jpg").then(
function(response) {
// do something with response
console.log(response);
},
function(err) {
console.log(err);
// there was an error
}
);
}
I get error process.nextTick is not a function
Hi, I have just started using the Clarifai API and it works great.
One thing I was wondering though is how to protect my application key/secret from being stolen / used by anyone who uses the app? It seems I cannot regenerate those and putting them in the javascript source does not feel right to me.
Any thoughts ?
Would you consider adding typescript support?
Hi,
I am trying this API for DevelopersWeek Hackathon tomorrow . I am looking at the docs in your https://developer.clarifai.com/quick-start/ and the example API for 'Train' is giving a 'Bad Request' error. Any ideas? All other , 'predict', 'search' are running fine. So I am assuming its not the Developer API Key issue.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.