Merge pull request #426 from janhq/chore/add-readme-retrieval-plugin
Add readme inference plugin
This commit is contained in:
commit
acdfe7e83b
4
.github/workflows/jan-plugins.yml
vendored
4
.github/workflows/jan-plugins.yml
vendored
@ -90,7 +90,7 @@ jobs:
|
|||||||
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
|
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
|
||||||
run: |
|
run: |
|
||||||
rm -rf /tmp/plugin-catalog
|
rm -rf /tmp/plugin-catalog
|
||||||
git clone https://${{ secrets.SERVICE_ACCOUNT_USERNAME }}@github.com/janhq/plugin-catalog.git /tmp/plugin-catalog
|
git clone https://${{ secrets.SERVICE_ACCOUNT_USERNAME }}:${{ secrets.PAT_SERVICE_ACCOUNT }}@github.com/janhq/plugin-catalog.git /tmp/plugin-catalog
|
||||||
for dir in $(cat /tmp/change_dir.txt)
|
for dir in $(cat /tmp/change_dir.txt)
|
||||||
do
|
do
|
||||||
echo "$dir"
|
echo "$dir"
|
||||||
@ -110,7 +110,7 @@ jobs:
|
|||||||
git checkout -b $BRANCH_NAME
|
git checkout -b $BRANCH_NAME
|
||||||
git add .
|
git add .
|
||||||
git commit -m "Update plugin catalog"
|
git commit -m "Update plugin catalog"
|
||||||
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin $BRANCH_NAME
|
git push origin $BRANCH_NAME
|
||||||
cd /tmp && rm -rf /tmp/plugin-catalog
|
cd /tmp && rm -rf /tmp/plugin-catalog
|
||||||
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
|
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
|
||||||
echo "::set-output name=branch_name::$BRANCH_NAME"
|
echo "::set-output name=branch_name::$BRANCH_NAME"
|
||||||
|
|||||||
73
plugins/inference-plugin/README.md
Normal file
73
plugins/inference-plugin/README.md
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
# Create a Jan Plugin using Typescript
|
||||||
|
|
||||||
|
Use this template to bootstrap the creation of a TypeScript Jan plugin. 🚀
|
||||||
|
|
||||||
|
## Create Your Own Plugin
|
||||||
|
|
||||||
|
To create your own plugin, you can use this repository as a template! Just follow the below instructions:
|
||||||
|
|
||||||
|
1. Click the Use this template button at the top of the repository
|
||||||
|
2. Select Create a new repository
|
||||||
|
3. Select an owner and name for your new repository
|
||||||
|
4. Click Create repository
|
||||||
|
5. Clone your new repository
|
||||||
|
|
||||||
|
## Initial Setup
|
||||||
|
|
||||||
|
After you've cloned the repository to your local machine or codespace, you'll need to perform some initial setup steps before you can develop your plugin.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
>
|
||||||
|
> You'll need to have a reasonably modern version of
|
||||||
|
> [Node.js](https://nodejs.org) handy. If you are using a version manager like
|
||||||
|
> [`nodenv`](https://github.com/nodenv/nodenv) or
|
||||||
|
> [`nvm`](https://github.com/nvm-sh/nvm), you can run `nodenv install` in the
|
||||||
|
> root of your repository to install the version specified in
|
||||||
|
> [`package.json`](./package.json). Otherwise, 20.x or later should work!
|
||||||
|
|
||||||
|
1. :hammer_and_wrench: Install the dependencies
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
1. :building_construction: Package the TypeScript for distribution
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run bundle
|
||||||
|
```
|
||||||
|
|
||||||
|
1. :white_check_mark: Check your artifact
|
||||||
|
|
||||||
|
There will be a tgz file in your plugin directory now
|
||||||
|
|
||||||
|
## Update the Plugin Metadata
|
||||||
|
|
||||||
|
The [`package.json`](package.json) file defines metadata about your plugin, such as
|
||||||
|
plugin name, main entry, description and version.
|
||||||
|
|
||||||
|
When you copy this repository, update `package.json` with the name, description for your plugin.
|
||||||
|
|
||||||
|
## Update the Plugin Code
|
||||||
|
|
||||||
|
The [`src/`](./src/) directory is the heart of your plugin! This contains the
|
||||||
|
source code that will be run when your plugin extension functions are invoked. You can replace the
|
||||||
|
contents of this directory with your own code.
|
||||||
|
|
||||||
|
There are a few things to keep in mind when writing your plugin code:
|
||||||
|
|
||||||
|
- Most Jan Plugin Extension functions are processed asynchronously.
|
||||||
|
In `index.ts`, you will see that the extension function will return a `Promise<any>`.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { core } from "@janhq/core";
|
||||||
|
|
||||||
|
function onStart(): Promise<any> {
|
||||||
|
return core.invokePluginFunc(MODULE_PATH, "run", 0);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information about the Jan Plugin Core module, see the
|
||||||
|
[documentation](https://github.com/janhq/jan/blob/main/core/README.md).
|
||||||
|
|
||||||
|
So, what are you waiting for? Go ahead and start customizing your plugin!
|
||||||
@ -71,3 +71,4 @@ There are a few things to keep in mind when writing your plugin code:
|
|||||||
[documentation](https://github.com/janhq/jan/blob/main/core/README.md).
|
[documentation](https://github.com/janhq/jan/blob/main/core/README.md).
|
||||||
|
|
||||||
So, what are you waiting for? Go ahead and start customizing your plugin!
|
So, what are you waiting for? Go ahead and start customizing your plugin!
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user