Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript] full support βœ¨πŸ€– #6

Closed
wants to merge 6 commits into from

Conversation

Mimikkk
Copy link

@Mimikkk Mimikkk commented Jan 2, 2024

I've been working for a couple of hours to add typescript support to the project.
It encompasses tests, utils and so on. Bumped vitest to 1.1.1 and did a few minor tweaks due to typing.

Changes:

  • typescript 5.3.3 support.
  • vite for building minified solution in both commonjs and esmodules formats.
  • prettier for code formatting.
  • concurrently/rimraf/copyfiles for support building on linux/windows/macos.
  • vite allowed me to split files into utils / types and index for ease of development

Added scripts:

  • build: builds the package into the build directory using vite. It clears the build/ directory, then it runs build process,
  • build:clear: clears the build/ directory
  • build:types: emits the typescript definitions into the build/ directory
  • build:lib: build and minifies the package into the build/ directory

I moved the dynamically created class Chat outside the Gemini class and added exported createGemini function for the ease of creation multiple instances.

@Mimikkk Mimikkk changed the title Feature full typescript support [Typescript] full support βœ¨πŸ€– Jan 2, 2024
@Mimikkk Mimikkk changed the title [Typescript] full support βœ¨πŸ€– [TypeScript] full support βœ¨πŸ€– Jan 2, 2024
@yoroshikun
Copy link

This is great πŸ‘ Hope it gets merged soon.

tsconfig.json Outdated
"baseUrl": ".",
"inlineSourceMap": true,
"inlineSources": true,
"module": "ESNext",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS somewhat complains about this Option 'module' must be set to 'NodeNext' when option 'moduleResolution' is set to 'NodeNext ts 5.3.3

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do it, it changes resolution model from directory specification into file specification:

import {} from 'abc';

to:

import {} from 'abc.js';

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, i've changed it to use nodenext directly. Try it on your build to verify it.

@yoroshikun
Copy link

You may also want to remove the old fullCoverage.test.js in this PR

vite.config.ts Outdated
@@ -0,0 +1,16 @@
import { defineConfig } from 'vite';
Copy link

@yoroshikun yoroshikun Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately if using bun the cache likes to be tested, can remove it with config.

Suggested change
import { defineConfig } from 'vite';
import { defineConfig } from 'vitest/config';
{
...
test: {
  exclude: ['*/~/**']
}
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, great idea

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oven-sh/bun#4145

When running vitest with bun it just crashes in a fire.
I excluded the test from the config. so it does not catch fire

@taciturnaxolotl
Copy link

hey @EvanZhouDev can you merge this? I would love to have full typescript support on the official package.

@taciturnaxolotl
Copy link

I might be dumb but how do you build and publish the package @Mimikkk? I've tried with npm publish and vite build but they don't seem to work.

@EvanZhouDev
Copy link
Owner

Hello @yoroshikun @kcoderhtml @Mimikkk, sorry for the super late response.

I know most likely you're not using this package anymore, but I thought I'd still update you on what's going on. I've been extremely busy for the past few months on work and other projects, so I haven't been able to catch up with gemini-ai recently. Furthermore, I have not decided to merge this branch because of a few refactors I've been doing, as well as the fact that it has seemed to stray a bit too far from the original.

However, seeing as Google has released Gemini 1.5 Flash today, I will be coming back to this project. Expect a relatively large update in the next few weeks, featuring types, updated streaming support, as well as better support by default for the new models.

As for this,

I might be dumb but how do you build and publish the package @Mimikkk? I've tried with npm publish and vite build but they don't seem to work.

only the original publisher can update the package to NPM πŸ˜…

@taciturnaxolotl
Copy link

Thanks! Looking forward to trying the updated package!

only the original publisher can update the package to NPM πŸ˜…

I believe I was trying to rebuild the package and deploy to my NPM account, but I can't remember at this point what I was trying to do :)

@EvanZhouDev
Copy link
Owner

EvanZhouDev commented May 22, 2024

I have finished the initial rewrite in TypeScript, which is now available on the v2 branch. It supports a bunch of improvements and some new features, which I will have to document πŸ˜…... it is still completely backward compatible, but I thought a ground-up rewrite deserves a major version bump.

Edit: PR now available at #9

@taciturnaxolotl
Copy link

Thank you!!! Looking forward to trying it out!

@EvanZhouDev
Copy link
Owner

Full TypeScript support, along with a bunch of great new features are now available on NPM. Will be closing this for now. Feel free to continue on this thread (or start a new issue) if anything needs to be fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants