Giter VIP home page Giter VIP logo

clarifai-nodejs-grpc's People

Contributors

aleksander-clarifai avatar andrew-pyle avatar arnoldramo avatar aruex avatar clarifai-prod avatar dependabot[bot] avatar rok-clarifai avatar rok-povsic avatar travertischio avatar yvetteclarifai avatar yvettez2017 avatar zeiler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clarifai-nodejs-grpc's Issues

get auth error "Empty or malformed authorization header. Please provide an API key or session token."

Hi!
Code example:

const {ClarifaiStub} = require("clarifai-nodejs-grpc");
const grpc = require("@grpc/grpc-js");

const stub = ClarifaiStub.insecureGrpc();

const metadata = new grpc.Metadata();
metadata.set("authorization", "Key " + MY_API_KEY);

stub.PostModelOutputs(
      {
          model_id: 'ivp-model',
          inputs: [{data: {image: {url: 'https://samples.clarifai.com/food.jpg'}}}]
      },
      metadata,
      (err: any, response: any) => {
          if (err) {
              console.log("Error: " + err);
              return;
          }
  
          if (response.status.code !== 10000) {
              console.log("Received failed status: " + response.status.description + "\n" + response.status.details);
              return;
          }
  
          for (const c of response.outputs[0].data.concepts) {
              console.log(c.name + ": " + c.value);
          }
      }

I always get:
'Received failed status: Invalid request
Empty or malformed authorization header. Please provide an API key or session token.'

As I understood, I need to take MY_API_KEY from an application page on https://portal.clarifai.com/ in "API Keys" area.
What I do wrong?

Would like to see generated Typescript definitions for ClarifaiStub

It would be great to have Typescript definitions for this library, or at least for the ClarifaiStub

@rok-clarifai Thank you for this NodeJS Library! The Readme explains the basic "predict" functionality well.

I'm lost when it comes to working with the callback, though. Apart from inspecting test responses, it's not easy to determine what values are possible for the callback parameters. From the Readme:

(err, response) => { // What is the type of err and response?
    if (err) {
        console.log("Error: " + err);
        return;
    }
    if (response.status.code !== 10000) {
        console.log("Received failed status: " + response.status.description + "\n" + response.status.details);
        return;
    }

    for (const c of response.outputs[0].data.concepts) {
        console.log(c.name + ": " + c.value);
    }
}

I am totally unfamiliar with gRPC, so I don't have any intuition about how this library behaves, so a .d.ts file would be extremely helpful.

I believe that it should be possible to automatically generate TS definitions for the ClarifaiStub, at least this post seems to say so in the section "Generating gRPC clients and types from proto files"

Is this something the authors can do?

Issue using in next.js 13

Hello!

I am encountering an issue when importing this library into my next.js application.

This occurs when I load the page on which I am importing clarifai-nodejs-grpc

./node_modules/@grpc/grpc-js/build/src/channel-credentials.js:20:0
Module not found: Can't resolve 'tls'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/@grpc/grpc-js/build/src/index.js
./node_modules/clarifai-nodejs-grpc/src/index.js
./pages/admin.js

I am using next.js v13.5.4 and clarifai-nodejs-grpc v9.9.6

Any advice on what I could try to get this working would be much appreciated. Thank you!

Fail to build in typescript

After I import your library and trying to build, following error occurs

node_modules/clarifai-nodejs-grpc/proto/clarifai/api/service_grpc_pb.d.ts:7:23 - error TS2307: Cannot find module 'grpc' or its corresponding type declarations.

7 import * as grpc from "grpc";
                        ~~~~~~


Found 1 error.

Don't default empty Concept value to 1 in the JSON channel

Currently, a concept with no value will default to 1.0 in the JSON channel. This is inconsistent with the gRPC channel where it'll default to 0.0.

Make JSON channel default to 0.0 (this is also what JSON channels in Java and Python do).

[Help] - How to delete concepts by concept id

https://stackoverflow.com/questions/70074554/clarifai-how-does-one-delete-a-concept-using-its-id-node-grcp-client

I want to expose the CRUD API for inputs, annotations and concepts. I am unable to find how to delete concepts using the gRCP node client (V7.4)

I want to delete concepts having only the concept's id

There seems to be a way to delete concepts using inputs : https://docs.clarifai.com/api-guide/data/create-get-update-delete

The docs do not reveal how to delete concepts : https://docs.clarifai.com/portal-guide/concept/concepts

Thank you for helping me

Metadata does not upload

Using a similar call:

// This will be used by every Clarifai endpoint call.
const metadata = new grpc.Metadata()

metadata.set('authorization', 'Key XXXXX')

stub.PostInputs(
    {
        inputs: [{data: {
            image: {url: "https://samples.clarifai.com/puppy.jpeg", allow_duplicate_url: true},
            metadata: {id: "id001", type: "animal", size: 100}
        }}]
    },
    metadata,
    (err, response) => {
        if (err) {
            throw new Error(err);
        }

        if (response.status.code !== 10000) {
            throw new Error("Post inputs failed, status: " + response.status.description);
        }
    }
);

Metadata is not attached to the input when you check via the Portal or any other method. This seems to happen only with this gRPC client.

Failed to compile

Hi

After importing the clarifai-nodejs-grpc package, I get this error:

./node_modules/@grpc/grpc-js/build/src/server.js
Module not found: Can't resolve 'http2' in 'C:\Users\Nene\Desktop\WebWork\face-recognition-app\node_modules@grpc\grpc-js\build\src'

Thanks

./node_modules/@grpc/grpc-js/build/src/resolver-dns.js Module not found: Can't resolve 'dns'

Been trying to figure this out for the past hour. I followed all instructions on Clarify website.

added:
const {ClarifaiStub, grpc} = require("clarifai-nodejs-grpc");

const stub = ClarifaiStub.grpc();

const metadata = new grpc.Metadata();
metadata.set("authorization", "Key API Key");

stub.PostModelOutputs(
{
// This is the model ID of a publicly available General model. You may use any other public or custom model ID.
model_id: "aaa03c23b3724a16a56b629203edc62c",
inputs: [{data: {image: {url: "https://samples.clarifai.com/dog2.jpeg"}}}]
},
metadata,
(err, response) => {
if (err) {
console.log("Error: " + err);
return;
}

        if (response.status.code !== 10000) {
            console.log("Received failed status: " + response.status.description + "\n" + response.status.details);
            return;
        }

        console.log("Predicted concepts, with confidence values:")
        for (const c of response.outputs[0].data.concepts) {
            console.log(c.name + ": " + c.value);
        }
    }
    );

after saving there were errors and I tried resolving. now all I receive is Failed to compile
./node_modules/@grpc/grpc-js/build/src/resolver-dns.js
Module not found: Can't resolve 'dns'

a bit new and still trying to learn.

What breaking changes are in v7?

Thank you for the great new Typescript definitions in v7.

However, I can't find a Changelog or Release notes. What has changed in this library's API? What's new? Where will code consuming v6 break with v7?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.