EvanZhouDev / palm-api

GNU General Public License v3.0
30 stars 1 forks source link

TypeScript support #2

Closed Crystal-Spider closed 1 year ago

Crystal-Spider commented 1 year ago

I'm trying to use this API in a TypeScript strict project.

I try to import PaLM by doing import {PaLM} from 'palm-api';, however this gives the following error:

Could not find a declaration file for module 'palm-api'. '.../node_modules/palm-api/index.js' implicitly has an 'any' type. Try npm i --save-dev @types/palm-api if it exists or add a new declaration (.d.ts) file containing declare module 'palm-api'; ts(7016)

The command npm i --save-dev @types/palm-api gives E404.

Would it be possible to add support for TypeScript?

sr-04 commented 1 year ago

I don't think we have a module named palm-api. We can access API using get method which is different from downloading a module.

Crystal-Spider commented 1 year ago

But in your readme there is an example to import it: import PaLM from "palm-api";

Never mind that in my previous comment there are curly brackets around PaLM, the error is the same regardless.
What I believe to be the issue is that this API only supports plain JavaScript; TypeScript strict then gives off an error because there are no types in the module, and so everything would be any.

EvanZhouDev commented 1 year ago

Yes, I am aware that we currently do not have TypeScript support. You are welcome to add it yourself through a pull request (PR). I have a number of other tasks on my plate at the moment, so I may not be able to address it immediately. Apologies for any inconvenience! 😅

Crystal-Spider commented 1 year ago

Sure thing, do you have any code-style rules you'd like me to follow?

EvanZhouDev commented 1 year ago

Nope, do whatever you are comfortable with. Thank you so much!

Crystal-Spider commented 1 year ago

In this section, is this correct?

Any model capable of generateText. Default: embedding-gecko-001.

Shouldn't it say embedText?

EvanZhouDev commented 1 year ago

Ah, you got me there... it is 😅

Crystal-Spider commented 1 year ago

I'm basically done, I just need to check if I configured everything correctly to be packaged with npm and still work properly, but I'm going to do it tomorrow since it's now 01:30 am where I live ahah

EvanZhouDev commented 1 year ago

No worries, take your time...

Crystal-Spider commented 1 year ago

I opened a PR: #3

EvanZhouDev commented 1 year ago

Wow, this is amazingly done... higher quality than anything I could ship 🤣

Honestly, I was just expecting .d.ts file, but this is better! I'm assuming you've tested everything?

Crystal-Spider commented 1 year ago

Unfortunately I couldn't test because I'm still on the waiting list for PaLM API and MakerSuite :/
Theoretically, no working should have changed, as all the work I did was mainly to add types. Of course I do agree that testing it out would be better ahah
What I'm actually unsure is whether I correctly setup the project to be published and used by others, but I wouldn't know how to test this.

Crystal-Spider commented 1 year ago

Do you think you can find the time to test it out, merge the PR, and release a new version?

Crystal-Spider commented 1 year ago

Hello! Any update on this? Unfortunately I still haven't been granted access to the PaLM API.

Crystal-Spider commented 1 year ago

Hello! Any update on this? Unfortunately I still haven't been granted access to the PaLM API.