forked from janhq/jan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
512 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Jan Build Electron App | ||
name: Electron Builder - Tag | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Jan Electron Linter & Test | ||
name: Test - Linter & Playwright | ||
on: | ||
workflow_dispatch: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Test - OpenAI API Pytest collection | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
- release/** | ||
paths: | ||
- "docs/**" | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
- release/** | ||
paths: | ||
- "docs/**" | ||
|
||
jobs: | ||
openai-python-tests: | ||
runs-on: [self-hosted, Linux, ubuntu-desktop] | ||
if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository) || github.event_name == 'push' || github.event_name == 'workflow_dispatch' | ||
steps: | ||
- name: Getting the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Installing node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 | ||
|
||
- name: "Cleanup cache" | ||
continue-on-error: true | ||
run: | | ||
rm -rf ~/jan | ||
make clean | ||
- name: install dependencies | ||
run: | | ||
npm install -g @stoplight/prism-cli | ||
- name: create python virtual environment and run test | ||
run: | | ||
python3 -m venv /tmp/jan | ||
source /tmp/jan/bin/activate | ||
# Clone openai-api-python repo | ||
OPENAI_API_PYTHON_TAG=$(cat docs/openapi/version.txt) | ||
git clone https://github.com/openai/openai-python.git | ||
cd openai-python | ||
git checkout $OPENAI_API_PYTHON_TAG | ||
python3 -m venv /tmp/jan | ||
source /tmp/jan/bin/activate | ||
pip install -r requirements-dev.lock | ||
pip install pytest-reportportal pytest-html | ||
# Create pytest.ini file with content | ||
cat ../docs/tests/pytest.ini >> pytest.ini | ||
echo "rp_api_key = ${{ secrets.REPORT_PORTAL_API_KEY }}" >> pytest.ini | ||
echo "rp_endpoint = ${{ secrets.REPORT_PORTAL_URL_PYTEST }}" >> pytest.ini | ||
cat pytest.ini | ||
# Append to conftest.py | ||
cat ../docs/tests/conftest.py >> tests/conftest.py | ||
# start mock server and run test then stop mock server | ||
prism mock ../docs/openapi/jan.yaml > prism.log & prism_pid=$! && pytest --reportportal --html=report.html && kill $prism_pid | ||
deactivate | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: report | ||
path: | | ||
openai-python/report.html | ||
openai-python/assets | ||
openai-python/prism.log | ||
- name: clean up | ||
if: always() | ||
run: | | ||
rm -rf /tmp/jan | ||
rm -rf openai-python | ||
rm -rf report.html | ||
rm -rf report.zip | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Jan Build Docker Nightly or Manual | ||
name: Docker Builder - Nightly / Manual | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Jan Build Docker | ||
name: Docker Builder - Tag | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
v1.23.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def pytest_collection_modifyitems(items): | ||
for item in items: | ||
# add the name of the file (without extension) as a marker | ||
filename = item.nodeid.split("::")[0].split("/")[-1].replace(".py", "") | ||
marker = pytest.mark.file(filename) | ||
item.add_marker(marker) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[pytest] | ||
rp_project = openai-api-test | ||
rp_launch = OpenAI Collection Test | ||
rp_launch_description = Full collection to ensure compatibility with OpenAI API | ||
rp_launch_attributes = 'CI' | ||
filterwarnings = ignore::pytest.PytestUnknownMarkWarning | ||
log_format = %(asctime)s %(levelname)s %(message)s | ||
log_date_format = %Y-%m-%d %H:%M:%S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Cohere Engine Extension | ||
|
||
Created using Jan extension example | ||
|
||
# Create a Jan Extension using Typescript | ||
|
||
Use this template to bootstrap the creation of a TypeScript Jan extension. 🚀 | ||
|
||
## Create Your Own Extension | ||
|
||
To create your own extension, 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 extension. | ||
|
||
> [!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 extension directory now | ||
|
||
## Update the Extension Metadata | ||
|
||
The [`package.json`](package.json) file defines metadata about your extension, such as | ||
extension name, main entry, description and version. | ||
|
||
When you copy this repository, update `package.json` with the name, description for your extension. | ||
|
||
## Update the Extension Code | ||
|
||
The [`src/`](./src/) directory is the heart of your extension! This contains the | ||
source code that will be run when your 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 extension code: | ||
|
||
- Most Jan Extension functions are processed asynchronously. | ||
In `index.ts`, you will see that the extension function will return a `Promise<any>`. | ||
|
||
```typescript | ||
import { events, MessageEvent, MessageRequest } from '@janhq/core' | ||
|
||
function onStart(): Promise<any> { | ||
return events.on(MessageEvent.OnMessageSent, (data: MessageRequest) => | ||
this.inference(data) | ||
) | ||
} | ||
``` | ||
|
||
For more information about the Jan Extension 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 extension! |
Oops, something went wrong.