Merge branch 'main' into feat_adr_008_extensible_docker
This commit is contained in:
commit
239d2681a6
5
.github/scripts/auto-sign.sh
vendored
Executable file
5
.github/scripts/auto-sign.sh
vendored
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
APP_PATH=${APP_PATH}
|
||||
DEVELOPER_ID=${DEVELOPER_ID}
|
||||
find $APP_PATH \( -type f -perm +111 -o -name "*.node" \) -exec codesign -s "$DEVELOPER_ID" --options=runtime {} \;
|
||||
4
.github/workflows/jan-electron-build.yml
vendored
4
.github/workflows/jan-electron-build.yml
vendored
@ -44,6 +44,7 @@ jobs:
|
||||
CODE_SIGN_P12_BASE64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
|
||||
|
||||
- uses: apple-actions/import-codesign-certs@v2
|
||||
continue-on-error: true
|
||||
with:
|
||||
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
|
||||
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
|
||||
@ -52,6 +53,9 @@ jobs:
|
||||
run: |
|
||||
yarn install
|
||||
yarn build:plugins-darwin
|
||||
env:
|
||||
APP_PATH: "."
|
||||
DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }}
|
||||
|
||||
- name: Build and publish app
|
||||
run: |
|
||||
|
||||
18
.github/workflows/jan-plugins.yml
vendored
18
.github/workflows/jan-plugins.yml
vendored
@ -15,7 +15,7 @@ on:
|
||||
- "!plugins/*/package.json"
|
||||
jobs:
|
||||
build:
|
||||
runs-on: mac-silicon
|
||||
runs-on: macos-latest
|
||||
environment: production
|
||||
outputs:
|
||||
branch_name: ${{ steps.commit_and_tag.outputs.branch_name }}
|
||||
@ -28,6 +28,18 @@ jobs:
|
||||
- name: Install jq
|
||||
uses: dcarbone/install-jq-action@v2.0.1
|
||||
|
||||
- name: Get Cer for code signing
|
||||
run: base64 -d <<< "$CODE_SIGN_P12_BASE64" > /tmp/codesign.p12
|
||||
shell: bash
|
||||
env:
|
||||
CODE_SIGN_P12_BASE64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
|
||||
|
||||
- uses: apple-actions/import-codesign-certs@v2
|
||||
continue-on-error: true
|
||||
with:
|
||||
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
|
||||
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
|
||||
|
||||
- name: Check Path Change
|
||||
run: |
|
||||
git config --global user.email "service@jan.ai"
|
||||
@ -76,7 +88,7 @@ jobs:
|
||||
do
|
||||
echo $dir
|
||||
cd $dir
|
||||
npm install && npm run build
|
||||
npm install && npm run postinstall && ../../.github/scripts/auto-sign.sh
|
||||
if [[ $GITHUB_EVENT_NAME == 'push' && $GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME != $GITHUB_REPOSITORY ]]; then
|
||||
npm publish --access public
|
||||
fi
|
||||
@ -84,6 +96,8 @@ jobs:
|
||||
done
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }}
|
||||
APP_PATH: "."
|
||||
|
||||
- name: "Commit new version to main and create tag"
|
||||
id: commit_and_tag
|
||||
|
||||
626
LICENSE
626
LICENSE
@ -1,107 +1,100 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
# GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Preamble
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
## Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains
|
||||
free software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing
|
||||
under this license.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
## TERMS AND CONDITIONS
|
||||
|
||||
1. Definitions.
|
||||
### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
"This License" refers to version 3 of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
@ -109,18 +102,18 @@ work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
@ -131,7 +124,7 @@ implementation is available to the public in source code form. A
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
@ -144,16 +137,15 @@ linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
2. Basic Permissions.
|
||||
### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
@ -161,40 +153,40 @@ covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
@ -202,37 +194,35 @@ non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
@ -242,19 +232,18 @@ beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
@ -263,16 +252,14 @@ in one of these ways:
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
@ -284,38 +271,38 @@ in one of these ways:
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
@ -326,23 +313,24 @@ if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
@ -351,41 +339,36 @@ apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
@ -395,47 +378,47 @@ License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
@ -443,14 +426,14 @@ modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
@ -460,7 +443,7 @@ give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
@ -468,14 +451,14 @@ rights granted under this License, and you may not initiate litigation
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
@ -484,19 +467,19 @@ purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
@ -510,7 +493,7 @@ covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
@ -518,157 +501,160 @@ or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
### 13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your
|
||||
version supports such interaction) an opportunity to receive the
|
||||
Corresponding Source of your version by providing access to the
|
||||
Corresponding Source from a network server at no charge, through some
|
||||
standard or customary means of facilitating copying of software. This
|
||||
Corresponding Source shall include the Corresponding Source for any
|
||||
work covered by version 3 of the GNU General Public License that is
|
||||
incorporated pursuant to the following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Affero General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
GNU Affero General Public License, you may choose any version ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
## How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for
|
||||
the specific requirements.
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
||||
@ -131,6 +131,11 @@ export enum DataService {
|
||||
* Updates a bot matching an ID.
|
||||
*/
|
||||
UpdateBot = "updateBot",
|
||||
|
||||
/**
|
||||
* Gets the plugin manifest.
|
||||
*/
|
||||
GetPluginManifest = "getPluginManifest",
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@janhq/core",
|
||||
"version": "0.1.6",
|
||||
"version": "0.1.7",
|
||||
"description": "Plugin core lib",
|
||||
"keywords": [
|
||||
"jan",
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
---
|
||||
title: "Jan's AI Hacker House (Ho Chi Minh City)"
|
||||
description: "24-27 Oct 2023, Thao Dien, HCMC. AI-focused talks, workshops and social events. Hosted by Jan.ai"
|
||||
description: "24-27 Oct 2023, District 3, HCMC. AI-focused talks, workshops and social events. Hosted by Jan.ai"
|
||||
slug: /events/hcmc-oct23
|
||||
image: /img/hcmc-villa-1.jpeg
|
||||
image: /img/hcmc-launch-party.png
|
||||
---
|
||||

|
||||
|
||||

|
||||
|
||||
🎉 Join us at our Friday Launch Party for an evening of AI talks from other builders! [(RSVP here)](https://jan-launch-party.eventbrite.sg/) 🎉
|
||||
|
||||
## Ho Chi Minh City
|
||||
|
||||
@ -20,17 +23,17 @@ Jan is a fully remote team. We use the money we save from not having an office,
|
||||
|
||||
### Location
|
||||
|
||||
- Thao Dien, District 2, Ho Chi Minh City
|
||||
- Exact location to be shared later
|
||||
- Districts 1 & 3, Ho Chi Minh City
|
||||
- Exact location in Evenbrite (see below)
|
||||
|
||||
## Agenda
|
||||
|
||||
To help us manage RSVPs, please use the Eventbrite links below to RSVP for each event.
|
||||
|
||||
| Day | Eventbrite Link | Signups |
|
||||
| ------------ | ------------------------------------- | -------------------------------------------------------------------------------------------- |
|
||||
| ------------ | ------------------------------------- | ---------------------------------------------------- |
|
||||
| Mon (23 Oct) | Jan Team & Partners Dinner | Invite-only |
|
||||
| Wed (25 Oct) | Intro to LLMs | [RSVP here](https://www.eventbrite.sg/e/intro-to-large-language-models-tickets-737819045627) |
|
||||
| Thu (26 Oct) | HCMC Startups & VC Night | Invite-only |
|
||||
| Fri (27 Oct) | Jan Launch Party + Build your own LLM | [RSVP here](https://jan-launch-party.eventbrite.sg/) |
|
||||
|
||||
### OKRs
|
||||
@ -40,9 +43,10 @@ To help us manage RSVPs, please use the Eventbrite links below to RSVP for each
|
||||
| Key Result | Polished UI with "Create Bot" w/ saved prompts |
|
||||
| Key Result | Documentation of Jan Codebase for Plugin Developers |
|
||||
| Key Result | Roadmap for 4Q 2023 |
|
||||
| Key Result | *Stretch Goal:* Core Process API for Plugins |
|
||||
| Key Result | _Stretch Goal:_ Core Process API for Plugins |
|
||||
|
||||
## Photos
|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
🎉 Join us at our Friday Launch Party for an evening of AI talks from other builders! [(RSVP here)](https://jan-launch-party.eventbrite.sg/) 🎉
|
||||
|
||||
@ -80,11 +80,8 @@
|
||||
@apply border-gray-200 dark:border-gray-800;
|
||||
}
|
||||
|
||||
[class*="docMainContainer_"],
|
||||
[class*="docSidebarContainer_"] {
|
||||
table {
|
||||
.theme-doc-markdown {
|
||||
a {
|
||||
@apply text-blue-600 dark:text-blue-400;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
docs/static/img/hcmc-launch-party.png
vendored
Normal file
BIN
docs/static/img/hcmc-launch-party.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
BIN
docs/static/img/hcmc-villa-1.jpeg
vendored
BIN
docs/static/img/hcmc-villa-1.jpeg
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 228 KiB |
BIN
docs/static/img/hcmc-villa-2.jpeg
vendored
BIN
docs/static/img/hcmc-villa-2.jpeg
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 332 KiB |
@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
DEVELOPER_ID="Developer ID Application: Eigenvector Pte Ltd"
|
||||
|
||||
find electron -type f -perm +111 -exec codesign -s "Developer ID Application: Eigenvector Pte Ltd (YT49P7GXG4)" --options=runtime {} \;
|
||||
@ -1,4 +1,11 @@
|
||||
import { app, BrowserWindow, ipcMain, dialog, shell } from "electron";
|
||||
import {
|
||||
app,
|
||||
BrowserWindow,
|
||||
ipcMain,
|
||||
dialog,
|
||||
shell,
|
||||
nativeTheme,
|
||||
} from "electron";
|
||||
import { readdirSync, writeFileSync } from "fs";
|
||||
import { resolve, join, extname } from "path";
|
||||
import { rmdir, unlink, createWriteStream } from "fs";
|
||||
@ -36,12 +43,30 @@ app.on("window-all-closed", () => {
|
||||
app.quit();
|
||||
});
|
||||
|
||||
ipcMain.handle("setNativeThemeLight", () => {
|
||||
nativeTheme.themeSource = "light";
|
||||
});
|
||||
|
||||
ipcMain.handle("setNativeThemeDark", () => {
|
||||
nativeTheme.themeSource = "dark";
|
||||
});
|
||||
|
||||
ipcMain.handle("setNativeThemeSystem", () => {
|
||||
nativeTheme.themeSource = "system";
|
||||
});
|
||||
|
||||
function createMainWindow() {
|
||||
mainWindow = new BrowserWindow({
|
||||
width: 1200,
|
||||
height: 800,
|
||||
frame: false,
|
||||
show: false,
|
||||
backgroundColor: "white",
|
||||
trafficLightPosition: {
|
||||
x: 16,
|
||||
y: 10,
|
||||
},
|
||||
titleBarStyle: "hidden",
|
||||
vibrancy: "sidebar",
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
preload: join(__dirname, "preload.js"),
|
||||
@ -118,11 +143,13 @@ function handleIPCs() {
|
||||
ipcMain.handle(
|
||||
"invokePluginFunc",
|
||||
async (_event, modulePath, method, ...args) => {
|
||||
const module = require(/* webpackIgnore: true */ join(
|
||||
const module = require(
|
||||
/* webpackIgnore: true */ join(
|
||||
app.getPath("userData"),
|
||||
"plugins",
|
||||
modulePath
|
||||
));
|
||||
)
|
||||
);
|
||||
requiredModules[modulePath] = module;
|
||||
|
||||
if (typeof module[method] === "function") {
|
||||
|
||||
@ -67,7 +67,6 @@
|
||||
"electron-store": "^8.1.0",
|
||||
"electron-updater": "^6.1.4",
|
||||
"pacote": "^17.0.4",
|
||||
"react-intersection-observer": "^9.5.2",
|
||||
"request": "^2.88.2",
|
||||
"request-progress": "^3.0.0",
|
||||
"use-debounce": "^9.0.4"
|
||||
|
||||
@ -9,6 +9,12 @@ contextBridge.exposeInMainWorld("electronAPI", {
|
||||
invokePluginFunc: (plugin: any, method: any, ...args: any[]) =>
|
||||
ipcRenderer.invoke("invokePluginFunc", plugin, method, ...args),
|
||||
|
||||
setNativeThemeLight: () => ipcRenderer.invoke("setNativeThemeLight"),
|
||||
|
||||
setNativeThemeDark: () => ipcRenderer.invoke("setNativeThemeDark"),
|
||||
|
||||
setNativeThemeSystem: () => ipcRenderer.invoke("setNativeThemeSystem"),
|
||||
|
||||
basePlugins: () => ipcRenderer.invoke("basePlugins"),
|
||||
|
||||
pluginPath: () => ipcRenderer.invoke("pluginPath"),
|
||||
@ -23,19 +29,27 @@ contextBridge.exposeInMainWorld("electronAPI", {
|
||||
|
||||
deleteFile: (filePath: string) => ipcRenderer.invoke("deleteFile", filePath),
|
||||
|
||||
installRemotePlugin: (pluginName: string) => ipcRenderer.invoke("installRemotePlugin", pluginName),
|
||||
installRemotePlugin: (pluginName: string) =>
|
||||
ipcRenderer.invoke("installRemotePlugin", pluginName),
|
||||
|
||||
downloadFile: (url: string, path: string) => ipcRenderer.invoke("downloadFile", url, path),
|
||||
downloadFile: (url: string, path: string) =>
|
||||
ipcRenderer.invoke("downloadFile", url, path),
|
||||
|
||||
onFileDownloadUpdate: (callback: any) => ipcRenderer.on("FILE_DOWNLOAD_UPDATE", callback),
|
||||
onFileDownloadUpdate: (callback: any) =>
|
||||
ipcRenderer.on("FILE_DOWNLOAD_UPDATE", callback),
|
||||
|
||||
onFileDownloadError: (callback: any) => ipcRenderer.on("FILE_DOWNLOAD_ERROR", callback),
|
||||
onFileDownloadError: (callback: any) =>
|
||||
ipcRenderer.on("FILE_DOWNLOAD_ERROR", callback),
|
||||
|
||||
onFileDownloadSuccess: (callback: any) => ipcRenderer.on("FILE_DOWNLOAD_COMPLETE", callback),
|
||||
onFileDownloadSuccess: (callback: any) =>
|
||||
ipcRenderer.on("FILE_DOWNLOAD_COMPLETE", callback),
|
||||
|
||||
onAppUpdateDownloadUpdate: (callback: any) => ipcRenderer.on("APP_UPDATE_PROGRESS", callback),
|
||||
onAppUpdateDownloadUpdate: (callback: any) =>
|
||||
ipcRenderer.on("APP_UPDATE_PROGRESS", callback),
|
||||
|
||||
onAppUpdateDownloadError: (callback: any) => ipcRenderer.on("APP_UPDATE_ERROR", callback),
|
||||
onAppUpdateDownloadError: (callback: any) =>
|
||||
ipcRenderer.on("APP_UPDATE_ERROR", callback),
|
||||
|
||||
onAppUpdateDownloadSuccess: (callback: any) => ipcRenderer.on("APP_UPDATE_COMPLETE", callback),
|
||||
onAppUpdateDownloadSuccess: (callback: any) =>
|
||||
ipcRenderer.on("APP_UPDATE_COMPLETE", callback),
|
||||
});
|
||||
|
||||
@ -48,10 +48,8 @@ test("renders the home page", async () => {
|
||||
|
||||
// Welcome text is available
|
||||
const welcomeText = await page
|
||||
.locator(".text-5xl", {
|
||||
hasText: "Welcome,let’s download your first model",
|
||||
})
|
||||
.getByTestId("testid-welcome-title")
|
||||
.first()
|
||||
.isDisabled();
|
||||
.isVisible();
|
||||
expect(welcomeText).toBe(false);
|
||||
});
|
||||
|
||||
@ -40,7 +40,7 @@ test("shows my models", async () => {
|
||||
.getByRole("heading")
|
||||
.filter({ hasText: "My Models" })
|
||||
.first()
|
||||
.isDisabled();
|
||||
.isVisible();
|
||||
expect(header).toBe(false);
|
||||
// More test cases here...
|
||||
});
|
||||
|
||||
@ -35,37 +35,13 @@ test.afterAll(async () => {
|
||||
});
|
||||
|
||||
test("renders left navigation panel", async () => {
|
||||
// Chat History section is available
|
||||
const chatSection = await page
|
||||
.getByRole("heading")
|
||||
.filter({ hasText: "CHAT HISTORY" })
|
||||
.first()
|
||||
.isDisabled();
|
||||
// Chat section should be there
|
||||
const chatSection = await page.getByTestId("Chat").first().isVisible();
|
||||
expect(chatSection).toBe(false);
|
||||
|
||||
// Home actions
|
||||
const createBotBtn = await page
|
||||
.getByRole("button", { name: "Create bot" })
|
||||
.first()
|
||||
.isEnabled();
|
||||
const exploreBtn = await page
|
||||
.getByRole("button", { name: "Explore Models" })
|
||||
.first()
|
||||
.isEnabled();
|
||||
const myModelsBtn = await page
|
||||
.getByTestId("My Models")
|
||||
.first()
|
||||
.isEnabled();
|
||||
const settingsBtn = await page
|
||||
.getByTestId("Settings")
|
||||
.first()
|
||||
.isEnabled();
|
||||
expect(
|
||||
[
|
||||
createBotBtn,
|
||||
exploreBtn,
|
||||
myModelsBtn,
|
||||
settingsBtn,
|
||||
].filter((e) => !e).length
|
||||
).toBe(0);
|
||||
const botBtn = await page.getByTestId("Bot").first().isEnabled();
|
||||
const myModelsBtn = await page.getByTestId("My Models").first().isEnabled();
|
||||
const settingsBtn = await page.getByTestId("Settings").first().isEnabled();
|
||||
expect([botBtn, myModelsBtn, settingsBtn].filter((e) => !e).length).toBe(0);
|
||||
});
|
||||
|
||||
@ -36,7 +36,5 @@ test.afterAll(async () => {
|
||||
|
||||
test("shows settings", async () => {
|
||||
await page.getByTestId("Settings").first().click();
|
||||
|
||||
const pluginList = await page.getByTestId("plugin-item").count();
|
||||
expect(pluginList).toBe(4);
|
||||
await page.getByTestId("testid-setting-description").isVisible();
|
||||
});
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
"build:web": "yarn workspace jan-web build && cpx \"web/out/**\" \"electron/renderer/\"",
|
||||
"build:electron": "yarn workspace jan build",
|
||||
"build:plugins": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm install && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && concurrently --kill-others-on-fail \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"",
|
||||
"build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./plugins/data-plugin && npm install && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && chmod +x ./electron/auto-sign.sh && ./electron/auto-sign.sh && concurrently \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"",
|
||||
"build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./plugins/data-plugin && npm install && npm run postinstall\" \"cd ./plugins/inference-plugin && npm install && npm run postinstall\" \"cd ./plugins/model-management-plugin && npm install && npm run postinstall\" \"cd ./plugins/monitoring-plugin && npm install && npm run postinstall\" && chmod +x ./.github/scripts/auto-sign.sh && ./.github/scripts/auto-sign.sh && concurrently \"cd ./plugins/data-plugin && npm run build:publish\" \"cd ./plugins/inference-plugin && npm run build:publish\" \"cd ./plugins/model-management-plugin && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm run build:publish\"",
|
||||
"build": "yarn build:web && yarn build:electron",
|
||||
"build:darwin": "yarn build:web && yarn workspace jan build:darwin",
|
||||
"build:win32": "yarn build:web && yarn workspace jan build:win32",
|
||||
|
||||
1
plugins/data-plugin/@types/global.d.ts
vendored
1
plugins/data-plugin/@types/global.d.ts
vendored
@ -1,2 +1,3 @@
|
||||
declare const PLUGIN_NAME: string;
|
||||
declare const MODULE_PATH: string;
|
||||
declare const PLUGIN_CATALOG: string;
|
||||
|
||||
@ -216,6 +216,9 @@ export function init({ register }: { register: RegisterExtensionPoint }) {
|
||||
register(DataService.GetBotById, getBotById.name, getBotById);
|
||||
register(DataService.DeleteBot, deleteBot.name, deleteBot);
|
||||
register(DataService.UpdateBot, updateBot.name, updateBot);
|
||||
|
||||
// for plugin manifest
|
||||
register(DataService.GetPluginManifest, getPluginManifest.name, getPluginManifest)
|
||||
}
|
||||
|
||||
function getConversations(): Promise<any> {
|
||||
@ -323,3 +326,20 @@ function getBotById(botId: string): Promise<any> {
|
||||
return Promise.reject(err);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the plugin manifest by importing the remote model catalog and clearing the cache to get the latest version.
|
||||
* A timestamp is added to the URL to prevent caching.
|
||||
* @returns A Promise that resolves with the plugin manifest.
|
||||
*/
|
||||
function getPluginManifest(): Promise<any> {
|
||||
// Clear cache to get the latest model catalog
|
||||
delete require.cache[
|
||||
require.resolve(/* webpackIgnore: true */ PLUGIN_CATALOG)
|
||||
];
|
||||
// Import the remote model catalog
|
||||
// Add a timestamp to the URL to prevent caching
|
||||
return import(
|
||||
/* webpackIgnore: true */ PLUGIN_CATALOG + `?t=${Date.now()}`
|
||||
).then((module) => module.default);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@janhq/data-plugin",
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.14",
|
||||
"description": "The Data Connector provides easy access to a data API using the PouchDB engine. It offers accessible data management capabilities.",
|
||||
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/circle-stack.svg",
|
||||
"main": "dist/esm/index.js",
|
||||
@ -12,7 +12,7 @@
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc -b ./config/tsconfig.esm.json && tsc -b ./config/tsconfig.cjs.json && webpack --config webpack.config.js",
|
||||
"postinstall": "rimraf *.tgz --glob && npm run build",
|
||||
"postinstall": "electron-rebuild -f -w leveldown@5.6.0 --arch=arm64 -v 26.2.1 && rimraf *.tgz --glob && npm run build",
|
||||
"build:publish": "npm pack && cpx *.tgz ../../electron/core/pre-install"
|
||||
},
|
||||
"exports": {
|
||||
@ -40,7 +40,9 @@
|
||||
"node_modules"
|
||||
],
|
||||
"dependencies": {
|
||||
"@janhq/core": "^0.1.6",
|
||||
"@janhq/core": "^0.1.7",
|
||||
"electron": "26.2.1",
|
||||
"electron-rebuild": "^3.2.9",
|
||||
"pouchdb-find": "^8.0.1",
|
||||
"pouchdb-node": "^8.0.1"
|
||||
},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2016",
|
||||
"module": "ES6",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "./dist",
|
||||
"esModuleInterop": true,
|
||||
|
||||
@ -19,6 +19,9 @@ module.exports = {
|
||||
new webpack.DefinePlugin({
|
||||
PLUGIN_NAME: JSON.stringify(packageJson.name),
|
||||
MODULE_PATH: JSON.stringify(`${packageJson.name}/${packageJson.module}`),
|
||||
PLUGIN_CATALOG: JSON.stringify(
|
||||
"https://cdn.jsdelivr.net/npm/@janhq/plugin-catalog@latest/dist/index.js"
|
||||
),
|
||||
}),
|
||||
],
|
||||
output: {
|
||||
|
||||
@ -9,13 +9,17 @@ import {
|
||||
} from "@janhq/core";
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
const initModel = async (product) => invokePluginFunc(MODULE_PATH, "initModel", product);
|
||||
const initModel = async (product) =>
|
||||
invokePluginFunc(MODULE_PATH, "initModel", product);
|
||||
|
||||
const stopModel = () => {
|
||||
invokePluginFunc(MODULE_PATH, "killSubprocess");
|
||||
};
|
||||
|
||||
function requestInference(recentMessages: any[], bot?: any): Observable<string> {
|
||||
function requestInference(
|
||||
recentMessages: any[],
|
||||
bot?: any
|
||||
): Observable<string> {
|
||||
return new Observable((subscriber) => {
|
||||
const requestBody = JSON.stringify({
|
||||
messages: recentMessages,
|
||||
@ -63,16 +67,21 @@ function requestInference(recentMessages: any[], bot?: any): Observable<string>
|
||||
}
|
||||
subscriber.complete();
|
||||
})
|
||||
.catch(subscriber.error);
|
||||
.catch((err) => subscriber.error(err));
|
||||
});
|
||||
}
|
||||
|
||||
async function retrieveLastTenMessages(conversationId: string, bot?: any) {
|
||||
// TODO: Common collections should be able to access via core functions instead of store
|
||||
const messageHistory = (await store.findMany("messages", { conversationId }, [{ createdAt: "asc" }])) ?? [];
|
||||
const messageHistory =
|
||||
(await store.findMany("messages", { conversationId }, [
|
||||
{ createdAt: "asc" },
|
||||
])) ?? [];
|
||||
|
||||
let recentMessages = messageHistory
|
||||
.filter((e) => e.message !== "" && (e.user === "user" || e.user === "assistant"))
|
||||
.filter(
|
||||
(e) => e.message !== "" && (e.user === "user" || e.user === "assistant")
|
||||
)
|
||||
.slice(-9)
|
||||
.map((message) => ({
|
||||
content: message.message.trim(),
|
||||
@ -81,10 +90,13 @@ async function retrieveLastTenMessages(conversationId: string, bot?: any) {
|
||||
|
||||
if (bot && bot.systemPrompt) {
|
||||
// append bot's system prompt
|
||||
recentMessages = [{
|
||||
recentMessages = [
|
||||
{
|
||||
content: `[INST] ${bot.systemPrompt}`,
|
||||
role: 'system'
|
||||
},...recentMessages];
|
||||
role: "system",
|
||||
},
|
||||
...recentMessages,
|
||||
];
|
||||
}
|
||||
|
||||
console.debug(`Last 10 messages: ${JSON.stringify(recentMessages, null, 2)}`);
|
||||
@ -93,13 +105,19 @@ async function retrieveLastTenMessages(conversationId: string, bot?: any) {
|
||||
}
|
||||
|
||||
async function handleMessageRequest(data: NewMessageRequest) {
|
||||
const conversation = await store.findOne("conversations", data.conversationId);
|
||||
const conversation = await store.findOne(
|
||||
"conversations",
|
||||
data.conversationId
|
||||
);
|
||||
let bot = undefined;
|
||||
if (conversation.botId != null) {
|
||||
bot = await store.findOne("bots", conversation.botId);
|
||||
}
|
||||
|
||||
const recentMessages = await retrieveLastTenMessages(data.conversationId, bot);
|
||||
const recentMessages = await retrieveLastTenMessages(
|
||||
data.conversationId,
|
||||
bot
|
||||
);
|
||||
const message = {
|
||||
...data,
|
||||
message: "",
|
||||
@ -124,7 +142,9 @@ async function handleMessageRequest(data: NewMessageRequest) {
|
||||
await store.updateOne("messages", message._id, message);
|
||||
},
|
||||
error: async (err) => {
|
||||
message.message = message.message.trim() + "\n" + "Error occurred: " + err;
|
||||
message.message =
|
||||
message.message.trim() + "\n" + "Error occurred: " + err.message;
|
||||
events.emit(EventName.OnMessageResponseUpdate, message);
|
||||
// TODO: Common collections should be able to access via core functions instead of store
|
||||
await store.updateOne("messages", message._id, message);
|
||||
},
|
||||
@ -140,7 +160,10 @@ async function inferenceRequest(data: NewMessageRequest): Promise<any> {
|
||||
};
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const recentMessages = await retrieveLastTenMessages(data.conversationId);
|
||||
requestInference([...recentMessages, { role: "user", content: data.message }]).subscribe({
|
||||
requestInference([
|
||||
...recentMessages,
|
||||
{ role: "user", content: data.message },
|
||||
]).subscribe({
|
||||
next: (content) => {
|
||||
message.message = content;
|
||||
},
|
||||
@ -166,5 +189,9 @@ export function init({ register }) {
|
||||
register(PluginService.OnStart, PLUGIN_NAME, onStart);
|
||||
register(InferenceService.InitModel, initModel.name, initModel);
|
||||
register(InferenceService.StopModel, stopModel.name, stopModel);
|
||||
register(InferenceService.InferenceRequest, inferenceRequest.name, inferenceRequest);
|
||||
register(
|
||||
InferenceService.InferenceRequest,
|
||||
inferenceRequest.name,
|
||||
inferenceRequest
|
||||
);
|
||||
}
|
||||
|
||||
@ -14,34 +14,28 @@ const initModel = (fileName) => {
|
||||
if (!fileName) {
|
||||
reject("Model not found, please download again.");
|
||||
}
|
||||
if (subprocess) {
|
||||
console.error("A subprocess is already running. Attempt to kill then reinit.");
|
||||
killSubprocess();
|
||||
}
|
||||
resolve(fileName);
|
||||
})
|
||||
// Kill port process if it is already in use
|
||||
.then((fileName) =>
|
||||
tcpPortUsed
|
||||
.waitUntilFree(PORT, 200, 3000)
|
||||
.catch(() => killPortProcess(PORT))
|
||||
.then(() => fileName)
|
||||
)
|
||||
// Spawn Nitro subprocess to load model
|
||||
.then(() => {
|
||||
return tcpPortUsed.check(PORT, "127.0.0.1").then((inUse) => {
|
||||
if (!inUse) {
|
||||
let binaryFolder = path.join(__dirname, "nitro"); // Current directory by default
|
||||
let binaryName;
|
||||
|
||||
if (process.platform === "win32") {
|
||||
// Todo: Need to check for CUDA support to switch between CUDA and non-CUDA binaries
|
||||
binaryName = "nitro_windows_amd64_cuda.exe";
|
||||
binaryName = "nitro_start_windows.bat";
|
||||
} else if (process.platform === "darwin") {
|
||||
// Mac OS platform
|
||||
binaryName = process.arch === "arm64" ? "nitro_mac_arm64" : "nitro_mac_intel";
|
||||
binaryName =
|
||||
process.arch === "arm64"
|
||||
? "nitro_mac_arm64"
|
||||
: "nitro_mac_intel";
|
||||
} else {
|
||||
// Linux
|
||||
// Todo: Need to check for CUDA support to switch between CUDA and non-CUDA binaries
|
||||
binaryName = "nitro_linux_amd64_cuda"; // For other platforms
|
||||
binaryName = "nitro_start_linux.sh"; // For other platforms
|
||||
}
|
||||
|
||||
const binaryPath = path.join(binaryFolder, binaryName);
|
||||
@ -62,6 +56,8 @@ const initModel = (fileName) => {
|
||||
console.log(`child process exited with code ${code}`);
|
||||
subprocess = null;
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
.then(() => tcpPortUsed.waitUntilUsed(PORT, 300, 30000))
|
||||
.then(() => {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
6
plugins/inference-plugin/nitro/nitro_start_linux.sh
Executable file
6
plugins/inference-plugin/nitro/nitro_start_linux.sh
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
# Attempt to run the nitro_linux_amd64_cuda file and if it fails, run nitro_linux_amd64
|
||||
./nitro_linux_amd64_cuda || (echo "nitro_linux_amd64_cuda encountered an error, attempting to run nitro_linux_amd64..." && ./nitro_linux_amd64)
|
||||
10
plugins/inference-plugin/nitro/nitro_start_windows.bat
Executable file
10
plugins/inference-plugin/nitro/nitro_start_windows.bat
Executable file
@ -0,0 +1,10 @@
|
||||
@echo off
|
||||
|
||||
rem Attempt to run nitro_windows_amd64_cuda.exe
|
||||
nitro_windows_amd64_cuda.exe
|
||||
|
||||
rem Check the exit code of the previous command
|
||||
if %errorlevel% neq 0 (
|
||||
echo nitro_windows_amd64_cuda.exe encountered an error, attempting to run nitro_windows_amd64.exe...
|
||||
nitro_windows_amd64.exe
|
||||
)
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@janhq/inference-plugin",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.14",
|
||||
"description": "Inference Plugin, powered by @janhq/nitro, bring a high-performance Llama model inference in pure C++.",
|
||||
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/command-line.svg",
|
||||
"main": "dist/index.js",
|
||||
|
||||
@ -8,19 +8,24 @@ import {
|
||||
} from "@janhq/core";
|
||||
import { parseToModel } from "./helper";
|
||||
|
||||
const downloadModel = (product) => downloadFile(product.downloadUrl, product.fileName);
|
||||
const downloadModel = (product) =>
|
||||
downloadFile(product.downloadUrl, product.fileName);
|
||||
|
||||
const deleteModel = (path) => deleteFile(path);
|
||||
|
||||
async function getConfiguredModels() {
|
||||
// Clear cache to get the latest model catalog
|
||||
delete require.cache[MODEL_CATALOG_URL];
|
||||
|
||||
// Import the remote model catalog
|
||||
const module = require(MODEL_CATALOG_URL);
|
||||
return module.default.map((e) => {
|
||||
/**
|
||||
* Retrieves a list of configured models from the model catalog URL.
|
||||
* @returns A Promise that resolves to an array of configured models.
|
||||
*/
|
||||
async function getConfiguredModels(): Promise<any> {
|
||||
// Add a timestamp to the URL to prevent caching
|
||||
return import(
|
||||
/* webpackIgnore: true */ MODEL_CATALOG_URL + `?t=${Date.now()}`
|
||||
).then((module) =>
|
||||
module.default.map((e) => {
|
||||
return parseToModel(e);
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +49,11 @@ function storeModel(model: any) {
|
||||
* @param model Product
|
||||
*/
|
||||
function updateFinishedDownloadAt(_id: string): Promise<any> {
|
||||
return store.updateMany("models", { _id }, { time: Date.now(), finishDownloadAt: 1 });
|
||||
return store.updateMany(
|
||||
"models",
|
||||
{ _id },
|
||||
{ time: Date.now(), finishDownloadAt: 1 }
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,14 +93,38 @@ function onStart() {
|
||||
export function init({ register }: { register: RegisterExtensionPoint }) {
|
||||
register(PluginService.OnStart, PLUGIN_NAME, onStart);
|
||||
|
||||
register(ModelManagementService.DownloadModel, downloadModel.name, downloadModel);
|
||||
register(
|
||||
ModelManagementService.DownloadModel,
|
||||
downloadModel.name,
|
||||
downloadModel
|
||||
);
|
||||
register(ModelManagementService.DeleteModel, deleteModel.name, deleteModel);
|
||||
register(ModelManagementService.GetConfiguredModels, getConfiguredModels.name, getConfiguredModels);
|
||||
register(
|
||||
ModelManagementService.GetConfiguredModels,
|
||||
getConfiguredModels.name,
|
||||
getConfiguredModels
|
||||
);
|
||||
|
||||
register(ModelManagementService.StoreModel, storeModel.name, storeModel);
|
||||
register(ModelManagementService.UpdateFinishedDownloadAt, updateFinishedDownloadAt.name, updateFinishedDownloadAt);
|
||||
register(
|
||||
ModelManagementService.UpdateFinishedDownloadAt,
|
||||
updateFinishedDownloadAt.name,
|
||||
updateFinishedDownloadAt
|
||||
);
|
||||
|
||||
register(ModelManagementService.DeleteDownloadModel, deleteDownloadModel.name, deleteDownloadModel);
|
||||
register(ModelManagementService.GetModelById, getModelById.name, getModelById);
|
||||
register(ModelManagementService.GetFinishedDownloadModels, getFinishedDownloadModels.name, getFinishedDownloadModels);
|
||||
register(
|
||||
ModelManagementService.DeleteDownloadModel,
|
||||
deleteDownloadModel.name,
|
||||
deleteDownloadModel
|
||||
);
|
||||
register(
|
||||
ModelManagementService.GetModelById,
|
||||
getModelById.name,
|
||||
getModelById
|
||||
);
|
||||
register(
|
||||
ModelManagementService.GetFinishedDownloadModels,
|
||||
getFinishedDownloadModels.name,
|
||||
getFinishedDownloadModels
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@janhq/model-management-plugin",
|
||||
"version": "1.0.8",
|
||||
"version": "1.0.9",
|
||||
"description": "Model Management Plugin provides model exploration and seamless downloads",
|
||||
"icon": "https://raw.githubusercontent.com/tailwindlabs/heroicons/88e98b0c2b458553fbadccddc2d2f878edc0387b/src/20/solid/queue-list.svg",
|
||||
"main": "dist/index.js",
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { useAtomValue } from 'jotai'
|
||||
import React from 'react'
|
||||
import ModelTable from '../ModelTable'
|
||||
import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom'
|
||||
import { activeAssistantModelAtom } from '@helpers/atoms/Model.atom'
|
||||
|
||||
const ActiveModelTable: React.FC = () => {
|
||||
const activeModel = useAtomValue(activeAssistantModelAtom)
|
||||
|
||||
@ -2,8 +2,7 @@ import DownloadModelContent from '../DownloadModelContent'
|
||||
import ModelDownloadButton from '../ModelDownloadButton'
|
||||
import ModelDownloadingButton from '../ModelDownloadingButton'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom'
|
||||
import { AssistantModel } from '@/_models/AssistantModel'
|
||||
import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom'
|
||||
|
||||
type Props = {
|
||||
model: AssistantModel
|
||||
|
||||
@ -7,7 +7,7 @@ type Props = {
|
||||
|
||||
const Avatar: React.FC<Props> = ({ allowEdit = false }) => (
|
||||
<div className="mx-auto flex flex-col gap-5">
|
||||
<span className="mx-auto inline-block h-14 w-14 overflow-hidden rounded-full bg-gray-100">
|
||||
<span className="mx-auto inline-block h-10 w-10 overflow-hidden rounded-full bg-gray-100">
|
||||
<svg
|
||||
className="mx-auto h-full w-full text-gray-300"
|
||||
fill="currentColor"
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
import { useSetAtom } from 'jotai'
|
||||
import { InformationCircleIcon } from '@heroicons/react/24/outline'
|
||||
import SendButton from '../SendButton'
|
||||
import { showingAdvancedPromptAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import { showingAdvancedPromptAtom } from '@helpers/atoms/Modal.atom'
|
||||
|
||||
const BasicPromptAccessories: React.FC = () => {
|
||||
const setShowingAdvancedPrompt = useSetAtom(showingAdvancedPromptAtom)
|
||||
@ -11,7 +11,7 @@ const BasicPromptAccessories: React.FC = () => {
|
||||
const shouldShowAdvancedPrompt = false
|
||||
|
||||
return (
|
||||
<div className="absolute inset-x-0 bottom-0 flex justify-between py-2 pl-3 pr-2">
|
||||
<div className="absolute inset-x-0 bottom-0 flex justify-between p-3">
|
||||
{/* Add future accessories here, e.g upload a file */}
|
||||
<div className="flex items-center space-x-5">
|
||||
<div className="flex items-center">
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import { useSetAtom } from 'jotai'
|
||||
import { ChevronLeftIcon } from '@heroicons/react/24/outline'
|
||||
import { showingAdvancedPromptAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import { showingAdvancedPromptAtom } from '@helpers/atoms/Modal.atom'
|
||||
|
||||
const BasicPromptButton: React.FC = () => {
|
||||
const setShowingAdvancedPrompt = useSetAtom(showingAdvancedPromptAtom)
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
'use client'
|
||||
|
||||
import { currentPromptAtom } from '@/_helpers/JotaiWrapper'
|
||||
import { getActiveConvoIdAtom } from '@/_helpers/atoms/Conversation.atom'
|
||||
import { selectedModelAtom } from '@/_helpers/atoms/Model.atom'
|
||||
import useCreateConversation from '@/_hooks/useCreateConversation'
|
||||
import useInitModel from '@/_hooks/useInitModel'
|
||||
import useSendChatMessage from '@/_hooks/useSendChatMessage'
|
||||
import { currentPromptAtom } from '@helpers/JotaiWrapper'
|
||||
import { getActiveConvoIdAtom } from '@helpers/atoms/Conversation.atom'
|
||||
import { selectedModelAtom } from '@helpers/atoms/Model.atom'
|
||||
import useCreateConversation from '@hooks/useCreateConversation'
|
||||
import useSendChatMessage from '@hooks/useSendChatMessage'
|
||||
import { useAtom, useAtomValue } from 'jotai'
|
||||
import { ChangeEvent, useEffect, useRef } from 'react'
|
||||
|
||||
@ -16,8 +15,6 @@ const BasicPromptInput: React.FC = () => {
|
||||
const { sendChatMessage } = useSendChatMessage()
|
||||
const { requestCreateConvo } = useCreateConversation()
|
||||
|
||||
const { initModel } = useInitModel()
|
||||
|
||||
const textareaRef = useRef<HTMLTextAreaElement>(null)
|
||||
|
||||
const handleKeyDown = async (
|
||||
@ -35,7 +32,6 @@ const BasicPromptInput: React.FC = () => {
|
||||
}
|
||||
|
||||
await requestCreateConvo(selectedModel)
|
||||
await initModel(selectedModel)
|
||||
sendChatMessage()
|
||||
}
|
||||
}
|
||||
@ -68,7 +64,7 @@ const BasicPromptInput: React.FC = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden rounded-lg shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-indigo-600">
|
||||
<div className=" border-border rounded-lg border shadow-sm">
|
||||
<textarea
|
||||
ref={textareaRef}
|
||||
onKeyDown={handleKeyDown}
|
||||
@ -76,7 +72,7 @@ const BasicPromptInput: React.FC = () => {
|
||||
onChange={handleMessageChange}
|
||||
name="comment"
|
||||
id="comment"
|
||||
className="block w-full resize-none border-0 bg-transparent py-1.5 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6"
|
||||
className="text-background-reverse block w-full resize-none border-0 bg-transparent py-1.5 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6"
|
||||
placeholder="Message ..."
|
||||
rows={1}
|
||||
style={{ overflow: 'auto' }}
|
||||
|
||||
@ -1,56 +1,58 @@
|
||||
import { activeBotAtom } from "@/_helpers/atoms/Bot.atom";
|
||||
import { activeBotAtom } from '@helpers/atoms/Bot.atom'
|
||||
import {
|
||||
MainViewState,
|
||||
setMainViewStateAtom,
|
||||
} from "@/_helpers/atoms/MainView.atom";
|
||||
import useCreateConversation from "@/_hooks/useCreateConversation";
|
||||
import useDeleteBot from "@/_hooks/useDeleteBot";
|
||||
import { useAtomValue, useSetAtom } from "jotai";
|
||||
import React from "react";
|
||||
import PrimaryButton from "../PrimaryButton";
|
||||
import ExpandableHeader from "../ExpandableHeader";
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
import useCreateConversation from '@hooks/useCreateConversation'
|
||||
import useDeleteBot from '@hooks/useDeleteBot'
|
||||
import { useAtomValue, useSetAtom } from 'jotai'
|
||||
import React from 'react'
|
||||
import PrimaryButton from '../PrimaryButton'
|
||||
import ExpandableHeader from '../ExpandableHeader'
|
||||
|
||||
const BotInfo: React.FC = () => {
|
||||
const { deleteBot } = useDeleteBot();
|
||||
const { createConvoByBot } = useCreateConversation();
|
||||
const setMainView = useSetAtom(setMainViewStateAtom);
|
||||
const botInfo = useAtomValue(activeBotAtom);
|
||||
if (!botInfo) return null;
|
||||
const { deleteBot } = useDeleteBot()
|
||||
const { createConvoByBot } = useCreateConversation()
|
||||
const setMainView = useSetAtom(setMainViewStateAtom)
|
||||
const botInfo = useAtomValue(activeBotAtom)
|
||||
if (!botInfo) return null
|
||||
|
||||
const onNewChatClicked = () => {
|
||||
if (!botInfo) {
|
||||
alert("No bot selected");
|
||||
return;
|
||||
alert('No bot selected')
|
||||
return
|
||||
}
|
||||
|
||||
createConvoByBot(botInfo);
|
||||
};
|
||||
createConvoByBot(botInfo)
|
||||
}
|
||||
|
||||
const onDeleteBotClick = async () => {
|
||||
// TODO: display confirmation diaglog
|
||||
const result = await deleteBot(botInfo._id);
|
||||
if (result === "success") {
|
||||
setMainView(MainViewState.Welcome);
|
||||
const result = await deleteBot(botInfo._id)
|
||||
if (result === 'success') {
|
||||
setMainView(MainViewState.Welcome)
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2 mx-1 my-1">
|
||||
<ExpandableHeader title="BOT INFO" expanded={true} onClick={() => {}} />
|
||||
<div className="mx-1 my-1 flex flex-col gap-2">
|
||||
<ExpandableHeader title="BOT INFO" />
|
||||
|
||||
<div className="flex flex-col">
|
||||
<label>{botInfo.name}</label>
|
||||
<PrimaryButton onClick={onNewChatClicked} title="New chat" />
|
||||
<span>{botInfo.description}</span>
|
||||
<label className="mb-2">{botInfo.name}</label>
|
||||
<span className="text-muted-foreground">{botInfo.description}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col space-y-2">
|
||||
<PrimaryButton onClick={onNewChatClicked} title="New chat" />
|
||||
<PrimaryButton
|
||||
title="Delete bot"
|
||||
onClick={onDeleteBotClick}
|
||||
className="bg-red-500 hover:bg-red-400"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default BotInfo;
|
||||
export default BotInfo
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { activeBotAtom } from '@/_helpers/atoms/Bot.atom'
|
||||
import { activeBotAtom } from '@helpers/atoms/Bot.atom'
|
||||
import { useAtomValue, useSetAtom } from 'jotai'
|
||||
import React from 'react'
|
||||
import Avatar from '../Avatar'
|
||||
import PrimaryButton from '../PrimaryButton'
|
||||
import useCreateConversation from '@/_hooks/useCreateConversation'
|
||||
import useDeleteBot from '@/_hooks/useDeleteBot'
|
||||
import useCreateConversation from '@hooks/useCreateConversation'
|
||||
import useDeleteBot from '@hooks/useDeleteBot'
|
||||
import {
|
||||
setMainViewStateAtom,
|
||||
MainViewState,
|
||||
} from '@/_helpers/atoms/MainView.atom'
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
|
||||
const BotInfoContainer: React.FC = () => {
|
||||
const activeBot = useAtomValue(activeBotAtom)
|
||||
@ -44,9 +44,7 @@ const BotInfoContainer: React.FC = () => {
|
||||
<div className="flex h-full w-full pt-4">
|
||||
<div className="mx-auto flex w-[672px] min-w-max flex-col gap-4">
|
||||
<Avatar />
|
||||
<h1 className="text-center text-2xl font-bold">
|
||||
{activeBot?.name}
|
||||
</h1>
|
||||
<h1 className="text-center text-2xl font-bold">{activeBot?.name}</h1>
|
||||
<div className="flex gap-4">
|
||||
<PrimaryButton
|
||||
fullWidth
|
||||
@ -55,7 +53,7 @@ const BotInfoContainer: React.FC = () => {
|
||||
/>
|
||||
<PrimaryButton
|
||||
fullWidth
|
||||
className='bg-red-500 hover:bg-red-400'
|
||||
className="bg-red-500 hover:bg-red-400"
|
||||
title="Delete bot"
|
||||
onClick={onDeleteBotClick}
|
||||
/>
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { activeBotAtom } from '@/_helpers/atoms/Bot.atom'
|
||||
import { showingBotListModalAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import useGetBots from '@/_hooks/useGetBots'
|
||||
import { Bot } from '@/_models/Bot'
|
||||
import { activeBotAtom } from '@helpers/atoms/Bot.atom'
|
||||
import { showingBotListModalAtom } from '@helpers/atoms/Modal.atom'
|
||||
import useGetBots from '@hooks/useGetBots'
|
||||
import { useAtom, useSetAtom } from 'jotai'
|
||||
import { rightSideBarExpandStateAtom } from '@helpers/atoms/SideBarExpand.atom'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import Avatar from '../Avatar'
|
||||
import {
|
||||
MainViewState,
|
||||
setMainViewStateAtom,
|
||||
} from '@/_helpers/atoms/MainView.atom'
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
|
||||
const BotListContainer: React.FC = () => {
|
||||
const [open, setOpen] = useAtom(showingBotListModalAtom)
|
||||
@ -16,6 +16,7 @@ const BotListContainer: React.FC = () => {
|
||||
const [activeBot, setActiveBot] = useAtom(activeBotAtom)
|
||||
const [bots, setBots] = useState<Bot[]>([])
|
||||
const { getAllBots } = useGetBots()
|
||||
const setRightSideBarVisibility = useSetAtom(rightSideBarExpandStateAtom)
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
@ -23,31 +24,34 @@ const BotListContainer: React.FC = () => {
|
||||
setBots(res)
|
||||
})
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [open])
|
||||
|
||||
const onBotSelected = (bot: Bot) => {
|
||||
if (bot._id !== activeBot?._id) {
|
||||
setMainView(MainViewState.BotInfo)
|
||||
setActiveBot(bot)
|
||||
setRightSideBarVisibility(true)
|
||||
}
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden bg-white shadow sm:rounded-md">
|
||||
<div className="bg-background/50 border-border overflow-hidden border sm:rounded-md">
|
||||
<ul role="list" className="divide-y divide-gray-200">
|
||||
{bots.map((bot) => (
|
||||
{bots.map((bot, i) => (
|
||||
<li
|
||||
role="button"
|
||||
key={bot._id}
|
||||
className="flex gap-4 p-4 hover:bg-hover-light sm:px-6"
|
||||
key={i}
|
||||
className="flex items-center gap-4 p-4 hover:bg-hover-light sm:px-6"
|
||||
onClick={() => onBotSelected(bot)}
|
||||
>
|
||||
<Avatar />
|
||||
|
||||
<div className="flex flex-1 flex-col">
|
||||
<p className="line-clamp-1">{bot.name}</p>
|
||||
<p className="line-clamp-1 text-ellipsis">{bot._id}</p>
|
||||
<p className="text-muted-foreground mt-1 line-clamp-1 text-ellipsis">
|
||||
{bot._id}
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { showingBotListModalAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import { showingBotListModalAtom } from '@helpers/atoms/Modal.atom'
|
||||
import { Dialog, Transition } from '@headlessui/react'
|
||||
import { useAtom } from 'jotai'
|
||||
import React, { Fragment } from 'react'
|
||||
@ -19,10 +19,10 @@ const BotListModal: React.FC = () => {
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
|
||||
<div className="fixed inset-0 z-40 h-full bg-gray-950/90 transition-opacity dark:backdrop-blur-sm" />
|
||||
</Transition.Child>
|
||||
|
||||
<div className="fixed inset-0 z-10 w-screen overflow-y-auto">
|
||||
<div className="fixed inset-0 z-50 w-screen overflow-y-auto">
|
||||
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||
<Transition.Child
|
||||
as={Fragment}
|
||||
@ -33,8 +33,8 @@ const BotListModal: React.FC = () => {
|
||||
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
|
||||
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||
>
|
||||
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-sm sm:p-6">
|
||||
<h1 className="mb-4 text-lg text-black font-bold">Your bots</h1>
|
||||
<Dialog.Panel className="border-border bg-background/90 relative transform overflow-hidden rounded-lg border px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6">
|
||||
<h1 className="mb-4 font-bold">Your bots</h1>
|
||||
<BotListContainer />
|
||||
</Dialog.Panel>
|
||||
</Transition.Child>
|
||||
|
||||
@ -1,26 +1,26 @@
|
||||
import Image from "next/image";
|
||||
import Image from 'next/image'
|
||||
|
||||
const BotPreview: React.FC = () => {
|
||||
return (
|
||||
<div className="flex pb-2 flex-col border border-gray-400 min-h-[235px] gap-2 overflow-hidden rounded-lg">
|
||||
<div className="flex items-center justify-center p-2 bg-gray-400">
|
||||
<div className="flex min-h-[235px] flex-col gap-2 overflow-hidden rounded-lg border border-gray-400 pb-2">
|
||||
<div className="flex items-center justify-center bg-gray-400 p-2">
|
||||
<Image
|
||||
className="rounded-md"
|
||||
src={
|
||||
"https://i.pinimg.com/564x/52/b1/6f/52b16f96f52221d48bea716795ccc89a.jpg"
|
||||
'https://i.pinimg.com/564x/52/b1/6f/52b16f96f52221d48bea716795ccc89a.jpg'
|
||||
}
|
||||
width={32}
|
||||
height={32}
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center text-xs text-gray-400 gap-1 px-1">
|
||||
<div className="flex-grow mx-1 border-b border-gray-400"></div>
|
||||
<div className="flex items-center gap-1 px-1 text-xs text-gray-400">
|
||||
<div className="mx-1 flex-grow border-b border-gray-400"></div>
|
||||
Context cleared
|
||||
<div className="flex-grow mx-1 border-b border-gray-400"></div>
|
||||
<div className="mx-1 flex-grow border-b border-gray-400"></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default BotPreview;
|
||||
export default BotPreview
|
||||
|
||||
@ -1,28 +1,26 @@
|
||||
import { activeBotAtom } from '@/_helpers/atoms/Bot.atom'
|
||||
import { activeBotAtom } from '@helpers/atoms/Bot.atom'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import React, { useState } from 'react'
|
||||
import ExpandableHeader from '../ExpandableHeader'
|
||||
import { useDebouncedCallback } from 'use-debounce'
|
||||
import useUpdateBot from '@/_hooks/useUpdateBot'
|
||||
import ProgressSetting from '../ProgressSetting'
|
||||
import { set } from 'react-hook-form'
|
||||
import useUpdateBot from '@hooks/useUpdateBot'
|
||||
import { formatTwoDigits } from '@utils/converter'
|
||||
|
||||
const delayBeforeUpdateInMs = 1000
|
||||
|
||||
const BotSetting: React.FC = () => {
|
||||
const activeBot = useAtomValue(activeBotAtom)
|
||||
const [temperature, setTemperature] = useState(0)
|
||||
const [maxTokens, setMaxTokens] = useState(0)
|
||||
const [frequencyPenalty, setFrequencyPenalty] = useState(0)
|
||||
const [presencePenalty, setPresencePenalty] = useState(0)
|
||||
const [temperature, setTemperature] = useState(
|
||||
activeBot?.customTemperature ?? 0
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (!activeBot) return
|
||||
setMaxTokens(activeBot.maxTokens ?? 0)
|
||||
setTemperature(activeBot.customTemperature ?? 0)
|
||||
setFrequencyPenalty(activeBot.frequencyPenalty ?? 0)
|
||||
setPresencePenalty(activeBot.presencePenalty ?? 0)
|
||||
}, [activeBot?._id])
|
||||
const [maxTokens, setMaxTokens] = useState(activeBot?.maxTokens ?? 0)
|
||||
const [frequencyPenalty, setFrequencyPenalty] = useState(
|
||||
activeBot?.frequencyPenalty ?? 0
|
||||
)
|
||||
const [presencePenalty, setPresencePenalty] = useState(
|
||||
activeBot?.presencePenalty ?? 0
|
||||
)
|
||||
|
||||
const { updateBot } = useUpdateBot()
|
||||
|
||||
@ -60,71 +58,109 @@ const BotSetting: React.FC = () => {
|
||||
|
||||
return (
|
||||
<div className="my-3 flex flex-col">
|
||||
<ExpandableHeader
|
||||
title="BOT SETTINGS"
|
||||
expanded={true}
|
||||
onClick={() => {}}
|
||||
/>
|
||||
|
||||
<ExpandableHeader title="BOT SETTINGS" />
|
||||
<div className="mx-2 mt-3 flex flex-shrink-0 flex-col gap-4">
|
||||
{/* System prompt */}
|
||||
<div>
|
||||
<label
|
||||
htmlFor="comment"
|
||||
className="block text-sm font-medium leading-6 text-gray-900"
|
||||
>
|
||||
<label htmlFor="comment" className="block">
|
||||
System prompt
|
||||
</label>
|
||||
<div className="mt-2">
|
||||
<div className="mt-1">
|
||||
<textarea
|
||||
rows={4}
|
||||
name="comment"
|
||||
id="comment"
|
||||
className="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
|
||||
className="bg-background/80 text-background-reverse ring-border placeholder:text-muted-foreground focus:ring-accent/50 block w-full resize-none rounded-md border-0 py-1.5 text-xs leading-relaxed shadow-sm ring-1 ring-inset focus:ring-2 focus:ring-inset"
|
||||
defaultValue={activeBot.systemPrompt}
|
||||
onChange={(e) => debouncedSystemPrompt(e.target.value)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ProgressSetting
|
||||
title="Max tokens"
|
||||
{/* TODO: clean up this code */}
|
||||
{/* Max temp */}
|
||||
<p>Max tokens</p>
|
||||
<div className="mt-2 flex items-center gap-2">
|
||||
<input
|
||||
className="flex-1"
|
||||
type="range"
|
||||
defaultValue={activeBot.maxTokens ?? 0}
|
||||
min={0}
|
||||
max={4096}
|
||||
step={1}
|
||||
value={maxTokens}
|
||||
onValueChanged={(value) => debouncedMaxToken(value)}
|
||||
onChange={(e) => {
|
||||
const value = Number(e.target.value)
|
||||
setMaxTokens(value)
|
||||
debouncedMaxToken(value)
|
||||
}}
|
||||
/>
|
||||
<span className="border-accent rounded-md border px-2 py-1">
|
||||
{formatTwoDigits(maxTokens)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<ProgressSetting
|
||||
<p>Frequency penalty</p>
|
||||
<div className="mt-2 flex items-center gap-2">
|
||||
<input
|
||||
className="flex-1"
|
||||
type="range"
|
||||
defaultValue={activeBot.frequencyPenalty ?? 0}
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.01}
|
||||
title="Temperature"
|
||||
value={temperature}
|
||||
onValueChanged={(value) => debouncedTemperature(value)}
|
||||
onChange={(e) => {
|
||||
const value = Number(e.target.value)
|
||||
setFrequencyPenalty(value)
|
||||
debouncedFreqPenalty(value)
|
||||
}}
|
||||
/>
|
||||
<span className="border-accent rounded-md border px-2 py-1">
|
||||
{formatTwoDigits(frequencyPenalty)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<ProgressSetting
|
||||
title="Frequency penalty"
|
||||
value={frequencyPenalty}
|
||||
<p>Presence penalty</p>
|
||||
<div className="mt-2 flex items-center gap-2">
|
||||
<input
|
||||
className="flex-1"
|
||||
type="range"
|
||||
defaultValue={activeBot.maxTokens ?? 0}
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.01}
|
||||
onValueChanged={(value) => debouncedFreqPenalty(value)}
|
||||
/>
|
||||
|
||||
<ProgressSetting
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.01}
|
||||
title="Presence penalty"
|
||||
value={presencePenalty}
|
||||
onValueChanged={(value) => {
|
||||
onChange={(e) => {
|
||||
const value = Number(e.target.value)
|
||||
setPresencePenalty(value)
|
||||
debouncedPresencePenalty(value)
|
||||
}}
|
||||
/>
|
||||
<span className="border-accent rounded-md border px-2 py-1">
|
||||
{formatTwoDigits(presencePenalty)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Custom temp */}
|
||||
<p>Temperature</p>
|
||||
<div className="mt-2 flex items-center gap-2">
|
||||
<input
|
||||
className="flex-1"
|
||||
type="range"
|
||||
id="volume"
|
||||
name="volume"
|
||||
defaultValue={activeBot.customTemperature ?? 0}
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.01"
|
||||
onChange={(e) => {
|
||||
const newTemp = Number(e.target.value)
|
||||
setTemperature(newTemp)
|
||||
debouncedTemperature(Number(e.target.value))
|
||||
}}
|
||||
/>
|
||||
<span className="border-accent rounded-md border px-2 py-1">
|
||||
{formatTwoDigits(temperature)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import React from "react";
|
||||
import MainHeader from "../MainHeader";
|
||||
import MainView from "../MainView";
|
||||
import React from 'react'
|
||||
import MainHeader from '../MainHeader'
|
||||
import MainView from '../MainView'
|
||||
|
||||
const CenterContainer: React.FC = () => (
|
||||
<div className="flex-1 flex flex-col">
|
||||
<div className="flex flex-1 flex-col dark:bg-gray-950/50">
|
||||
<MainHeader />
|
||||
<MainView />
|
||||
</div>
|
||||
);
|
||||
)
|
||||
|
||||
export default React.memo(CenterContainer);
|
||||
export default React.memo(CenterContainer)
|
||||
|
||||
@ -1,61 +1,17 @@
|
||||
'use client'
|
||||
|
||||
import React, { useCallback, useRef, useState, useEffect } from 'react'
|
||||
import React from 'react'
|
||||
import ChatItem from '../ChatItem'
|
||||
import { ChatMessage } from '@/_models/ChatMessage'
|
||||
import useChatMessages from '@/_hooks/useChatMessages'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { selectAtom } from 'jotai/utils'
|
||||
import { getActiveConvoIdAtom } from '@/_helpers/atoms/Conversation.atom'
|
||||
import { chatMessages } from '@/_helpers/atoms/ChatMessage.atom'
|
||||
import useChatMessages from '@hooks/useChatMessages'
|
||||
|
||||
const ChatBody: React.FC = () => {
|
||||
const activeConversationId = useAtomValue(getActiveConvoIdAtom) ?? ''
|
||||
const messageList = useAtomValue(
|
||||
selectAtom(
|
||||
chatMessages,
|
||||
useCallback((v) => v[activeConversationId], [activeConversationId])
|
||||
)
|
||||
)
|
||||
const [content, setContent] = useState<React.JSX.Element[]>([])
|
||||
|
||||
const [offset, setOffset] = useState(0)
|
||||
const { loading, hasMore } = useChatMessages(offset)
|
||||
const intersectObs = useRef<any>(null)
|
||||
|
||||
const lastPostRef = useCallback(
|
||||
(message: ChatMessage) => {
|
||||
if (loading) return
|
||||
|
||||
if (intersectObs.current) intersectObs.current.disconnect()
|
||||
|
||||
intersectObs.current = new IntersectionObserver((entries) => {
|
||||
if (entries[0].isIntersecting && hasMore) {
|
||||
setOffset((prevOffset) => prevOffset + 5)
|
||||
}
|
||||
})
|
||||
|
||||
if (message) intersectObs.current.observe(message)
|
||||
},
|
||||
[loading, hasMore]
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
const list = messageList?.map((message, index) => {
|
||||
if (messageList?.length === index + 1) {
|
||||
return (
|
||||
// @ts-ignore
|
||||
<ChatItem ref={lastPostRef} message={message} key={message.id} />
|
||||
)
|
||||
}
|
||||
return <ChatItem message={message} key={message.id} />
|
||||
})
|
||||
setContent(list)
|
||||
}, [messageList, lastPostRef])
|
||||
const { messages } = useChatMessages()
|
||||
|
||||
return (
|
||||
<div className="scroll flex flex-1 flex-col-reverse overflow-y-auto py-4">
|
||||
{content}
|
||||
<div className="flex h-full flex-1 flex-col-reverse overflow-y-auto [&>*:nth-child(odd)]:bg-background">
|
||||
{messages.map((message) => (
|
||||
<ChatItem message={message} key={message.id} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import SimpleControlNetMessage from '../SimpleControlNetMessage'
|
||||
import SimpleImageMessage from '../SimpleImageMessage'
|
||||
import SimpleTextMessage from '../SimpleTextMessage'
|
||||
import { ChatMessage, MessageType } from '@/_models/ChatMessage'
|
||||
import { ChatMessage, MessageType } from '@models/ChatMessage'
|
||||
|
||||
|
||||
export default function renderChatMessage({
|
||||
id,
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
/* eslint-disable react/display-name */
|
||||
import React, { forwardRef } from 'react'
|
||||
import renderChatMessage from '../ChatBody/renderChatMessage'
|
||||
import { ChatMessage } from '@/_models/ChatMessage'
|
||||
|
||||
type Props = {
|
||||
message: ChatMessage
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
import React from 'react'
|
||||
import JanImage from '../JanImage'
|
||||
import { useSetAtom } from 'jotai'
|
||||
import { setActiveConvoIdAtom } from '@/_helpers/atoms/Conversation.atom'
|
||||
|
||||
const CompactLogo: React.FC = () => {
|
||||
const setActiveConvoId = useSetAtom(setActiveConvoIdAtom)
|
||||
|
||||
return (
|
||||
<button onClick={() => setActiveConvoId(undefined)}>
|
||||
<JanImage imageUrl="icons/app_icon.svg" width={28} height={28} />
|
||||
</button>
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(CompactLogo)
|
||||
@ -1,5 +1,5 @@
|
||||
import { showConfirmDeleteConversationModalAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import useDeleteConversation from '@/_hooks/useDeleteConversation'
|
||||
import { showConfirmDeleteConversationModalAtom } from '@helpers/atoms/Modal.atom'
|
||||
import useDeleteConversation from '@hooks/useDeleteConversation'
|
||||
import { Dialog, Transition } from '@headlessui/react'
|
||||
import { ExclamationTriangleIcon } from '@heroicons/react/24/outline'
|
||||
import { useAtom } from 'jotai'
|
||||
@ -31,10 +31,10 @@ const ConfirmDeleteConversationModal: React.FC = () => {
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
>
|
||||
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" />
|
||||
<div className="fixed inset-0 z-40 h-full bg-gray-950/90 transition-opacity dark:backdrop-blur-sm" />
|
||||
</Transition.Child>
|
||||
|
||||
<div className="fixed inset-0 z-10 overflow-y-auto">
|
||||
<div className="fixed inset-0 z-50 overflow-y-auto">
|
||||
<div className="flex min-h-full items-end justify-center p-4 text-center sm:items-center sm:p-0">
|
||||
<Transition.Child
|
||||
as={Fragment}
|
||||
@ -45,7 +45,7 @@ const ConfirmDeleteConversationModal: React.FC = () => {
|
||||
leaveFrom="opacity-100 translate-y-0 sm:scale-100"
|
||||
leaveTo="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95"
|
||||
>
|
||||
<Dialog.Panel className="relative transform overflow-hidden rounded-lg bg-white px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6">
|
||||
<Dialog.Panel className="relative transform overflow-hidden rounded-lg border border-border bg-background/90 px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:max-w-lg sm:p-6">
|
||||
<div className="sm:flex sm:items-start">
|
||||
<div className="mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full bg-red-100 sm:mx-0 sm:h-10 sm:w-10">
|
||||
<ExclamationTriangleIcon
|
||||
@ -54,14 +54,11 @@ const ConfirmDeleteConversationModal: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left">
|
||||
<Dialog.Title
|
||||
as="h3"
|
||||
className="text-base font-semibold leading-6 text-gray-900"
|
||||
>
|
||||
<Dialog.Title as="h3" className="font-semibold leading-6">
|
||||
Delete Conversation
|
||||
</Dialog.Title>
|
||||
<div className="mt-2">
|
||||
<p className="text-sm text-gray-500">
|
||||
<p className="text-muted-foreground">
|
||||
Are you sure you want to delete this conversation? All
|
||||
of messages will be permanently removed. This action
|
||||
cannot be undone.
|
||||
@ -72,14 +69,14 @@ const ConfirmDeleteConversationModal: React.FC = () => {
|
||||
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse">
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex w-full justify-center rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-500 sm:ml-3 sm:w-auto"
|
||||
className="inline-flex w-full justify-center rounded-md bg-red-600 px-3 py-2 text-xs font-semibold text-white shadow-sm hover:bg-red-500 sm:ml-3 sm:w-auto"
|
||||
onClick={() => onConfirmDelete()}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto"
|
||||
className="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-xs font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto"
|
||||
onClick={() => setShow(false)}
|
||||
ref={cancelButtonRef}
|
||||
>
|
||||
|
||||
@ -2,7 +2,7 @@ import React, { Fragment } from 'react'
|
||||
import { Dialog, Transition } from '@headlessui/react'
|
||||
import { QuestionMarkCircleIcon } from '@heroicons/react/24/outline'
|
||||
import { useAtom } from 'jotai'
|
||||
import { showConfirmDeleteModalAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import { showConfirmDeleteModalAtom } from '@helpers/atoms/Modal.atom'
|
||||
|
||||
const ConfirmDeleteModelModal: React.FC = () => {
|
||||
const [show, setShow] = useAtom(showConfirmDeleteModalAtom)
|
||||
|
||||
@ -2,8 +2,8 @@ import React, { Fragment } from 'react'
|
||||
import { Dialog, Transition } from '@headlessui/react'
|
||||
import { QuestionMarkCircleIcon } from '@heroicons/react/24/outline'
|
||||
import { useAtom } from 'jotai'
|
||||
import useSignOut from '@/_hooks/useSignOut'
|
||||
import { showConfirmSignOutModalAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import useSignOut from '@hooks/useSignOut'
|
||||
import { showConfirmSignOutModalAtom } from '@helpers/atoms/Modal.atom'
|
||||
|
||||
const ConfirmSignOutModal: React.FC = () => {
|
||||
const [show, setShow] = useAtom(showConfirmSignOutModalAtom)
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import React from 'react'
|
||||
import Image from 'next/image'
|
||||
import useCreateConversation from '@/_hooks/useCreateConversation'
|
||||
import { AssistantModel } from '@/_models/AssistantModel'
|
||||
import { PlayIcon } from "@heroicons/react/24/outline"
|
||||
import useCreateConversation from '@hooks/useCreateConversation'
|
||||
import { PlayIcon } from '@heroicons/react/24/outline'
|
||||
|
||||
type Props = {
|
||||
model: AssistantModel
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { AssistantModel } from '@/_models/AssistantModel'
|
||||
import ConversationalCard from '../ConversationalCard'
|
||||
import { ChatBubbleBottomCenterTextIcon } from '@heroicons/react/24/outline'
|
||||
|
||||
@ -15,7 +14,7 @@ const ConversationalList: React.FC<Props> = ({ models }) => (
|
||||
</span>
|
||||
</div>
|
||||
<div className="scroll mt-2 flex w-full gap-2 overflow-hidden overflow-x-scroll pl-6">
|
||||
{models.map((item) => (
|
||||
{models?.map((item) => (
|
||||
<ConversationalCard key={item._id} model={item} />
|
||||
))}
|
||||
</div>
|
||||
|
||||
@ -5,35 +5,39 @@ import DropdownBox from '../DropdownBox'
|
||||
import PrimaryButton from '../PrimaryButton'
|
||||
import ToggleSwitch from '../ToggleSwitch'
|
||||
import CreateBotPromptInput from '../CreateBotPromptInput'
|
||||
import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels'
|
||||
import { Bot } from '@/_models/Bot'
|
||||
import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels'
|
||||
import { SubmitHandler, useForm } from 'react-hook-form'
|
||||
import Avatar from '../Avatar'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import DraggableProgressBar from '../DraggableProgressBar'
|
||||
import { useSetAtom } from 'jotai'
|
||||
import { activeBotAtom } from '@/_helpers/atoms/Bot.atom'
|
||||
import { activeBotAtom } from '@helpers/atoms/Bot.atom'
|
||||
import {
|
||||
rightSideBarExpandStateAtom,
|
||||
} from '@helpers/atoms/SideBarExpand.atom'
|
||||
import {
|
||||
MainViewState,
|
||||
setMainViewStateAtom,
|
||||
} from '@/_helpers/atoms/MainView.atom'
|
||||
import { executeSerial } from '../../../../electron/core/plugin-manager/execution/extension-manager'
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
import { DataService } from '@janhq/core'
|
||||
import { executeSerial } from '@services/pluginService'
|
||||
|
||||
const CreateBotContainer: React.FC = () => {
|
||||
const { downloadedModels } = useGetDownloadedModels()
|
||||
const setActiveBot = useSetAtom(activeBotAtom)
|
||||
const setMainViewState = useSetAtom(setMainViewStateAtom)
|
||||
const setRightSideBarVisibility = useSetAtom(rightSideBarExpandStateAtom)
|
||||
|
||||
const createBot = async (bot: Bot) => {
|
||||
try {
|
||||
await executeSerial(DataService.CreateBot, bot).then(async () => {
|
||||
setActiveBot(bot)
|
||||
setMainViewState(MainViewState.BotInfo)
|
||||
})
|
||||
await executeSerial(DataService.CreateBot, bot)
|
||||
} catch (err) {
|
||||
alert(err)
|
||||
console.error(err)
|
||||
} finally {
|
||||
setMainViewState(MainViewState.BotInfo)
|
||||
setActiveBot(bot)
|
||||
setRightSideBarVisibility(true)
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,9 +77,10 @@ const CreateBotContainer: React.FC = () => {
|
||||
createBot(bot)
|
||||
}
|
||||
|
||||
let models = downloadedModels.map((model) => {
|
||||
let models = downloadedModels.map((model: { _id: any }) => {
|
||||
return model._id
|
||||
})
|
||||
|
||||
models = ['Select a model', ...models]
|
||||
|
||||
return (
|
||||
@ -84,7 +89,7 @@ const CreateBotContainer: React.FC = () => {
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
>
|
||||
<div className="mx-6 mt-3 flex items-center justify-between gap-3">
|
||||
<span className="text-3xl font-bold text-gray-900">Create Bot</span>
|
||||
<span className="text-lg font-bold">Create Bot</span>
|
||||
<div className="flex gap-3">
|
||||
<PrimaryButton isSubmit title="Create" />
|
||||
</div>
|
||||
@ -108,7 +113,7 @@ const CreateBotContainer: React.FC = () => {
|
||||
control={control}
|
||||
/>
|
||||
|
||||
<div className="flex flex-col gap-4 pb-2">
|
||||
<div className="flex flex-col pb-2">
|
||||
<DropdownBox
|
||||
id="modelId"
|
||||
title="Model"
|
||||
@ -116,30 +121,23 @@ const CreateBotContainer: React.FC = () => {
|
||||
control={control}
|
||||
required={true}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<CreateBotPromptInput
|
||||
id="systemPrompt"
|
||||
control={control}
|
||||
required
|
||||
/>
|
||||
<CreateBotPromptInput id="systemPrompt" control={control} required />
|
||||
|
||||
<div className="flex flex-col gap-0.5">
|
||||
<label className="block text-base font-bold text-gray-900">
|
||||
Bot access
|
||||
</label>
|
||||
<span className="pb-2 text-sm text-[#737d7d]">
|
||||
If this setting is enabled, the bot will be added to your
|
||||
profile and will be publicly accessible. Turning this off will
|
||||
make the bot private.
|
||||
<label className="block">Bot access</label>
|
||||
<span className="mb-4 mt-1 text-muted-foreground">
|
||||
If this setting is enabled, the bot will be added to your profile
|
||||
and will be publicly accessible. Turning this off will make the
|
||||
bot private.
|
||||
</span>
|
||||
|
||||
<ToggleSwitch
|
||||
id="publiclyAccessible"
|
||||
title="Bot publicly accessible"
|
||||
control={control}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<p>Max tokens</p>
|
||||
<DraggableProgressBar
|
||||
id="maxTokens"
|
||||
control={control}
|
||||
|
||||
98
web/app/_components/CreateBotInAdvance/index.tsx
Normal file
98
web/app/_components/CreateBotInAdvance/index.tsx
Normal file
@ -0,0 +1,98 @@
|
||||
import React, { Fragment, useState } from 'react'
|
||||
import ToggleSwitch from '../ToggleSwitch'
|
||||
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'
|
||||
import CutomBotTemperature from '../CustomBotTemperature'
|
||||
import DraggableProgressBar from '../DraggableProgressBar'
|
||||
|
||||
type Props = {
|
||||
control?: any
|
||||
}
|
||||
|
||||
const CreateBotInAdvance: React.FC<Props> = ({ control }) => {
|
||||
const [showAdvanced, setShowAdvanced] = useState(true)
|
||||
|
||||
const handleShowAdvanced = (e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
setShowAdvanced(!showAdvanced)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex items-start">
|
||||
<button
|
||||
className="mb-2 flex items-center justify-center font-bold"
|
||||
onClick={handleShowAdvanced}
|
||||
>
|
||||
Advanced
|
||||
{showAdvanced ? (
|
||||
<ChevronDownIcon width={16} className="ml-2" />
|
||||
) : (
|
||||
<ChevronUpIcon width={16} className="ml-2" />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{showAdvanced && (
|
||||
<>
|
||||
<div>
|
||||
<p className="text-bold">Max tokens</p>
|
||||
<DraggableProgressBar
|
||||
id="maxTokens"
|
||||
control={control}
|
||||
min={0}
|
||||
max={4096}
|
||||
step={1}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-bold">Custom temperature</p>
|
||||
<DraggableProgressBar
|
||||
id="customTemperature"
|
||||
control={control}
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.01}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-bold">Frequency penalty</p>
|
||||
<DraggableProgressBar
|
||||
id="frequencyPenalty"
|
||||
control={control}
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.01}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-bold">Presence penalty</p>
|
||||
<DraggableProgressBar
|
||||
id="presencePenalty"
|
||||
control={control}
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.01}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* {showAdvanced && (
|
||||
<Fragment>
|
||||
<ToggleSwitch
|
||||
id="suggestReplies"
|
||||
title="Suggest replies"
|
||||
control={control}
|
||||
/>
|
||||
<ToggleSwitch
|
||||
id="renderMarkdownContent"
|
||||
title="Render markdown content"
|
||||
control={control}
|
||||
/>
|
||||
<CutomBotTemperature control={control} />
|
||||
</Fragment>
|
||||
)} */}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default CreateBotInAdvance
|
||||
@ -1,30 +1,27 @@
|
||||
import React, { Fragment, use } from "react";
|
||||
import ToggleSwitch from "../ToggleSwitch";
|
||||
import { useController } from "react-hook-form";
|
||||
import React, { Fragment, use } from 'react'
|
||||
import ToggleSwitch from '../ToggleSwitch'
|
||||
import { useController } from 'react-hook-form'
|
||||
|
||||
type Props = {
|
||||
id: string;
|
||||
control?: any;
|
||||
required?: boolean;
|
||||
};
|
||||
id: string
|
||||
control?: any
|
||||
required?: boolean
|
||||
}
|
||||
|
||||
const CreateBotPromptInput: React.FC<Props> = ({ id, control, required }) => {
|
||||
const { field } = useController({
|
||||
name: id,
|
||||
control: control,
|
||||
rules: { required: required },
|
||||
});
|
||||
})
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<div className="flex flex-col gap-2">
|
||||
<label
|
||||
htmlFor="comment"
|
||||
className="block text-base text-gray-900 font-bold"
|
||||
>
|
||||
<label htmlFor="comment" className="block font-bold ">
|
||||
Prompt
|
||||
</label>
|
||||
<p className="text-sm text-gray-400 font-normal">
|
||||
<p className="mt-1 font-normal text-gray-400">
|
||||
All conversations with this bot will start with your prompt but it
|
||||
will not be visible to the user in the chat. If you would like the
|
||||
prompt message to be visible to the user, consider using an intro
|
||||
@ -32,18 +29,18 @@ const CreateBotPromptInput: React.FC<Props> = ({ id, control, required }) => {
|
||||
</p>
|
||||
<ToggleSwitch
|
||||
id="visibleFromBotProfile"
|
||||
title={"Prompt visible from bot profile"}
|
||||
title={'Prompt visible from bot profile'}
|
||||
control={control}
|
||||
/>
|
||||
<textarea
|
||||
rows={4}
|
||||
className="block w-full resize-none rounded-md border-0 py-1.5 bg-transparent shadow-sm ring-1 ring-inset text-gray-900 ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6"
|
||||
className="block w-full resize-none rounded-md border-0 bg-background/80 py-1.5 text-xs leading-relaxed text-background-reverse shadow-sm ring-1 ring-inset ring-border placeholder:text-muted-foreground focus:ring-2 focus:ring-inset focus:ring-accent/50"
|
||||
placeholder="Talk to me like a pirate"
|
||||
{...field}
|
||||
/>
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default CreateBotPromptInput;
|
||||
export default CreateBotPromptInput
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import ToggleSwitch from "../ToggleSwitch";
|
||||
import DraggableProgressBar from "../DraggableProgressBar";
|
||||
import { Controller } from "react-hook-form";
|
||||
import ToggleSwitch from '../ToggleSwitch'
|
||||
import DraggableProgressBar from '../DraggableProgressBar'
|
||||
import { Controller } from 'react-hook-form'
|
||||
|
||||
type Props = {
|
||||
control?: any;
|
||||
};
|
||||
control?: any
|
||||
}
|
||||
|
||||
const CutomBotTemperature: React.FC<Props> = ({ control }) => (
|
||||
<div className="flex flex-col gap-2">
|
||||
@ -13,23 +13,29 @@ const CutomBotTemperature: React.FC<Props> = ({ control }) => (
|
||||
title="Custom temperature"
|
||||
control={control}
|
||||
/>
|
||||
<div className="text-gray-500 mt-1 text-[0.8em]">
|
||||
Controls the creativity of the bot's responses. Higher values produce more
|
||||
<div className="mt-1 text-[0.8em] text-gray-500">
|
||||
{`Controls the creativity of the bot's responses. Higher values produce more
|
||||
varied but unpredictable replies, lower values generate more consistent
|
||||
responses.
|
||||
responses.`}
|
||||
</div>
|
||||
<span className="text-gray-900">default: 0.7</span>
|
||||
<Controller
|
||||
name="enableCustomTemperature"
|
||||
control={control}
|
||||
render={({ field: { value } }) => {
|
||||
if (!value) return <div />;
|
||||
if (!value) return <div />
|
||||
return (
|
||||
<DraggableProgressBar id="customTemperature" control={control} min={0} max={1} step={0.01} />
|
||||
);
|
||||
<DraggableProgressBar
|
||||
id="customTemperature"
|
||||
control={control}
|
||||
min={0}
|
||||
max={1}
|
||||
step={0.01}
|
||||
/>
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
|
||||
export default CutomBotTemperature;
|
||||
export default CutomBotTemperature
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import { AssistantModel } from '@/_models/AssistantModel'
|
||||
import DownloadModelContent from '../DownloadModelContent'
|
||||
|
||||
type Props = {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import SearchBar from '../SearchBar'
|
||||
import ModelTable from '../ModelTable'
|
||||
import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels'
|
||||
import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels'
|
||||
|
||||
const DownloadedModelTable: React.FC = () => {
|
||||
const { downloadedModels } = useGetDownloadedModels()
|
||||
@ -9,11 +9,11 @@ const DownloadedModelTable: React.FC = () => {
|
||||
if (!downloadedModels || downloadedModels.length === 0) return null
|
||||
|
||||
return (
|
||||
<div className="pl-[63px] pr-[89px]">
|
||||
<h3 className="mt-[50px] text-xl leading-[25px]">Downloaded Models</h3>
|
||||
<div className="w-[568px] py-5">
|
||||
<div className="mt-5">
|
||||
{/* <h3 className="mt-[50px] text-xl leading-[25px]">Downloaded Models</h3> */}
|
||||
{/* <div className="w-[568px] py-5">
|
||||
<SearchBar />
|
||||
</div>
|
||||
</div> */}
|
||||
<ModelTable models={downloadedModels} />
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import React, { Fragment } from 'react'
|
||||
import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom'
|
||||
import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import ModelDownloadingTable from '../ModelDownloadingTable'
|
||||
import { DownloadState } from '@/_models/DownloadState'
|
||||
|
||||
const DownloadingModelTable: React.FC = () => {
|
||||
const modelDownloadState = useAtomValue(modelDownloadStateAtom)
|
||||
|
||||
@ -1,23 +1,29 @@
|
||||
import { formatTwoDigits } from "@/_utils/converter";
|
||||
import React from "react";
|
||||
import { Controller, useController } from "react-hook-form";
|
||||
import { formatTwoDigits } from '@utils/converter'
|
||||
import React from 'react'
|
||||
import { Controller, useController } from 'react-hook-form'
|
||||
|
||||
type Props = {
|
||||
id: string;
|
||||
control: any;
|
||||
min: number;
|
||||
max: number;
|
||||
step: number;
|
||||
};
|
||||
id: string
|
||||
control: any
|
||||
min: number
|
||||
max: number
|
||||
step: number
|
||||
}
|
||||
|
||||
const DraggableProgressBar: React.FC<Props> = ({ id, control, min, max, step }) => {
|
||||
const DraggableProgressBar: React.FC<Props> = ({
|
||||
id,
|
||||
control,
|
||||
min,
|
||||
max,
|
||||
step,
|
||||
}) => {
|
||||
const { field } = useController({
|
||||
name: id,
|
||||
control: control,
|
||||
});
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2 mt-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
{...field}
|
||||
className="flex-1"
|
||||
@ -30,13 +36,13 @@ const DraggableProgressBar: React.FC<Props> = ({ id, control, min, max, step })
|
||||
name={id}
|
||||
control={control}
|
||||
render={({ field: { value } }) => (
|
||||
<span className="border border-[#737d7d] rounded-md py-1 px-2 text-gray-900">
|
||||
<span className="rounded-md border border-border px-2 py-1 text-accent">
|
||||
{formatTwoDigits(value)}
|
||||
</span>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default DraggableProgressBar;
|
||||
export default DraggableProgressBar
|
||||
|
||||
@ -24,9 +24,9 @@ const DropdownBox: React.FC<Props> = ({
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<label className="block text-base font-bold text-gray-900">{title}</label>
|
||||
<label className="block font-bold">{title}</label>
|
||||
<select
|
||||
className="mt-2 block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-indigo-600 sm:text-sm sm:leading-6"
|
||||
className="bg-background/80 ring-border focus:ring-accent/50 mt-1 block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-xs ring-1 ring-inset focus:ring-2 sm:leading-6"
|
||||
{...field}
|
||||
>
|
||||
{data.map((option) => (
|
||||
|
||||
@ -2,22 +2,11 @@ import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'
|
||||
|
||||
type Props = {
|
||||
title: string
|
||||
expanded: boolean
|
||||
onClick: () => void
|
||||
}
|
||||
|
||||
const ExpandableHeader: React.FC<Props> = ({ title, expanded, onClick }) => (
|
||||
<button onClick={onClick} className="flex items-center justify-between px-2">
|
||||
<h2 className="pl-1 text-xs font-bold leading-[12px] text-gray-400">
|
||||
{title}
|
||||
</h2>
|
||||
<div className="mr-2">
|
||||
{expanded ? (
|
||||
<ChevronDownIcon width={12} height={12} color="#6B7280" />
|
||||
) : (
|
||||
<ChevronUpIcon width={12} height={12} color="#6B7280" />
|
||||
)}
|
||||
</div>
|
||||
const ExpandableHeader: React.FC<Props> = ({ title }) => (
|
||||
<button className="flex items-center justify-between">
|
||||
<h2 className="text-muted-foreground pl-1 font-bold">{title}</h2>
|
||||
</button>
|
||||
)
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import HeaderTitle from '../HeaderTitle'
|
||||
import ExploreModelList from '../ExploreModelList'
|
||||
import ExploreModelList from '../../../screens/ExploreModels/ExploreModelList'
|
||||
import ExploreModelFilter from '../ExploreModelFilter'
|
||||
|
||||
const ExploreModelContainer: React.FC = () => (
|
||||
|
||||
@ -16,7 +16,7 @@ const tags = [
|
||||
const checkboxs = ['GGUF', 'TensorRT', 'Meow', 'JigglyPuff']
|
||||
|
||||
const ExploreModelFilter: React.FC = () => {
|
||||
const enabled = false
|
||||
const enabled = true
|
||||
if (!enabled) return null
|
||||
|
||||
return (
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
'use client'
|
||||
|
||||
import ExploreModelItemHeader from '../ExploreModelItemHeader'
|
||||
import { Button } from '@uikit'
|
||||
import ModelVersionList from '../ModelVersionList'
|
||||
import { Fragment, forwardRef, useEffect, useState } from 'react'
|
||||
import SimpleTag from '../SimpleTag'
|
||||
@ -14,10 +15,9 @@ import {
|
||||
UsecaseTag,
|
||||
VersionTag,
|
||||
} from '@/_components/SimpleTag/TagType'
|
||||
import { displayDate } from '@/_utils/datetime'
|
||||
import { Product } from '@/_models/Product'
|
||||
import useGetMostSuitableModelVersion from '@/_hooks/useGetMostSuitableModelVersion'
|
||||
import { toGigabytes } from '@/_utils/converter'
|
||||
import { displayDate } from '@utils/datetime'
|
||||
import useGetMostSuitableModelVersion from '@hooks/useGetMostSuitableModelVersion'
|
||||
import { toGigabytes } from '@utils/converter'
|
||||
|
||||
type Props = {
|
||||
model: Product
|
||||
@ -32,6 +32,7 @@ const ExploreModelItem = forwardRef<HTMLDivElement, Props>(({ model }, ref) => {
|
||||
|
||||
useEffect(() => {
|
||||
getMostSuitableModelVersion(availableVersions)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [availableVersions])
|
||||
|
||||
if (!suitableModel) {
|
||||
@ -43,25 +44,30 @@ const ExploreModelItem = forwardRef<HTMLDivElement, Props>(({ model }, ref) => {
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
className="mb-4 flex flex-col rounded-md border border-gray-200"
|
||||
className="border-border bg-background/60 mb-4 flex flex-col rounded-md border"
|
||||
>
|
||||
<ExploreModelItemHeader
|
||||
suitableModel={suitableModel}
|
||||
exploreModel={model}
|
||||
/>
|
||||
<div className="flex flex-col px-[26px] py-[22px]">
|
||||
<div className="flex flex-col p-4">
|
||||
<div className="mb-4 flex flex-col gap-1">
|
||||
<span className="font-semibold">About</span>
|
||||
<span className="text-muted-foreground leading-relaxed">
|
||||
{model.longDescription}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-between">
|
||||
<div className="flex flex-1 flex-col gap-8">
|
||||
<div className="flex flex-1 flex-col gap-y-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="text-sm font-medium text-gray-500">
|
||||
Release Date
|
||||
</div>
|
||||
<div className="text-sm font-normal text-gray-900">
|
||||
<div className="font-semibold">Release Date</div>
|
||||
<p className="text-muted-foreground mt-1">
|
||||
{displayDate(model.releaseDate)}
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="text-sm font-medium text-gray-500">Version</div>
|
||||
<div className="font-semibold">Version</div>
|
||||
<div className="flex gap-2">
|
||||
<SimpleTag
|
||||
title={model.version}
|
||||
@ -81,17 +87,14 @@ const ExploreModelItem = forwardRef<HTMLDivElement, Props>(({ model }, ref) => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-1 flex-col gap-8">
|
||||
|
||||
<div className="flex flex-1 flex-col gap-y-4">
|
||||
<div>
|
||||
<div className="text-sm font-medium text-gray-500">Author</div>
|
||||
<div className="text-sm font-normal text-gray-900">
|
||||
{model.author}
|
||||
</div>
|
||||
<div className="font-semibold">Author</div>
|
||||
<p className="text-muted-foreground mt-1">{model.author}</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="text-sm font-medium text-gray-500">
|
||||
Compatibility
|
||||
</div>
|
||||
<div className="font-semibold">Compatibility</div>
|
||||
<div className="flex gap-2">
|
||||
<SimpleTag
|
||||
title={usecase}
|
||||
@ -106,16 +109,11 @@ const ExploreModelItem = forwardRef<HTMLDivElement, Props>(({ model }, ref) => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-[26px] flex flex-col gap-1">
|
||||
<span className="text-sm font-medium text-gray-500">About</span>
|
||||
<span className="text-sm font-normal text-gray-500">
|
||||
{model.longDescription}
|
||||
</span>
|
||||
</div>
|
||||
<div className="mt-5 flex flex-col gap-2">
|
||||
<span className="text-sm font-medium text-gray-500">Tags</span>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
|
||||
<div className="flex flex-1 flex-col gap-y-4">
|
||||
<div>
|
||||
<div className="font-medium">Tags</div>
|
||||
<div className="mt-1 flex flex-wrap gap-2">
|
||||
{model.tags.map((tag) => (
|
||||
<SimpleTag
|
||||
key={tag}
|
||||
@ -127,8 +125,16 @@ const ExploreModelItem = forwardRef<HTMLDivElement, Props>(({ model }, ref) => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{model.availableVersions?.length > 0 && (
|
||||
<Fragment>
|
||||
<div className="border-border bg-background mt-5 w-full rounded-md border p-2">
|
||||
<button onClick={() => setShow(!show)} className="w-full">
|
||||
{!show
|
||||
? '+ Show Available Versions'
|
||||
: '- Collapse Available Versions'}
|
||||
</button>
|
||||
|
||||
{show && (
|
||||
<ModelVersionList
|
||||
model={model}
|
||||
@ -136,15 +142,10 @@ const ExploreModelItem = forwardRef<HTMLDivElement, Props>(({ model }, ref) => {
|
||||
recommendedVersion={suitableModel?._id ?? ''}
|
||||
/>
|
||||
)}
|
||||
<button
|
||||
onClick={() => setShow(!show)}
|
||||
className="border-t border-gray-200 bg-[#FBFBFB] px-4 py-2 text-left text-sm text-gray-500"
|
||||
>
|
||||
{!show ? '+ Show Available Versions' : '- Collapse'}
|
||||
</button>
|
||||
</Fragment>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@ -1,19 +1,18 @@
|
||||
import SimpleTag from '../SimpleTag'
|
||||
import PrimaryButton from '../PrimaryButton'
|
||||
import { formatDownloadPercentage, toGigabytes } from '@/_utils/converter'
|
||||
import { formatDownloadPercentage, toGigabytes } from '@utils/converter'
|
||||
import SecondaryButton from '../SecondaryButton'
|
||||
import { Product } from '@/_models/Product'
|
||||
import { useCallback, useEffect, useMemo } from 'react'
|
||||
import { ModelVersion } from '@/_models/ModelVersion'
|
||||
import useGetPerformanceTag from '@/_hooks/useGetPerformanceTag'
|
||||
import useDownloadModel from '@/_hooks/useDownloadModel'
|
||||
import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels'
|
||||
import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom'
|
||||
import useGetPerformanceTag from '@hooks/useGetPerformanceTag'
|
||||
import useDownloadModel from '@hooks/useDownloadModel'
|
||||
import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels'
|
||||
import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom'
|
||||
import { atom, useAtomValue, useSetAtom } from 'jotai'
|
||||
import { Button } from '@uikit'
|
||||
import {
|
||||
MainViewState,
|
||||
setMainViewStateAtom,
|
||||
} from '@/_helpers/atoms/MainView.atom'
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
|
||||
type Props = {
|
||||
suitableModel: ModelVersion
|
||||
@ -37,35 +36,36 @@ const ExploreModelItemHeader: React.FC<Props> = ({
|
||||
|
||||
useEffect(() => {
|
||||
getPerformanceForModel(suitableModel)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [suitableModel])
|
||||
|
||||
const onDownloadClick = useCallback(() => {
|
||||
downloadModel(exploreModel, suitableModel)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [exploreModel, suitableModel])
|
||||
|
||||
const isDownloaded =
|
||||
downloadedModels.find((model) => model._id === suitableModel._id) != null
|
||||
|
||||
let downloadButton = (
|
||||
<PrimaryButton
|
||||
title={
|
||||
suitableModel.size
|
||||
<Button themes="accent" onClick={() => onDownloadClick()}>
|
||||
{suitableModel.size
|
||||
? `Download (${toGigabytes(suitableModel.size)})`
|
||||
: 'Download'
|
||||
}
|
||||
onClick={() => onDownloadClick()}
|
||||
/>
|
||||
: 'Download'}
|
||||
</Button>
|
||||
)
|
||||
|
||||
if (isDownloaded) {
|
||||
downloadButton = (
|
||||
<PrimaryButton
|
||||
title="View Downloaded Model"
|
||||
<Button
|
||||
size="sm"
|
||||
themes="accent"
|
||||
onClick={() => {
|
||||
setMainViewState(MainViewState.MyModel)
|
||||
}}
|
||||
className="bg-green-500 hover:bg-green-400"
|
||||
/>
|
||||
>
|
||||
View Downloaded Model
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ const ExploreModelItemHeader: React.FC<Props> = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-between border-b border-gray-200 p-4">
|
||||
<div className="border-border bg-background/50 flex items-center justify-between rounded-t-md border-b px-4 py-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<span>{exploreModel.name}</span>
|
||||
{performanceTag && (
|
||||
|
||||
@ -1,28 +0,0 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import ExploreModelItem from '../ExploreModelItem'
|
||||
import { getConfiguredModels } from '@/_hooks/useGetDownloadedModels'
|
||||
import useGetConfiguredModels from '@/_hooks/useGetConfiguredModels'
|
||||
import { Waveform } from '@uiball/loaders'
|
||||
|
||||
const ExploreModelList: React.FC = () => {
|
||||
const { loading, models } = useGetConfiguredModels()
|
||||
|
||||
useEffect(() => {
|
||||
getConfiguredModels()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="scroll flex flex-1 flex-col overflow-y-auto">
|
||||
{loading && (
|
||||
<div className="mx-auto">
|
||||
<Waveform size={24} color="#CBD5E0" />
|
||||
</div>
|
||||
)}
|
||||
{models.map((item) => (
|
||||
<ExploreModelItem key={item._id} model={item} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ExploreModelList
|
||||
@ -1,23 +0,0 @@
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
|
||||
// DEPRECATED
|
||||
export default function Footer() {
|
||||
return (
|
||||
<div className="container m-auto flex items-center justify-between">
|
||||
<div className="flex items-center gap-3">
|
||||
<Image src={'icons/app_icon.svg'} width={32} height={32} alt="" />
|
||||
<span>Jan</span>
|
||||
</div>
|
||||
<div className="my-6 flex gap-4">
|
||||
<Link href="/privacy" className="cursor-pointer">
|
||||
Privacy
|
||||
</Link>
|
||||
<span>•</span>
|
||||
<Link href="/support" className="cursor-pointer">
|
||||
Support
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { showingMobilePaneAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import { showingMobilePaneAtom } from '@helpers/atoms/Modal.atom'
|
||||
import { Bars3Icon } from '@heroicons/react/24/outline'
|
||||
import { useSetAtom } from 'jotai'
|
||||
import React from 'react'
|
||||
|
||||
@ -1,21 +1,18 @@
|
||||
import React from 'react'
|
||||
import { useAtomValue, useSetAtom } from 'jotai'
|
||||
import Image from 'next/image'
|
||||
import { Conversation } from '@/_models/Conversation'
|
||||
import { ModelManagementService } from '@janhq/core'
|
||||
import { executeSerial } from '../../../../electron/core/plugin-manager/execution/extension-manager'
|
||||
import {
|
||||
getActiveConvoIdAtom,
|
||||
setActiveConvoIdAtom,
|
||||
updateConversationErrorAtom,
|
||||
updateConversationWaitingForResponseAtom,
|
||||
} from '@/_helpers/atoms/Conversation.atom'
|
||||
} from '@helpers/atoms/Conversation.atom'
|
||||
import {
|
||||
setMainViewStateAtom,
|
||||
MainViewState,
|
||||
} from '@/_helpers/atoms/MainView.atom'
|
||||
import useInitModel from '@/_hooks/useInitModel'
|
||||
import { displayDate } from '@/_utils/datetime'
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
import { displayDate } from '@utils/datetime'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
import { executeSerial } from '@services/pluginService'
|
||||
|
||||
type Props = {
|
||||
conversation: Conversation
|
||||
@ -35,14 +32,9 @@ const HistoryItem: React.FC<Props> = ({
|
||||
const setMainViewState = useSetAtom(setMainViewStateAtom)
|
||||
const activeConvoId = useAtomValue(getActiveConvoIdAtom)
|
||||
const setActiveConvoId = useSetAtom(setActiveConvoIdAtom)
|
||||
const updateConvWaiting = useSetAtom(
|
||||
updateConversationWaitingForResponseAtom
|
||||
)
|
||||
const updateConvError = useSetAtom(updateConversationErrorAtom)
|
||||
const updateConvWaiting = useSetAtom(updateConversationWaitingForResponseAtom)
|
||||
const isSelected = activeConvoId === conversation._id
|
||||
|
||||
const { initModel } = useInitModel()
|
||||
|
||||
const onClick = async () => {
|
||||
const model = await executeSerial(
|
||||
ModelManagementService.GetModelById,
|
||||
@ -50,55 +42,38 @@ const HistoryItem: React.FC<Props> = ({
|
||||
)
|
||||
|
||||
if (conversation._id) updateConvWaiting(conversation._id, true)
|
||||
initModel(model).then((res: any) => {
|
||||
if (conversation._id) updateConvWaiting(conversation._id, false)
|
||||
|
||||
if (res?.error && conversation._id) {
|
||||
updateConvError(conversation._id, res.error)
|
||||
}
|
||||
})
|
||||
|
||||
if (activeConvoId !== conversation._id) {
|
||||
setMainViewState(MainViewState.Conversation)
|
||||
setActiveConvoId(conversation._id)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const backgroundColor = isSelected
|
||||
? "bg-gray-100 dark:bg-gray-700"
|
||||
: "bg-white dark:bg-gray-500"
|
||||
|
||||
const description = conversation?.lastMessage ?? "No new message"
|
||||
const backgroundColor = isSelected ? 'bg-background/80' : 'bg-background/20'
|
||||
const description = conversation?.lastMessage ?? 'No new message'
|
||||
|
||||
return (
|
||||
<li
|
||||
role="button"
|
||||
className={`ml-3 mr-2 flex flex-row rounded p-3 ${backgroundColor} hover:bg-hover-light`}
|
||||
className={twMerge(
|
||||
'flex flex-row rounded-md border border-border p-3',
|
||||
backgroundColor
|
||||
)}
|
||||
onClick={onClick}
|
||||
>
|
||||
<div className="h-8 w-8">
|
||||
<Image
|
||||
width={32}
|
||||
height={32}
|
||||
src={avatarUrl ?? 'icons/app_icon.svg'}
|
||||
className="aspect-square rounded-full"
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="ml-2 flex flex-1 flex-col">
|
||||
<div className="flex flex-1 flex-col">
|
||||
{/* title */}
|
||||
<div className="flex">
|
||||
<span className="line-clamp-1 flex-1 text-gray-900">
|
||||
{summary ?? name}
|
||||
</span>
|
||||
<span className="line-clamp-1 text-xs leading-5 text-gray-500">
|
||||
|
||||
<span className="mb-1 line-clamp-1 leading-5 text-muted-foreground">
|
||||
{updatedAt && displayDate(new Date(updatedAt).getTime())}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<span className="line-clamp-1">{summary ?? name}</span>
|
||||
|
||||
{/* description */}
|
||||
<span className="mt-1 line-clamp-2 text-gray-400">{description}</span>
|
||||
<span className="mt-1 line-clamp-2 text-muted-foreground">
|
||||
{description}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
)
|
||||
|
||||
@ -2,15 +2,15 @@ import HistoryItem from '../HistoryItem'
|
||||
import { useEffect, useState } from 'react'
|
||||
import ExpandableHeader from '../ExpandableHeader'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { searchAtom } from '@/_helpers/JotaiWrapper'
|
||||
import useGetUserConversations from '@/_hooks/useGetUserConversations'
|
||||
import { searchAtom } from '@helpers/JotaiWrapper'
|
||||
import useGetUserConversations from '@hooks/useGetUserConversations'
|
||||
import SidebarEmptyHistory from '../SidebarEmptyHistory'
|
||||
import { userConversationsAtom } from '@/_helpers/atoms/Conversation.atom'
|
||||
import { userConversationsAtom } from '@helpers/atoms/Conversation.atom'
|
||||
import { twMerge } from 'tailwind-merge'
|
||||
|
||||
const HistoryList: React.FC = () => {
|
||||
const conversations = useAtomValue(userConversationsAtom)
|
||||
const searchText = useAtomValue(searchAtom)
|
||||
const [expand, setExpand] = useState<boolean>(true)
|
||||
const { getUserConversations } = useGetUserConversations()
|
||||
|
||||
useEffect(() => {
|
||||
@ -18,17 +18,9 @@ const HistoryList: React.FC = () => {
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<div className="flex flex-grow flex-col gap-2 overflow-hidden pt-3">
|
||||
<ExpandableHeader
|
||||
title="CHAT HISTORY"
|
||||
expanded={expand}
|
||||
onClick={() => setExpand(!expand)}
|
||||
/>
|
||||
<ul
|
||||
className={`scroll mt-1 flex flex-col gap-1 overflow-y-auto ${
|
||||
!expand ? 'hidden ' : 'block'
|
||||
}`}
|
||||
>
|
||||
<div className="flex flex-grow flex-col gap-2">
|
||||
<ExpandableHeader title="CHAT HISTORY" />
|
||||
<ul className={twMerge('mt-1 flex flex-col gap-y-3 overflow-y-auto')}>
|
||||
{conversations.length > 0 ? (
|
||||
conversations
|
||||
.filter(
|
||||
|
||||
@ -1,24 +1,23 @@
|
||||
/* eslint-disable react-hooks/rules-of-hooks */
|
||||
'use client'
|
||||
|
||||
import BasicPromptInput from '../BasicPromptInput'
|
||||
import BasicPromptAccessories from '../BasicPromptAccessories'
|
||||
import { useAtomValue, useSetAtom } from 'jotai'
|
||||
import { showingAdvancedPromptAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import SecondaryButton from '../SecondaryButton'
|
||||
import { Fragment, useEffect, useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { PlusIcon } from '@heroicons/react/24/outline'
|
||||
import useCreateConversation from '@/_hooks/useCreateConversation'
|
||||
import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom'
|
||||
import useCreateConversation from '@hooks/useCreateConversation'
|
||||
import { activeAssistantModelAtom } from '@helpers/atoms/Model.atom'
|
||||
import {
|
||||
currentConversationAtom,
|
||||
currentConvoStateAtom,
|
||||
} from '@/_helpers/atoms/Conversation.atom'
|
||||
import useGetBots from '@/_hooks/useGetBots'
|
||||
import { activeBotAtom } from '@/_helpers/atoms/Bot.atom'
|
||||
import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels'
|
||||
} from '@helpers/atoms/Conversation.atom'
|
||||
import useGetBots from '@hooks/useGetBots'
|
||||
import { activeBotAtom } from '@helpers/atoms/Bot.atom'
|
||||
import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels'
|
||||
|
||||
const InputToolbar: React.FC = () => {
|
||||
const showingAdvancedPrompt = useAtomValue(showingAdvancedPromptAtom)
|
||||
const activeModel = useAtomValue(activeAssistantModelAtom)
|
||||
const { requestCreateConvo } = useCreateConversation()
|
||||
const currentConvoState = useAtomValue(currentConvoStateAtom)
|
||||
@ -62,6 +61,7 @@ const InputToolbar: React.FC = () => {
|
||||
}
|
||||
}
|
||||
getReplyState()
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentConvo])
|
||||
|
||||
const onNewConversationClick = () => {
|
||||
@ -70,26 +70,19 @@ const InputToolbar: React.FC = () => {
|
||||
}
|
||||
}
|
||||
|
||||
if (showingAdvancedPrompt) {
|
||||
return <div />
|
||||
}
|
||||
|
||||
if (inputState === 'loading') {
|
||||
return <div>Loading..</div>
|
||||
}
|
||||
|
||||
if (inputState === 'disabled') {
|
||||
// text italic
|
||||
if (inputState === 'loading') return <div>Loading..</div>
|
||||
|
||||
if (inputState === 'disabled')
|
||||
return (
|
||||
<p className="mx-auto my-5 line-clamp-2 text-ellipsis text-center text-sm italic text-gray-600">
|
||||
<div className="sticky bottom-0 flex items-center justify-center bg-background/90">
|
||||
<p className="mx-auto my-5 line-clamp-2 text-ellipsis text-center italic text-gray-600">
|
||||
{error}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<div className="sticky bottom-0 w-full bg-background/90 px-5 py-0">
|
||||
{currentConvoState?.error && (
|
||||
<div className="flex flex-row justify-center">
|
||||
<span className="mx-5 my-2 text-sm text-red-500">
|
||||
@ -105,13 +98,13 @@ const InputToolbar: React.FC = () => {
|
||||
/>
|
||||
</div>
|
||||
{/* My text input */}
|
||||
<div className="mx-12 mb-5 flex items-start space-x-4 md:mx-32 2xl:mx-64">
|
||||
<div className="mb-5 flex items-start space-x-4">
|
||||
<div className="relative min-w-0 flex-1">
|
||||
<BasicPromptInput />
|
||||
<BasicPromptAccessories />
|
||||
</div>
|
||||
</div>
|
||||
</Fragment>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
import React, { Fragment } from "react"
|
||||
import HistoryList from "../HistoryList"
|
||||
import LeftHeaderAction from "../LeftHeaderAction"
|
||||
import { leftSideBarExpandStateAtom } from "@/_helpers/atoms/LeftSideBarExpand.atom"
|
||||
import { useAtomValue } from "jotai"
|
||||
import { Variants, motion } from "framer-motion"
|
||||
import React, { Fragment } from 'react'
|
||||
import HistoryList from '../HistoryList'
|
||||
import LeftHeaderAction from '../LeftHeaderAction'
|
||||
import { leftSideBarExpandStateAtom } from '@helpers/atoms/SideBarExpand.atom'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { Variants, motion } from 'framer-motion'
|
||||
|
||||
const leftSideBarVariants: Variants = {
|
||||
show: {
|
||||
@ -13,7 +13,7 @@ const leftSideBarVariants: Variants = {
|
||||
transition: { duration: 0.3 },
|
||||
},
|
||||
hide: {
|
||||
x: "-100%",
|
||||
x: '-100%',
|
||||
width: 0,
|
||||
opacity: 0,
|
||||
transition: { duration: 0.3 },
|
||||
@ -26,13 +26,13 @@ const LeftContainer: React.FC = () => {
|
||||
return (
|
||||
<motion.div
|
||||
initial={false}
|
||||
animate={isVisible ? "show" : "hide"}
|
||||
animate={isVisible ? 'show' : 'hide'}
|
||||
variants={leftSideBarVariants}
|
||||
className="flex flex-col w-80 flex-shrink-0 border-r border-gray-200"
|
||||
className="flex w-80 flex-shrink-0 flex-col dark:bg-gray-950/50"
|
||||
>
|
||||
{isVisible && (
|
||||
<Fragment>
|
||||
<LeftHeaderAction />
|
||||
{/* <LeftHeaderAction /> */}
|
||||
<HistoryList />
|
||||
</Fragment>
|
||||
)}
|
||||
|
||||
@ -1,47 +1,47 @@
|
||||
"use client";
|
||||
'use client'
|
||||
|
||||
import React from "react";
|
||||
import SecondaryButton from "../SecondaryButton";
|
||||
import { useSetAtom } from "jotai";
|
||||
import React from 'react'
|
||||
import SecondaryButton from '../SecondaryButton'
|
||||
import { useSetAtom } from 'jotai'
|
||||
import {
|
||||
MainViewState,
|
||||
setMainViewStateAtom,
|
||||
} from "@/_helpers/atoms/MainView.atom";
|
||||
import { MagnifyingGlassIcon, PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { useGetDownloadedModels } from "@/_hooks/useGetDownloadedModels";
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
import { MagnifyingGlassIcon, PlusIcon } from '@heroicons/react/24/outline'
|
||||
import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels'
|
||||
|
||||
const LeftHeaderAction: React.FC = () => {
|
||||
const setMainView = useSetAtom(setMainViewStateAtom);
|
||||
const { downloadedModels } = useGetDownloadedModels();
|
||||
const setMainView = useSetAtom(setMainViewStateAtom)
|
||||
const { downloadedModels } = useGetDownloadedModels()
|
||||
|
||||
const onExploreClick = () => {
|
||||
setMainView(MainViewState.ExploreModel);
|
||||
};
|
||||
setMainView(MainViewState.ExploreModel)
|
||||
}
|
||||
|
||||
const onCreateBotClicked = () => {
|
||||
if (downloadedModels.length === 0) {
|
||||
alert("You need to download at least one model to create a bot.");
|
||||
return;
|
||||
alert('You need to download at least one model to create a bot.')
|
||||
return
|
||||
}
|
||||
setMainView(MainViewState.CreateBot)
|
||||
}
|
||||
setMainView(MainViewState.CreateBot);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-row gap-2 mx-3 my-3">
|
||||
<div className="sticky top-0 mb-4 flex flex-row gap-2">
|
||||
<SecondaryButton
|
||||
title={"Explore"}
|
||||
title={'Explore'}
|
||||
onClick={onExploreClick}
|
||||
className="flex-1"
|
||||
icon={<MagnifyingGlassIcon width={16} height={16} />}
|
||||
/>
|
||||
<SecondaryButton
|
||||
title={"Create bot"}
|
||||
title={'Create bot'}
|
||||
onClick={onCreateBotClicked}
|
||||
className="flex-1"
|
||||
icon={<PlusIcon width={16} height={16} />}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(LeftHeaderAction);
|
||||
export default React.memo(LeftHeaderAction)
|
||||
|
||||
@ -2,9 +2,9 @@ import {
|
||||
MainViewState,
|
||||
getMainViewStateAtom,
|
||||
setMainViewStateAtom,
|
||||
} from '@/_helpers/atoms/MainView.atom'
|
||||
import Image from 'next/image'
|
||||
import CompactLogo from '../CompactLogo'
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
|
||||
import CompactLogo from '../../../containers/Logo/CompactLogo'
|
||||
import {
|
||||
ChatBubbleOvalLeftEllipsisIcon,
|
||||
Cog8ToothIcon,
|
||||
@ -13,24 +13,26 @@ import {
|
||||
Squares2X2Icon,
|
||||
} from '@heroicons/react/24/outline'
|
||||
import { useAtomValue, useSetAtom } from 'jotai'
|
||||
import { showingBotListModalAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels'
|
||||
import useGetBots from '@/_hooks/useGetBots'
|
||||
import { showingBotListModalAtom } from '@helpers/atoms/Modal.atom'
|
||||
import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels'
|
||||
import useGetBots from '@hooks/useGetBots'
|
||||
|
||||
import { Icons, Toggle } from '@uikit'
|
||||
|
||||
const menu = [
|
||||
{
|
||||
name: 'Explore Models',
|
||||
iconComponent: <CpuChipIcon width={24} height={24} color="#C7D2FE" />,
|
||||
state: MainViewState.ExploreModel,
|
||||
},
|
||||
// {
|
||||
// name: 'Explore Models',
|
||||
// icon: <CpuChipIcon />,
|
||||
// state: MainViewState.ExploreModel,
|
||||
// },
|
||||
{
|
||||
name: 'My Models',
|
||||
iconComponent: <Squares2X2Icon width={24} height={24} color="#C7D2FE" />,
|
||||
icon: <Icons name="layout-grid" />,
|
||||
state: MainViewState.MyModel,
|
||||
},
|
||||
{
|
||||
name: 'Settings',
|
||||
iconComponent: <Cog8ToothIcon width={24} height={24} color="#C7D2FE" />,
|
||||
icon: <Icons name="settings" />,
|
||||
state: MainViewState.Setting,
|
||||
},
|
||||
]
|
||||
@ -51,13 +53,13 @@ const LeftRibbonNav: React.FC = () => {
|
||||
const bgColor = isConversationView ? 'bg-gray-500' : ''
|
||||
|
||||
const onConversationClick = () => {
|
||||
if (currentState === MainViewState.Conversation) return
|
||||
// if (currentState === MainViewState.Conversation) return
|
||||
setMainViewState(MainViewState.Conversation)
|
||||
}
|
||||
|
||||
const onBotListClick = async () => {
|
||||
const bots = await getAllBots()
|
||||
if (bots.length === 0) {
|
||||
if (bots?.length === 0) {
|
||||
alert('You have no bot')
|
||||
return
|
||||
}
|
||||
@ -71,52 +73,42 @@ const LeftRibbonNav: React.FC = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<nav className="flex h-screen w-20 flex-col bg-gray-900">
|
||||
<div className='mx-auto mt-4'>
|
||||
<nav className="flex h-screen flex-shrink-0 flex-col items-center pt-10">
|
||||
<CompactLogo />
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-1 flex-col items-center justify-between px-3 py-6">
|
||||
<div className="flex flex-1 flex-col gap-2">
|
||||
<button
|
||||
onClick={onConversationClick}
|
||||
className={`rounded-lg p-4 ${bgColor} hover:bg-gray-400`}
|
||||
>
|
||||
<div className="flex w-full flex-1 flex-col items-center justify-between">
|
||||
<div className="flex flex-col pt-4">
|
||||
<button onClick={onConversationClick}>
|
||||
<ChatBubbleOvalLeftEllipsisIcon
|
||||
width={24}
|
||||
height={24}
|
||||
color="#C7D2FE"
|
||||
color="text-white"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
onClick={onBotListClick}
|
||||
className={`rounded-lg p-4 hover:bg-gray-400`}
|
||||
>
|
||||
<CubeTransparentIcon width={24} height={24} color="#C7D2FE" />
|
||||
<button onClick={onBotListClick}>
|
||||
<CubeTransparentIcon />
|
||||
</button>
|
||||
</div>
|
||||
<ul className="flex flex-col gap-3">
|
||||
<ul className="flex flex-col gap-3 py-8">
|
||||
{menu.map((item) => {
|
||||
const bgColor = currentState === item.state ? 'bg-gray-500' : ''
|
||||
return (
|
||||
<li
|
||||
role="button"
|
||||
data-testid={item.name}
|
||||
key={item.name}
|
||||
className={`rounded-lg p-4 ${bgColor} hover:bg-gray-400`}
|
||||
className="item-center flex gap-x-2"
|
||||
onClick={() => onMenuClick(item.state)}
|
||||
>
|
||||
{item.iconComponent}
|
||||
{item.icon}
|
||||
<span className="text-xs">{item.name}</span>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* User avatar */}
|
||||
<div className="flex items-center justify-center pb-5">
|
||||
<Image src={'/icons/avatar.svg'} width={40} height={40} alt="" />
|
||||
</div>
|
||||
{/* <div className="pb-5 flex items-center justify-center">
|
||||
<Image src={"/icons/avatar.svg"} width={40} height={40} alt="" />
|
||||
</div> */}
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import ChatBody from "../ChatBody";
|
||||
import InputToolbar from "../InputToolbar";
|
||||
import ChatBody from '../ChatBody'
|
||||
import InputToolbar from '../InputToolbar'
|
||||
|
||||
const MainChat: React.FC = () => (
|
||||
<div className="flex h-full w-full flex-col">
|
||||
|
||||
@ -1,21 +1,19 @@
|
||||
import React from "react"
|
||||
import LeftContainer from "../LeftContainer"
|
||||
import LeftRibbonNav from "../LeftRibbonNav"
|
||||
import MonitorBar from "../MonitorBar"
|
||||
import RightContainer from "../RightContainer"
|
||||
import CenterContainer from "../CenterContainer"
|
||||
import React from 'react'
|
||||
import LeftContainer from '../LeftContainer'
|
||||
import LeftRibbonNav from '../LeftRibbonNav'
|
||||
import MonitorBar from '../MonitorBar'
|
||||
import RightContainer from '../RightContainer'
|
||||
import CenterContainer from '../CenterContainer'
|
||||
|
||||
const MainContainer: React.FC = () => (
|
||||
<div className="flex h-screen">
|
||||
<LeftRibbonNav />
|
||||
|
||||
<div className="flex flex-1 flex-col h-full">
|
||||
<div className="flex flex-1 flex-col ">
|
||||
<div className="flex flex-1 overflow-hidden">
|
||||
<LeftContainer />
|
||||
<CenterContainer />
|
||||
<RightContainer />
|
||||
</div>
|
||||
|
||||
<MonitorBar />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
import { currentConversationAtom } from '@/_helpers/atoms/Conversation.atom'
|
||||
import { currentConversationAtom } from '@helpers/atoms/Conversation.atom'
|
||||
import {
|
||||
leftSideBarExpandStateAtom,
|
||||
rightSideBarExpandStateAtom,
|
||||
showRightSideBarToggleAtom,
|
||||
} from '@/_helpers/atoms/LeftSideBarExpand.atom'
|
||||
import { TrashIcon } from '@heroicons/react/24/outline'
|
||||
import { showConfirmDeleteConversationModalAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
} from '@helpers/atoms/SideBarExpand.atom'
|
||||
import { showConfirmDeleteConversationModalAtom } from '@helpers/atoms/Modal.atom'
|
||||
import { ChartPieIcon, TrashIcon } from '@heroicons/react/24/outline'
|
||||
import { useAtomValue, useSetAtom } from 'jotai'
|
||||
import React from 'react'
|
||||
import Image from 'next/image'
|
||||
import { Trash2 } from 'lucide-react'
|
||||
|
||||
const MainHeader: React.FC = () => {
|
||||
const setLeftSideBarVisibility = useSetAtom(leftSideBarExpandStateAtom)
|
||||
const setRightSideBarVisibility = useSetAtom(rightSideBarExpandStateAtom)
|
||||
const showRightSideBarToggle = useAtomValue(showRightSideBarToggleAtom)
|
||||
const setShowConfirmDeleteConversationModal = useSetAtom(
|
||||
showConfirmDeleteConversationModalAtom
|
||||
)
|
||||
@ -22,43 +20,19 @@ const MainHeader: React.FC = () => {
|
||||
const currentConvo = useAtomValue(currentConversationAtom)
|
||||
let title = currentConvo?.name ?? ''
|
||||
|
||||
return (
|
||||
<div className="flex justify-between bg-gray-200 px-2 py-3">
|
||||
<Image
|
||||
role="button"
|
||||
alt=""
|
||||
src="icons/ic_sidebar_off.svg"
|
||||
width={24}
|
||||
onClick={() => setLeftSideBarVisibility((prev) => !prev)}
|
||||
height={24}
|
||||
/>
|
||||
if (!activeConversation) return null
|
||||
|
||||
<span className="flex gap-0.5 text-base font-semibold leading-6">
|
||||
{title}
|
||||
</span>
|
||||
return (
|
||||
<div className="sticky top-0 border-b border-border bg-background/90 px-4 py-2">
|
||||
<span className="font-semibold text-muted-foreground">{title}</span>
|
||||
|
||||
{/* right most */}
|
||||
<div className="flex gap-4">
|
||||
{activeConversation != null && (
|
||||
<TrashIcon
|
||||
<div className="absolute right-4 top-2">
|
||||
<Trash2
|
||||
role="button"
|
||||
width={24}
|
||||
height={24}
|
||||
color="#9CA3AF"
|
||||
size={16}
|
||||
onClick={() => setShowConfirmDeleteConversationModal(true)}
|
||||
/>
|
||||
)}
|
||||
|
||||
{showRightSideBarToggle && (
|
||||
<Image
|
||||
role="button"
|
||||
alt=""
|
||||
src="icons/ic_sidebar_off.svg"
|
||||
width={24}
|
||||
onClick={() => setRightSideBarVisibility((prev) => !prev)}
|
||||
height={24}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
@ -8,11 +8,10 @@ import ExploreModelContainer from '../ExploreModelContainer'
|
||||
import {
|
||||
MainViewState,
|
||||
getMainViewStateAtom,
|
||||
} from '@/_helpers/atoms/MainView.atom'
|
||||
} from '@helpers/atoms/MainView.atom'
|
||||
import EmptyChatContainer from '../EmptyChatContainer'
|
||||
import MainChat from '../MainChat'
|
||||
import CreateBotContainer from '../CreateBotContainer'
|
||||
import BotInfoContainer from '../BotInfoContainer'
|
||||
|
||||
const MainView: React.FC = () => {
|
||||
const viewState = useAtomValue(getMainViewStateAtom)
|
||||
@ -38,9 +37,6 @@ const MainView: React.FC = () => {
|
||||
case MainViewState.Welcome:
|
||||
children = <Welcome />
|
||||
break
|
||||
case MainViewState.BotInfo:
|
||||
children = <BotInfoContainer />
|
||||
break
|
||||
default:
|
||||
children = <MainChat />
|
||||
break
|
||||
|
||||
@ -3,7 +3,7 @@ import { Popover, Transition } from '@headlessui/react'
|
||||
import { Fragment } from 'react'
|
||||
// import useGetCurrentUser from "@/_hooks/useGetCurrentUser";
|
||||
import { useSetAtom } from 'jotai'
|
||||
import { showConfirmSignOutModalAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import { showConfirmSignOutModalAtom } from '@helpers/atoms/Modal.atom'
|
||||
|
||||
export const MenuHeader: React.FC = () => {
|
||||
const setShowConfirmSignOutModal = useSetAtom(showConfirmSignOutModalAtom)
|
||||
|
||||
@ -3,7 +3,7 @@ import { Dialog } from '@headlessui/react'
|
||||
import { XMarkIcon } from '@heroicons/react/24/outline'
|
||||
import Image from 'next/image'
|
||||
import { useAtom } from 'jotai'
|
||||
import { showingMobilePaneAtom } from '@/_helpers/atoms/Modal.atom'
|
||||
import { showingMobilePaneAtom } from '@helpers/atoms/Modal.atom'
|
||||
|
||||
const MobileMenuPane: React.FC = () => {
|
||||
const [show, setShow] = useAtom(showingMobilePaneAtom)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import React from 'react'
|
||||
import PrimaryButton from '../PrimaryButton'
|
||||
import { Button } from '@uikit'
|
||||
import ModelActionMenu from '../ModelActionMenu'
|
||||
|
||||
export enum ModelActionType {
|
||||
Start = 'Start',
|
||||
@ -8,41 +9,51 @@ export enum ModelActionType {
|
||||
|
||||
type ModelActionStyle = {
|
||||
title: string
|
||||
backgroundColor: string
|
||||
textColor: string
|
||||
}
|
||||
|
||||
const modelActionMapper: Record<ModelActionType, ModelActionStyle> = {
|
||||
[ModelActionType.Start]: {
|
||||
title: 'Start',
|
||||
backgroundColor: 'bg-blue-500 hover:bg-blue-600',
|
||||
textColor: 'text-white',
|
||||
},
|
||||
[ModelActionType.Stop]: {
|
||||
title: 'Stop',
|
||||
backgroundColor: 'bg-red-500 hover:bg-red-600',
|
||||
textColor: 'text-white',
|
||||
},
|
||||
}
|
||||
|
||||
type Props = {
|
||||
disabled?: boolean
|
||||
loading?: boolean
|
||||
type: ModelActionType
|
||||
onActionClick: (type: ModelActionType) => void
|
||||
onDeleteClick: () => void
|
||||
}
|
||||
|
||||
const ModelActionButton: React.FC<Props> = ({ type, onActionClick }) => {
|
||||
const ModelActionButton: React.FC<Props> = ({
|
||||
disabled,
|
||||
loading,
|
||||
type,
|
||||
onActionClick,
|
||||
onDeleteClick,
|
||||
}) => {
|
||||
const styles = modelActionMapper[type]
|
||||
|
||||
const onClick = () => {
|
||||
onActionClick(type)
|
||||
}
|
||||
|
||||
return (
|
||||
<td className="whitespace-nowrap px-6 py-4 text-sm">
|
||||
<PrimaryButton
|
||||
title={styles.title}
|
||||
onClick={onClick}
|
||||
className={styles.backgroundColor}
|
||||
/>
|
||||
<td className="whitespace-nowrap px-3 py-2 text-right">
|
||||
<div className="flex items-center justify-end gap-x-4">
|
||||
<ModelActionMenu onDeleteClick={onDeleteClick} />
|
||||
<Button
|
||||
disabled={disabled}
|
||||
size="sm"
|
||||
themes={styles.title === 'Start' ? 'accent' : 'default'}
|
||||
onClick={() => onClick()}
|
||||
loading={loading}
|
||||
>
|
||||
{styles.title} Model
|
||||
</Button>
|
||||
</div>
|
||||
</td>
|
||||
)
|
||||
}
|
||||
|
||||
@ -7,36 +7,9 @@ type Props = {
|
||||
}
|
||||
|
||||
const ModelActionMenu: React.FC<Props> = ({ onDeleteClick }) => (
|
||||
<Menu as="div" className="relative flex-none">
|
||||
<Menu.Button className="block text-gray-500 hover:text-gray-900">
|
||||
<span className="sr-only">Open options</span>
|
||||
<EllipsisVerticalIcon className="h-5 w-5" aria-hidden="true" />
|
||||
</Menu.Button>
|
||||
<Transition
|
||||
as={Fragment}
|
||||
enter="transition ease-out duration-100"
|
||||
enterFrom="transform opacity-0 scale-95"
|
||||
enterTo="transform opacity-100 scale-100"
|
||||
leave="transition ease-in duration-75"
|
||||
leaveFrom="transform opacity-100 scale-100"
|
||||
leaveTo="transform opacity-0 scale-95"
|
||||
>
|
||||
<Menu.Items className="absolute right-0 z-50 mt-2 w-32 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-gray-900/5 focus:outline-none">
|
||||
<Menu.Item>
|
||||
{({ active }) => (
|
||||
<button
|
||||
className={`${
|
||||
active ? 'bg-violet-500 text-white' : 'text-gray-900'
|
||||
} group flex w-full items-center rounded-md px-2 py-2 text-sm`}
|
||||
onClick={onDeleteClick}
|
||||
>
|
||||
<button className="text-muted-foreground text-xs" onClick={onDeleteClick}>
|
||||
Delete
|
||||
</button>
|
||||
)}
|
||||
</Menu.Item>
|
||||
</Menu.Items>
|
||||
</Transition>
|
||||
</Menu>
|
||||
)
|
||||
|
||||
export default ModelActionMenu
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { toGigabytes } from '@/_utils/converter'
|
||||
import { toGigabytes } from '@utils/converter'
|
||||
|
||||
type Props = {
|
||||
total: number
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
import React from 'react'
|
||||
import { DownloadState } from '@/_models/DownloadState'
|
||||
|
||||
import {
|
||||
formatDownloadPercentage,
|
||||
formatDownloadSpeed,
|
||||
toGigabytes,
|
||||
} from '@/_utils/converter'
|
||||
} from '@utils/converter'
|
||||
|
||||
type Props = {
|
||||
downloadState: DownloadState
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import React from 'react'
|
||||
import ModelTableHeader from '../ModelTableHeader'
|
||||
import { DownloadState } from '@/_models/DownloadState'
|
||||
import ModelDownloadingRow from '../ModelDownloadingRow'
|
||||
|
||||
type Props = {
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
import React, { useCallback } from 'react'
|
||||
import { ModelStatus, ModelStatusComponent } from '../ModelStatusComponent'
|
||||
import ModelActionMenu from '../ModelActionMenu'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import ModelActionButton, { ModelActionType } from '../ModelActionButton'
|
||||
import useStartStopModel from '@/_hooks/useStartStopModel'
|
||||
import useDeleteModel from '@/_hooks/useDeleteModel'
|
||||
import { AssistantModel } from '@/_models/AssistantModel'
|
||||
import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom'
|
||||
import { toGigabytes } from '@/_utils/converter'
|
||||
import useStartStopModel from '@hooks/useStartStopModel'
|
||||
import useDeleteModel from '@hooks/useDeleteModel'
|
||||
import { activeAssistantModelAtom, stateModel } from '@helpers/atoms/Model.atom'
|
||||
import { toGigabytes } from '@utils/converter'
|
||||
|
||||
type Props = {
|
||||
model: AssistantModel
|
||||
@ -17,6 +15,7 @@ const ModelRow: React.FC<Props> = ({ model }) => {
|
||||
const { startModel, stopModel } = useStartStopModel()
|
||||
const activeModel = useAtomValue(activeAssistantModelAtom)
|
||||
const { deleteModel } = useDeleteModel()
|
||||
const { loading, model: currentModelState } = useAtomValue(stateModel)
|
||||
|
||||
let status = ModelStatus.Installed
|
||||
if (activeModel && activeModel._id === model._id) {
|
||||
@ -38,32 +37,33 @@ const ModelRow: React.FC<Props> = ({ model }) => {
|
||||
|
||||
const onDeleteClick = useCallback(() => {
|
||||
deleteModel(model)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [model])
|
||||
|
||||
return (
|
||||
<tr className="border-b border-gray-200 last:rounded-lg last:border-b-0">
|
||||
<td className="flex flex-col whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-900">
|
||||
<tr className="border-b border-border bg-background/50 last:rounded-lg last:border-b-0">
|
||||
<td className="whitespace-nowrap px-3 font-semibold text-muted-foreground">
|
||||
{model.name}
|
||||
<span className="font-normal text-gray-500">{model.version}</span>
|
||||
<span className="ml-2 font-semibold">v{model.version}</span>
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-6 py-4 text-sm text-gray-500">
|
||||
<td className="whitespace-nowrap px-3 text-muted-foreground">
|
||||
<div className="flex flex-col justify-start">
|
||||
<span>GGUF</span>
|
||||
</div>
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-6 py-4 text-sm text-gray-500">
|
||||
<td className="whitespace-nowrap px-3 text-muted-foreground">
|
||||
{toGigabytes(model.size)}
|
||||
</td>
|
||||
<td className="whitespace-nowrap px-6 py-4 text-sm text-gray-500">
|
||||
<td className="whitespace-nowrap px-3 text-muted-foreground">
|
||||
<ModelStatusComponent status={status} />
|
||||
</td>
|
||||
<ModelActionButton
|
||||
disabled={loading}
|
||||
loading={currentModelState === model._id ? loading : false}
|
||||
type={actionButtonType}
|
||||
onActionClick={onModelActionClick}
|
||||
onDeleteClick={onDeleteClick}
|
||||
/>
|
||||
<td className="relative w-fit whitespace-nowrap px-6 py-4 text-right text-sm font-medium">
|
||||
<ModelActionMenu onDeleteClick={onDeleteClick} />
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { searchingModelText } from '@/_helpers/JotaiWrapper'
|
||||
import { searchingModelText } from '@helpers/JotaiWrapper'
|
||||
import { MagnifyingGlassIcon } from '@heroicons/react/24/outline'
|
||||
import { useSetAtom } from 'jotai'
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
@ -2,9 +2,8 @@ import { Fragment, useEffect } from 'react'
|
||||
import { Listbox, Transition } from '@headlessui/react'
|
||||
import { CheckIcon, ChevronUpDownIcon } from '@heroicons/react/20/solid'
|
||||
import { useAtom, useAtomValue } from 'jotai'
|
||||
import { selectedModelAtom } from '@/_helpers/atoms/Model.atom'
|
||||
import { downloadedModelAtom } from '@/_helpers/atoms/DownloadedModel.atom'
|
||||
import { AssistantModel } from '@/_models/AssistantModel'
|
||||
import { selectedModelAtom } from '@helpers/atoms/Model.atom'
|
||||
import { downloadedModelAtom } from '@helpers/atoms/DownloadedModel.atom'
|
||||
|
||||
function classNames(...classes: any) {
|
||||
return classes.filter(Boolean).join(' ')
|
||||
|
||||
@ -16,17 +16,17 @@ export const ModelStatusMapper: Record<ModelStatus, ModelStatusType> = {
|
||||
[ModelStatus.Installed]: {
|
||||
title: 'Installed',
|
||||
textColor: 'text-black',
|
||||
backgroundColor: 'bg-gray-100',
|
||||
backgroundColor: 'bg-gray-200 text-gray-600',
|
||||
},
|
||||
[ModelStatus.Active]: {
|
||||
title: 'Active',
|
||||
textColor: 'text-black',
|
||||
backgroundColor: 'bg-green-100',
|
||||
textColor: 'text-green-800',
|
||||
backgroundColor: 'bg-green-100 dark:bg-green-300 text-green-700',
|
||||
},
|
||||
[ModelStatus.RunningInNitro]: {
|
||||
title: 'Running in Nitro',
|
||||
textColor: 'text-black',
|
||||
backgroundColor: 'bg-green-100',
|
||||
textColor: 'text-green-800',
|
||||
backgroundColor: 'bg-green-100 dark:bg-green-300 text-green-700',
|
||||
},
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ export const ModelStatusComponent: React.FC<Props> = ({ status }) => {
|
||||
const statusType = ModelStatusMapper[status]
|
||||
return (
|
||||
<div
|
||||
className={`w-fit rounded-[10px] px-2.5 py-0.5 text-xs font-medium ${statusType.backgroundColor}`}
|
||||
className={`w-fit rounded-full px-2.5 py-0.5 text-xs font-medium ${statusType.backgroundColor}`}
|
||||
>
|
||||
{statusType.title}
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import React from 'react'
|
||||
import ModelRow from '../ModelRow'
|
||||
import ModelTableHeader from '../ModelTableHeader'
|
||||
import { AssistantModel } from '@/_models/AssistantModel'
|
||||
|
||||
type Props = {
|
||||
models: AssistantModel[]
|
||||
@ -10,25 +9,25 @@ type Props = {
|
||||
const tableHeaders = ['MODEL', 'FORMAT', 'SIZE', 'STATUS', 'ACTIONS']
|
||||
|
||||
const ModelTable: React.FC<Props> = ({ models }) => (
|
||||
<div className="flow-root min-w-full rounded-lg border border-gray-200 align-middle shadow-lg">
|
||||
<>
|
||||
<div className="border-border overflow-hidden rounded-lg border align-middle shadow-lg">
|
||||
<table className="min-w-full">
|
||||
<thead className="border-b border-gray-200 bg-gray-50">
|
||||
<thead className="bg-background">
|
||||
<tr className="rounded-t-lg">
|
||||
{tableHeaders.map((item) => (
|
||||
<ModelTableHeader key={item} title={item} />
|
||||
))}
|
||||
<th scope="col" className="relative w-fit px-6 py-3">
|
||||
<span className="sr-only">Edit</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{models.map((model) => (
|
||||
{models?.map((model) => (
|
||||
<ModelRow key={model._id} model={model} />
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div className="relative"></div>
|
||||
</>
|
||||
)
|
||||
|
||||
export default React.memo(ModelTable)
|
||||
|
||||
@ -7,7 +7,7 @@ type Props = {
|
||||
const ModelTableHeader: React.FC<Props> = ({ title }) => (
|
||||
<th
|
||||
scope="col"
|
||||
className="px-6 py-3 text-left text-xs font-medium uppercase tracking-wide text-gray-500 first:rounded-tl-lg last:rounded-tr-lg"
|
||||
className="text-muted-foreground border-border border-b p-3 text-left text-xs font-semibold uppercase first:rounded-tl-lg last:rounded-tr-lg last:text-right"
|
||||
>
|
||||
{title}
|
||||
</th>
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
import React, { useMemo } from 'react'
|
||||
import { formatDownloadPercentage, toGigabytes } from '@/_utils/converter'
|
||||
import { formatDownloadPercentage, toGigabytes } from '@utils/converter'
|
||||
import Image from 'next/image'
|
||||
import { Product } from '@/_models/Product'
|
||||
import useDownloadModel from '@/_hooks/useDownloadModel'
|
||||
import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom'
|
||||
import useDownloadModel from '@hooks/useDownloadModel'
|
||||
import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom'
|
||||
import { atom, useAtomValue } from 'jotai'
|
||||
import { ModelVersion } from '@/_models/ModelVersion'
|
||||
import { useGetDownloadedModels } from '@/_hooks/useGetDownloadedModels'
|
||||
import { useGetDownloadedModels } from '@hooks/useGetDownloadedModels'
|
||||
import SimpleTag from '../SimpleTag'
|
||||
import { RamRequired, UsecaseTag } from '../SimpleTag/TagType'
|
||||
|
||||
@ -56,10 +54,9 @@ const ModelVersionItem: React.FC<Props> = ({
|
||||
const { maxRamRequired, usecase } = modelVersion
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-between gap-4 border-t border-gray-200 pb-3 pl-3 pr-4 pt-3 first:border-t-0">
|
||||
<div className="border-border flex items-center justify-between gap-4 border-t pb-3 pl-3 pr-4 pt-3 first:border-t-0">
|
||||
<div className="flex items-center gap-2">
|
||||
<Image src={'/icons/app_icon.svg'} width={14} height={20} alt="" />
|
||||
<span className="font-sm flex-1 text-gray-900">
|
||||
<span className="font-sm text-muted-foreground mb-4 line-clamp-1 flex-1">
|
||||
{modelVersion.name}
|
||||
</span>
|
||||
</div>
|
||||
@ -75,10 +72,10 @@ const ModelVersionItem: React.FC<Props> = ({
|
||||
type={RamRequired.RamDefault}
|
||||
clickable={false}
|
||||
/>
|
||||
</div>
|
||||
<div className="rounded bg-gray-200 px-2.5 py-0.5 text-xs font-medium">
|
||||
<div className="bg-background border-border rounded-full border px-2.5 py-0.5 font-medium">
|
||||
{toGigabytes(modelVersion.size)}
|
||||
</div>
|
||||
</div>
|
||||
{downloadButton}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import React from 'react'
|
||||
import ModelVersionItem from '../ModelVersionItem'
|
||||
import { Product } from '@/_models/Product'
|
||||
import { ModelVersion } from '@/_models/ModelVersion'
|
||||
|
||||
type Props = {
|
||||
model: Product
|
||||
@ -15,11 +13,7 @@ const ModelVersionList: React.FC<Props> = ({
|
||||
recommendedVersion,
|
||||
}) => {
|
||||
return (
|
||||
<div className="border-t border-gray-200 px-4 py-5">
|
||||
<div className="text-sm font-medium text-gray-500">
|
||||
Available Versions
|
||||
</div>
|
||||
<div className="overflow-hidden rounded-lg border border-gray-200">
|
||||
<div className="pt-4">
|
||||
{versions.map((item) => (
|
||||
<ModelVersionItem
|
||||
key={item._id}
|
||||
@ -29,7 +23,6 @@ const ModelVersionList: React.FC<Props> = ({
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
import ProgressBar from '../ProgressBar'
|
||||
import SystemItem from '../SystemItem'
|
||||
import ProgressBar from '@/_components/ProgressBar'
|
||||
import SystemItem from '@containers/SystemItem'
|
||||
import { useAtomValue } from 'jotai'
|
||||
import { appDownloadProgress } from '@/_helpers/JotaiWrapper'
|
||||
import useGetAppVersion from '@/_hooks/useGetAppVersion'
|
||||
import useGetSystemResources from '@/_hooks/useGetSystemResources'
|
||||
import { modelDownloadStateAtom } from '@/_helpers/atoms/DownloadState.atom'
|
||||
import { DownloadState } from '@/_models/DownloadState'
|
||||
import { formatDownloadPercentage } from '@/_utils/converter'
|
||||
import { activeAssistantModelAtom } from '@/_helpers/atoms/Model.atom'
|
||||
import { appDownloadProgress } from '@helpers/JotaiWrapper'
|
||||
import useGetAppVersion from '@hooks/useGetAppVersion'
|
||||
import useGetSystemResources from '@hooks/useGetSystemResources'
|
||||
import { modelDownloadStateAtom } from '@helpers/atoms/DownloadState.atom'
|
||||
import { formatDownloadPercentage } from '@utils/converter'
|
||||
import { activeAssistantModelAtom } from '@helpers/atoms/Model.atom'
|
||||
|
||||
const MonitorBar: React.FC = () => {
|
||||
const progress = useAtomValue(appDownloadProgress)
|
||||
@ -22,7 +21,7 @@ const MonitorBar: React.FC = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-row items-center justify-between border-t border-gray-200">
|
||||
<div className="flex flex-row items-center justify-between">
|
||||
{progress && progress >= 0 ? (
|
||||
<ProgressBar total={100} used={progress} />
|
||||
) : null}
|
||||
@ -40,7 +39,7 @@ const MonitorBar: React.FC = () => {
|
||||
{activeModel && (
|
||||
<SystemItem name={`Active model: ${activeModel.name}`} value={''} />
|
||||
)}
|
||||
<span className="text-sm text-gray-900">v{version}</span>
|
||||
<span className="text-xs">v{version}</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user