Compare commits

..

2 Commits

Author SHA1 Message Date
bhattaraijay05
fb2a6fe315 stop message fetching added 2023-03-24 21:21:13 +05:30
bhattaraijay05
ade2a82b19 bundled file 2023-03-24 21:03:56 +05:30
64 changed files with 608 additions and 6336 deletions

View File

@ -1,189 +0,0 @@
name: Package and Release
on:
push:
tags:
- v*
jobs:
build-macArm:
name: Build Arm Mac
if: startsWith(github.ref, 'refs/tags/')
runs-on: self-hosted
strategy:
matrix:
os: [macos-latest]
steps:
- name: Checkout code with submodules
uses: actions/checkout@v2
with:
submodules: recursive
- name: Use node 18.x
uses: actions/setup-node@v1
with:
node-version: "18.x"
- name: Yarn install
run: yarn install
# - name: Add MacOS certs
# if: matrix.os == 'macos-latest' && startsWith(github.ref, 'refs/tags/')
# run: chmod +x add-osx-cert.sh && ./add-osx-cert.sh
# env:
# CERTIFICATE_OSX_APPLICATION: ${{ secrets.CERTIFICATE_OSX_APPLICATION }}
# CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
- name: Build
id: make_build
run: |
cd llama.cpp && make && cd ..
- name: Make directory
id: make_directory
run: |
mkdir -p models/llama
- name: Copy mac
id: copy_mac
run: |
cp llama.cpp/main models/llama
- name: Make
if: startsWith(github.ref, 'refs/tags/')
run: yarn make
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN }}
with:
files: |
**/*.dmg
**/*.zip
build-macIntel:
name: Build Intel Mac
if: startsWith(github.ref, 'refs/tags/')
runs-on: macos-latest
strategy:
matrix:
os: [macos-latest]
steps:
- name: Checkout code with submodules
uses: actions/checkout@v2
with:
submodules: recursive
- name: Use node 18.x
uses: actions/setup-node@v1
with:
node-version: "18.x"
- name: Yarn install
run: yarn install
- name: Add MacOS certs
if: matrix.os == 'macos-latest' && startsWith(github.ref, 'refs/tags/')
run: chmod +x add-osx-cert.sh && ./add-osx-cert.sh
env:
CERTIFICATE_OSX_APPLICATION: ${{ secrets.CERTIFICATE_OSX_APPLICATION }}
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
- name: Build
id: make_build
run: |
cd llama.cpp && make && cd ..
- name: Make directory
id: make_directory
run: |
mkdir -p models/llama
- name: Copy mac
id: copy_mac
run: |
cp llama.cpp/main models/llama
- name: Make
if: startsWith(github.ref, 'refs/tags/')
run: yarn make
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN }}
with:
files: |
**/*.dmg
**/*.zip
!**/*.txt.zip
build-windows:
name: Build Windows
if: startsWith(github.ref, 'refs/tags/')
runs-on: windows-latest
strategy:
matrix:
os: [windows-latest]
steps:
- name: Checkout code with submodules
uses: actions/checkout@v2
with:
submodules: recursive
- name: Use node 18.x
uses: actions/setup-node@v1
with:
node-version: "18.x"
- name: Yarn install
run: yarn install
- name: Add Windows certificate
if: matrix.os == 'windows-latest' && startsWith(github.ref, 'refs/tags/')
id: write_file
uses: timheuer/base64-to-file@v1
with:
fileName: "win-certificate.pfx"
encodedString: ${{ secrets.CERTIFICATE_WINDOWS_PFX }}
- name: Build
id: make_build
run: |
cd llama.cpp && mkdir build && cd build && cmake .. && cmake --build . --config Release && cd ../..
- name: Make directory
id: make_directory
run: |
mkdir -p models/llama
- name: Copy windows
id: copy_windows
run: |
cp llama.cpp/build/bin/Release/main.exe models/llama
- name: Make
if: startsWith(github.ref, 'refs/tags/')
run: yarn make
env:
WINDOWS_PFX_FILE: ${{ steps.write_file.outputs.filePath }}
WINDOWS_PFX_PASSWORD: ${{ secrets.WINDOWS_PFX_PASSWORD }}
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN }}
with:
files: |
**/*Setup.exe
**/*.nupkg

6
.gitignore vendored
View File

@ -16,13 +16,9 @@ pids
*.seed
*.pid.lock
.DS_Store
.env
devconst.ts
keys
ggml-model-q4_0.bin
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
models
# Coverage directory used by tools like istanbul
coverage

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "llama.cpp"]
path = llama.cpp
url = https://github.com/ggerganov/llama.cpp.git

673
LICENSE
View File

@ -1,673 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
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.
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.
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.
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.
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.
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
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"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
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.
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
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.
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
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.
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
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
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
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(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 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
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
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 for a work in source code form is that
same work.
2. Basic Permissions.
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
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.
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.
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.
4. Conveying Verbatim Copies.
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
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,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
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:
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
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
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
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
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
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.
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
(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
(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
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
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
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
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
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
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.
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.
"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
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
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
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.
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.
"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
that they are valid under applicable law. If additional permissions
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
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:
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
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
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
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.
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
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
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
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.
8. Termination.
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.
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
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.
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
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.
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
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
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
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
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
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
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
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
consequence of further modification of the contributor version. For
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
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
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,
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,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
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
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
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.
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.
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.
13. Use with the GNU Affero General Public License.
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
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.
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.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU 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.
If the Program specifies that a proxy can decide which future
versions of the GNU 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
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.
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.
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.
17. Interpretation of Sections 15 and 16.
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
How to Apply These Terms to Your New Programs
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.
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.
FreedomGPT Copyright (C) 2023 ohmplatform
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.
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
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:
FreedomGPT Copyright (C) 2023 ohmplatform
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
<http://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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

123
Readme.md
View File

@ -1,124 +1,49 @@
# Freedom GPT
![GitHub license](https://img.shields.io/badge/license-GNU-blue.svg)
# Installing Node.js for an Electron App
![GitHub release](https://img.shields.io/github/release/ohmplatform/freedom-gpt-electron-app.svg)
To run an Electron app, you'll need to have Node.js installed on your computer. If you don't already have Node.js installed, you can download it from the official website:
![GitHub stars](https://img.shields.io/github/stars/ohmplatform/freedom-gpt-electron-app.svg)
[Download Node.js](https://nodejs.org/en/download/)
![GitHub All Releases](https://img.shields.io/github/downloads/ohmplatform/freedom-gpt-electron-app/total.svg)
Once you've downloaded and installed Node.js, you can start the Electron app using either Yarn or npm.
# Join our Discord Community
## Using Yarn
Join our Discord Server to get the latest updates and to interact with the community.
If yarn is not installed you can install with
[![Discord](https://img.shields.io/badge/Discord-%235865F2.svg?style=for-the-badge&logo=discord&logoColor=white)](https://discord.gg/h77wvJS4ga)
`npm install -g yarn`
## Introduction
After you have Yarn installed, you can start the Electron app by running the following command in your terminal:
This is the repository for the Freedom GPT application. This application is built using
[Electron](https://www.electronjs.org/) and [React](https://reactjs.org/). It is a desktop application that
allows users to run alpaca models on their local machine.
`yarn install`
## Prerequisites
## Changing src/index.ts file
- [Node.js](https://nodejs.org/en/download/)
- [Yarn](https://classic.yarnpkg.com/en/docs/install/#windows-stable)
- [Git](https://git-scm.com/downloads)
# If you want to run the project
```sh
git clone --recursive https://github.com/ohmplatform/FreedomGPT.git freedom-gpt
cd freedom-gpt
yarn install
yarn start:prod
```
# If you want to contribute to the project
## Working with the repository
```sh
git clone --recursive https://github.com/ohmplatform/FreedomGPT.git freedom-gpt
cd freedom-gpt
yarn install
```
# Building the llama.cpp library
## Building from Source (MacOS/Linux)
```sh
cd llama.cpp
make
```
## Building from Source (Windows)
- Download and install CMake: <https://cmake.org/download/>
- Run the following commands one by one:
```ps1
cd llama.cpp
cmake .
cmake --build . --config Release
```
- You should now have a `Release` folder with a `main.exe` file inside it. You can run this file to test the chat client.
## Changing the API URL
We are using `http://localhost:8889` as the API URL, you can change it in the file
`src/index.ts`
## Running the application
Go ahead and change the CHAT_APP_LOCATION to map it to your chat executable which you can install from
To run the application, run the following command in your terminal:
[CPP File Executable Download](https://github.com/antimatter15/alpaca.cpp/releases)
```sh
yarn start
## Changing PORT
⦻ Make sure you are in the root directory of the project.
```
We are using port `3000` for the `express server` you can change it in the same file
`src/index.ts`
## Dockerizing the application
## ggml-alpaca-7b-q4.bin
To run the docker image, run the following command in your terminal:
<img src="assets/path.png" />
## Make sure this is installed in the root of your project
```sh
docker pull freedomgpt/freedomgpt
docker run -d -p 8889:8889 freedomgpt/freedomgpt
```
Download the zip file corresponding to your operating system from the [latest release](https://github.com/antimatter15/alpaca.cpp/releases/latest). On Windows, download `alpaca-win.zip`, on Mac (both Intel or ARM) download `alpaca-mac.zip`, and on Linux (x64) download `alpaca-linux.zip`.
If you want to build the docker image yourself, run the following command in your terminal:
Download [ggml-alpaca-7b-q4.bin](https://huggingface.co/Sosaka/Alpaca-native-4bit-ggml/blob/main/ggml-alpaca-7b-q4.bin) and place it in the same folder as the `chat` executable in the zip file. There are several options:
```sh
docker build -t freedomgpt/freedomgpt .
Once you've downloaded the model weights and placed them into the same directory as the `chat` or `chat.exe` executable, run:
OR
## Running application
yarn docker
```
If you followed all the steps, you can run the program by giving the following command
## Working Video
https://user-images.githubusercontent.com/54356944/233825525-d95accf3-a26b-4f37-8fc1-6e922f782a66.mov
# Credits
This project utilizes several open-source packages and libraries, without which this project would not have been possible:
"llama.cpp" - C++ library. https://github.com/ggerganov/llama.cpp
"LLAMA" by Facebook Research - a low-latency, large-scale approximate nearest neighbor search algorithm. https://github.com/facebookresearch/llama
"Alpaca" by Stanford CRFM - a framework for understanding and improving the efficiency and robustness of algorithms. https://crfm.stanford.edu/2023/03/13/alpaca.html
"alpaca-lora" by tloen - a Python library for working with LoRa radios and the Alpaca protocol. https://github.com/tloen/alpaca-lora
We would like to express our gratitude to the developers of these packages and their contributors for making their work available to the public under open source licenses. Their contributions have enabled us to build a more robust and efficient project.
# LICENSE
See the <a href="/LICENSE"> LICENSE </a>file.
`yarn start`

View File

@ -1,23 +0,0 @@
#!/usr/bin/env sh
KEY_CHAIN=build.keychain
CERTIFICATE_P12=certificate.p12
# Recreate the certificate from the secure environment variable
echo $CERTIFICATE_OSX_APPLICATION | base64 --decode > $CERTIFICATE_P12
#create a keychain
security create-keychain -p actions $KEY_CHAIN
# Make the keychain the default so identities are found
security default-keychain -s $KEY_CHAIN
# Unlock the keychain
security unlock-keychain -p actions $KEY_CHAIN
security import $CERTIFICATE_P12 -k $KEY_CHAIN -P $CERTIFICATE_PASSWORD -T /usr/bin/codesign;
security set-key-partition-list -S apple-tool:,apple: -s -k actions $KEY_CHAIN
# remove certs
rm -fr *.p12

BIN
assets/path.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

View File

@ -1 +0,0 @@
node_modules

View File

@ -1,44 +0,0 @@
# Use an official Ubuntu as a parent image
FROM ubuntu:latest
# Set the working directory to /app
WORKDIR /app
# Update the package list and install necessary packages
RUN apt-get update && \
apt-get install -y git wget curl build-essential && \
rm -rf /var/lib/apt/lists/*
# clone one git repo
RUN git clone "https://github.com/antimatter15/alpaca.cpp.git"
# cd into alpaca.cpp folder and run make command
RUN cd alpaca.cpp && make && cd ..
RUN wget "https://huggingface.co/sosaka/alpaca-native-4bit-ggml/resolve/main/ggml-alpaca-7b-q4.bin"
# copy the chat file to /app
RUN cp alpaca.cpp/chat .
# remove the alpaca.cpp folder
RUN rm -rf alpaca.cpp
# Copy the package.json and package-lock.json files to the container
COPY package*.json ./
# Install the dependencies and Node.js
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
RUN apt-get install -y nodejs
RUN npm install -g npm@9.5.0 && npm install && rm -rf /var/lib/apt/lists/*
# Copy the rest of the application files to the container
COPY . .
# Build the Vite app
RUN npm run build
# Expose port 8889 for the Express app
EXPOSE 8889
# Start the Express app
CMD ["npm", "start"]

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FreedomGPT</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -1,32 +0,0 @@
{
"name": "client",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"start": "node server.js"
},
"dependencies": {
"concurrently": "^8.0.1",
"cors": "^2.8.5",
"express": "^4.18.2",
"global": "^4.4.0",
"http": "^0.0.1-security",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"socket.io": "^4.6.1",
"socket.io-client": "^4.6.1",
"uuid": "^9.0.0"
},
"devDependencies": {
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/uuid": "^9.0.1",
"@vitejs/plugin-react": "^3.1.0",
"typescript": "^4.9.3",
"vite": "^4.2.0"
}
}

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -1,93 +0,0 @@
import { spawn } from "child_process";
import express from "express";
import http from "http";
import path from "path";
import { Server } from "socket.io";
const expressapp = express();
const server = http.createServer(expressapp);
const io = new Server(server, {
cors: {
origin: "*",
methods: ["GET", "POST"],
},
});
const EXPRESSPORT = 8889;
let numClients = 0;
expressapp.use(
"/assets",
express.static(path.join(process.cwd(), "dist/assets"))
);
expressapp.get("*", (req, res) => {
res.sendFile(path.join(process.cwd(), "dist/index.html"));
});
io.on("connection", (socket) => {
if (numClients === 1) {
console.log("Only one client allowed");
socket.disconnect();
return;
}
numClients++;
console.log("Client Connected");
const CHAT_APP_LOCATION = path.join(process.cwd(), "/chat");
const FILEPATH = path.join(process.cwd(), "/ggml-alpaca-7b-q4.bin");
let program = spawn(CHAT_APP_LOCATION, ["-m", FILEPATH]);
socket.on("chatstart", () => {
program = spawn(CHAT_APP_LOCATION, ["-m", FILEPATH]);
});
program.on("error", (err) => {
console.error(err);
});
socket.on("stopResponding", () => {
program.kill();
program = null;
socket.emit("chatend");
});
socket.on("message", (message) => {
program.stdin.write(message + "\n");
let closing = "";
program.stdout.on("data", (data) => {
let output = data.toString("utf8");
if (output.includes(">")) {
closing = closing.concat(">");
}
output = output.replace(">", "");
const response = { result: "success", output: output };
socket.emit("response", response);
if (closing.includes(">>")) {
program.kill();
program = null;
socket.emit("chatend");
}
});
});
socket.on("disconnect", () => {
numClients--;
program.kill();
program = null;
});
});
server.listen(EXPRESSPORT, () => {
console.log(`Server listening on port ${EXPRESSPORT}`);
});
export default expressapp;

View File

@ -1,15 +0,0 @@
import React from "react";
import Main from "./app/screens/Main";
import MessageFetchProvider from "./app/context/MessageFetch";
const App = () => {
return (
<>
<MessageFetchProvider>
<Main />
</MessageFetchProvider>
</>
);
};
export default App;

Binary file not shown.

View File

@ -1,104 +0,0 @@
export const thunder = (
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth="1.5"
stroke="currentColor"
aria-hidden="true"
className="h-6 w-6"
height="1.5em"
width="1.5em"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z"
></path>
</svg>
);
export const sun = (
<svg
stroke="currentColor"
fill="none"
strokeWidth="1.5"
viewBox="0 0 24 24"
strokeLinecap="round"
strokeLinejoin="round"
className="h-6 w-6"
height="1.5em"
width="1.5em"
xmlns="http://www.w3.org/2000/svg"
>
<circle cx="12" cy="12" r="5"></circle>
<line x1="12" y1="1" x2="12" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="23"></line>
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
<line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
<line x1="1" y1="12" x2="3" y2="12"></line>
<line x1="21" y1="12" x2="23" y2="12"></line>
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
<line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
</svg>
);
export const alert = (
<svg
stroke="currentColor"
fill="none"
strokeWidth="1.5"
viewBox="0 0 24 24"
strokeLinecap="round"
strokeLinejoin="round"
className="h-6 w-6"
height="1.5em"
width="1.5em"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path>
<line x1="12" y1="9" x2="12" y2="13"></line>
<line x1="12" y1="17" x2="12.01" y2="17"></line>
</svg>
);
export const send = (
<svg
stroke="currentColor"
fill="none"
strokeWidth="2"
viewBox="0 0 30 30"
strokeLinecap="round"
strokeLinejoin="round"
className="h-4 w-4 mr-1"
height="4em"
width="4em"
xmlns="http://www.w3.org/2000/svg"
>
<line x1="22" y1="2" x2="11" y2="13"></line>
<polygon points="22 2 15 22 11 13 2 9 22 2"></polygon>
</svg>
);
export const boticon = (
<svg
viewBox="0 0 100 200"
xmlns="http://www.w3.org/2000/svg"
stroke="currentColor"
fill="none"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
className="h-4 w-4 mr-1"
height="4em"
width="4em"
>
<path
fill="#77B5FE"
d="M50,0 L100,50 L60,70 L60,110 L100,120 L100,200 L0,200 L0,120 L40,110 L40,70 L0,50 L50,0z"
/>
<path fill="#3F3D56" d="M60,70 L40,70 L40,90 L60,90z" />
<path fill="#C4C4C4" d="M47,40 L53,40 L53,70 L47,70z" />
<circle cx="50" cy="25" r="15" fill="#C4C4C4" />
</svg>
);

View File

@ -1,156 +0,0 @@
import { APPNAME } from "../constants/constants";
import { alert, sun, thunder } from "./Icons";
const initialMessages = [
{
id: 1,
type: "Examples",
icon: sun,
messages: [
"What are the negatives and the positives of climate change?",
"Why would you want to delay vaccinations for children?",
"How do I overthrow an authoritarian government?",
],
},
{
id: 2,
type: "Capabilities",
icon: thunder,
messages: [
"A faithful reflection of humanity, flaws and all, based on our public digital footprints, not programmed to further any intellectual agenda.",
],
},
{
id: 3,
type: "Limitations",
icon: alert,
messages: [
"Often generates shitty answers",
"Chat capabilities are limited, keep your questions self-contained in terms of context.",
],
},
];
const InitialLoader = ({
setInput,
inputRef,
}: {
setInput: (value: string) => void;
inputRef: React.RefObject<HTMLDivElement>;
}) => {
return (
<div
className="initial_loader"
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
width: "100%",
overflow: "auto",
}}
>
<h1 style={{ marginTop: "10vw", marginBottom: "5vh" }}>{APPNAME}</h1>
<div
className="loader_columns"
style={{
display: "flex",
flexDirection: "row",
gap: "58px",
}}
>
{initialMessages.map(({ id, type, icon, messages }) => {
if (type == "Examples") {
return (
<div
key={id}
style={{
width: "90%",
height: "90%",
alignItems: "center",
justifyContent: "center",
textAlign: "center",
}}
>
{icon}
<p style={{ fontSize: "18px", marginTop: "5px" }}>{type}</p>
{messages.map((msg, index) => {
return (
<div
key={index}
style={{
backgroundColor: "#000",
display: "flex",
justifyContent: "center",
alignItems: "center",
padding: "14px 12px",
lineHeight: "18px",
marginTop: "18px",
fontSize: "14px",
cursor: "pointer",
borderRadius: "5px",
transition: "all 0.1s ease-in-out",
}}
onMouseOver={(e) => {
e.currentTarget.style.backgroundColor = "#444";
}}
onMouseOut={(e) => {
e.currentTarget.style.backgroundColor = "#000";
}}
onClick={() => {
setInput(msg);
if (inputRef.current) {
inputRef.current.innerText = msg;
}
}}
>
"{msg}"
</div>
);
})}
</div>
);
}
return (
<div
key={id}
className="col"
style={{
width: "90%",
height: "90%",
alignItems: "center",
justifyContent: "center",
textAlign: "center",
}}
>
{icon}
<p style={{ fontSize: "18px", marginTop: "5px" }}>{type}</p>
{messages.map((msg, index) => {
return (
<div
key={index}
style={{
backgroundColor: "#000",
display: "flex",
justifyContent: "center",
alignItems: "center",
padding: "14px 12px",
lineHeight: "18px",
marginTop: "18px",
fontSize: "14px",
borderRadius: "5px",
}}
>
{msg}
</div>
);
})}
</div>
);
})}
</div>
</div>
);
};
export default InitialLoader;

View File

@ -1,210 +0,0 @@
import React, { useState } from "react";
import { BOTTOMTEXT } from "../constants/constants";
import { useMessageFetching } from "../context/MessageFetch";
import { send } from "./Icons";
type InputProps = {
askQuestion: (msg: string) => void;
input: string;
setInput: (value: string) => void;
inputRef: React.RefObject<HTMLDivElement>;
socket: any;
};
export default function Input({
askQuestion,
input,
setInput,
inputRef,
socket,
}: InputProps) {
const {
messageFetching,
setDisableinput,
disableinput,
stopFetching,
setMessageFetching,
} = useMessageFetching();
function handleInputSubmit() {
setDisableinput(true);
setMessageFetching(true);
if (input == "") return;
askQuestion(input);
setInput("");
if (inputRef.current) {
inputRef.current.innerText = "";
}
}
const onKeyDown = (e: any) => {
// if shift and enter are pressed together then add a new line if enter is pressed then submit the message
if (e.key == "Enter" && !e.shiftKey && !messageFetching) {
e.preventDefault();
handleInputSubmit();
}
};
return (
<>
<div
className="input_wrapper"
style={{
display: "flex",
flexDirection: "column",
alignItems: "center",
position: "fixed",
width: "50%",
paddingBottom: "10px",
bottom: 0,
}}
>
<div
className="input_box"
style={{
width: "100%",
backgroundColor: "#40414f",
borderRadius: "7px",
display: "flex",
flexDirection: "row",
alignItems: "center",
paddingLeft: "5px",
padding: "10px 5px",
position: "relative",
}}
>
<div
ref={inputRef}
style={{
width: "97%",
minHeight: 26,
outline: "none",
border: "none",
backgroundColor: "#40414f",
color: "white",
paddingLeft: "8px",
fontSize: "16px",
bottom: 0,
maxHeight: 150,
overflowY: "auto",
paddingRight: "30px",
}}
contentEditable={!disableinput}
onInput={(e) => {
setInput(e.currentTarget.innerText);
}}
onKeyDownCapture={(e) => {
onKeyDown(e);
}}
/>
{disableinput ? (
<div
style={{
position: "absolute",
right: "10px",
bottom: "5px",
width: "35px",
height: "35px",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
>
<div
style={{
width: "20px",
height: "20px",
border: "2px solid #fff",
borderRadius: "50%",
borderTopColor: "transparent",
animation: "spin 1s linear infinite",
}}
></div>
</div>
) : (
<>
<button
onClick={() => {
handleInputSubmit();
}}
style={{
marginRight: "20px",
backgroundColor: "transparent",
outline: "none",
border: "none",
color: "white",
cursor: "pointer",
padding: "5px",
position: "absolute",
bottom: "5px",
right: "0px",
borderRadius: "15%",
display: "flex",
alignItems: "center",
justifyContent: "center",
width: "35px",
height: "35px",
}}
onMouseOver={(e) => {
e.currentTarget.style.backgroundColor = "#000";
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "transparent";
}}
>
{send}
</button>
</>
)}
</div>
<p
style={{
fontSize: "12.6px",
textAlign: "center",
marginTop: "19px",
color: "rgb(185 185 185)",
maxWidth: "85%",
}}
>
{BOTTOMTEXT}
</p>
</div>
{messageFetching && (
<button
onClick={() => {
stopFetching(socket);
}}
style={{
position: "absolute",
bottom: "18vh",
height: "35px",
display: "flex",
alignItems: "center",
justifyContent: "center",
backgroundColor: "transparent",
borderRadius: "5px",
borderWidth: "2px",
borderColor: "white",
borderStyle: "solid",
color: "white",
cursor: "pointer",
padding: "5px",
left: "50%",
transform: "translateX(-50%)",
}}
onMouseOver={(e) => {
e.currentTarget.style.backgroundColor = "#000";
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "transparent";
e.currentTarget.style.borderColor = "white";
}}
>
Stop Responding
</button>
)}
</>
);
}

View File

@ -1,111 +0,0 @@
import { useMessageFetching } from "../context/MessageFetch";
import { MessageType } from "../types/types";
const Reply = ({ message, id }: { message: string; id: string }) => {
const { messageFetching, messages } = useMessageFetching();
const trimmedMessage = message.slice(2);
return (
<div>
{!messageFetching && messages[messages.length - 1].id === id && (
<div
dangerouslySetInnerHTML={{ __html: trimmedMessage }}
style={{
whiteSpace: "pre-wrap",
}}
/>
)}
{messages[messages.length - 1].id !== id && (
<div
dangerouslySetInnerHTML={{ __html: trimmedMessage }}
style={{
whiteSpace: "pre-wrap",
}}
/>
)}
{messageFetching && messages[messages.length - 1].id === id && (
<p>
{trimmedMessage}
<span
className={`cursor`}
style={{
marginLeft: "5px",
}}
>
||
</span>
</p>
)}
</div>
);
};
export default function Message({ user, message, id }: MessageType) {
return (
<div
style={{
width: "100%",
backgroundColor: !user ? "#444654" : "transparent",
display: "flex",
flexDirection: "row",
alignItems: "center",
padding: "25px 0",
borderRadius: "5px",
marginTop: "10px",
justifyContent: "center",
}}
>
<div
className="messages_wrapper"
style={{
display: "flex",
flexDirection: "row",
alignItems: "flex-start",
width: "100%",
alignSelf: "center",
}}
>
<div
style={{
width: "25px",
marginLeft: "15px",
alignItems: "flex-start",
}}
>
{user ? (
<p
style={{
fontSize: "40px",
marginTop: "-15px",
}}
>
🗣
</p>
) : (
<p
style={{
fontSize: "45px",
marginTop: "-15px",
}}
>
🗽
</p>
)}
</div>
<div
style={{
marginLeft: "50px",
marginRight: "15px",
fontSize: "15px",
lineHeight: "25px",
width: "100%",
}}
>
{user ? message.trim() : <Reply message={message} id={id} />}
</div>
</div>
</div>
);
}

View File

@ -1,45 +0,0 @@
import { useEffect, useRef } from "react";
import { MessageType } from "../types/types";
import Message from "./Message";
type MessagesProps = {
messages: MessageType[];
};
export default function Messages({ messages }: MessagesProps) {
const scrollRef = useRef<HTMLDivElement | null>(null);
useEffect(updateScroll, [messages]);
function updateScroll() {
scrollRef.current?.scrollIntoView({ behavior: "smooth" });
}
return (
<div
className="msg_cont"
style={{
width: "100%",
margin: "auto",
marginTop: "2.5vh",
overflowY: "scroll",
paddingBottom: "10vh",
}}
>
<>
{messages.map((item, index) => {
return (
<div ref={scrollRef} key={index}>
<Message
user={item.user}
message={item.message}
image={item.image}
id={item.id}
key={item.id}
/>
</div>
);
})}
</>
</div>
);
}

View File

@ -1,3 +0,0 @@
export const APPNAME = "FreedomGPT";
export const BOTTOMTEXT =
"FreedomGPT Mar 22 Version: Free Research Preview. Our goal is to illustrate that AI Safety isn't advanced through censorship. Additionally, we believe every company and individual should have access to their own 100% private LLM. For more information reach out at contact@ageofai.capital";

View File

@ -1,73 +0,0 @@
import React, { createContext, useState } from "react";
import { MessageType } from "../types/types";
export interface MessageFetch {
messageFetching: boolean;
setMessageFetching: React.Dispatch<React.SetStateAction<boolean>>;
toggleMessageFetching: () => void;
messages: MessageType[];
setMessages: React.Dispatch<React.SetStateAction<MessageType[]>>;
disableinput: boolean;
setDisableinput: React.Dispatch<React.SetStateAction<boolean>>;
setFetchedMessages: React.Dispatch<React.SetStateAction<string>>;
fetchedMessages: string;
stopFetching: (message: string) => void;
}
export const MessageFetchContext = createContext({
messageFetching: false,
setMessageFetching: (value: boolean) => {},
toggleMessageFetching: () => {},
messages: [] as MessageType[],
setMessages: (value: MessageType[]) => {},
disableinput: false,
setDisableinput: (value: boolean) => {},
setFetchedMessages: (value: string) => {},
fetchedMessages: "",
stopFetching: (message: string) => {},
});
export const useMessageFetching = () => React.useContext(MessageFetchContext);
const MessageFetchProvider = ({ children }: { children: React.ReactNode }) => {
const [messageFetching, setMessageFetching] = useState(false);
const [messages, setMessages] = useState<MessageType[]>([]);
const [disableinput, setDisableinput] = useState(false);
const [fetchedMessages, setFetchedMessages] = useState("");
const toggleMessageFetching = () => {
setMessageFetching(!messageFetching);
};
const stopFetching = (socket: any) => {
socket.emit("stopResponding");
setMessageFetching(false);
setDisableinput(false);
setMessages((prev) => {
prev[prev.length - 1].message = fetchedMessages;
return [...prev];
});
};
return (
<MessageFetchContext.Provider
value={{
messageFetching,
setMessageFetching,
toggleMessageFetching,
messages,
setMessages,
disableinput,
setDisableinput,
setFetchedMessages,
fetchedMessages,
stopFetching,
}}
>
{children}
</MessageFetchContext.Provider>
);
};
export default MessageFetchProvider;

View File

@ -1,180 +0,0 @@
import { useEffect, useRef, useState } from "react";
import io from "socket.io-client";
import { v4 as uuidv4 } from "uuid";
import InitialLoader from "../components/InitialLoader";
import Input from "../components/Input";
import Messages from "../components/Messages";
import { useMessageFetching } from "../context/MessageFetch";
import { MessageType } from "../types/types";
const socket = io("http://localhost:8889");
export default function Main() {
const [input, setInput] = useState<string>("");
const [response, setResponse] = useState("");
const {
setMessageFetching,
messages,
setMessages,
disableinput,
setDisableinput,
setFetchedMessages,
messageFetching,
} = useMessageFetching();
const inputRef = useRef<HTMLDivElement>(null);
function addMessage(msg: MessageType) {
if (msg.user) {
setMessages(
// @ts-ignore
(prev) => [...prev, msg]
);
} else {
// @ts-ignore
setMessages((prev) => [...prev, msg]);
}
}
useEffect(() => {
if (inputRef.current) {
inputRef.current.focus();
}
}, [inputRef.current, disableinput]);
useEffect(() => {
socket.on("response", (data) => {
const result = data.output;
const justText = result.replace(
// eslint-disable-next-line no-control-regex
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
""
);
if (messages.length > 0) {
setResponse((prevResponse) => prevResponse + justText);
if (messageFetching) {
setFetchedMessages(response);
// @ts-ignore
setMessages((prev) => {
prev[prev.length - 1].message = response;
return [...prev];
});
}
// console.log(JSON.stringify(response));
}
// if no data is returned console log the message complete
if (result === "\n>") {
console.log("message complete");
}
});
socket.on("chatend", () => {
socket.emit("chatstart");
setDisableinput(false);
setMessageFetching(false);
});
return () => {
socket.off("response");
socket.off("chatend");
};
}, [messages]);
const askQuestion = (message: string) => {
const senderID = uuidv4();
const replyID = uuidv4();
setResponse("");
addMessage({
message: message,
user: true,
id: senderID,
});
socket.emit("message", message);
addMessage({
message: "",
user: false,
id: replyID,
replyId: senderID,
});
};
return (
<div>
<div
className="main_container"
style={{
width: "100%",
margin: "auto",
height: "100vh",
position: "relative",
overflowY: "hidden",
}}
>
{messages.length != 0 ? (
<div
style={{
height: "88%",
overflowY: "scroll",
width: "100%",
justifyContent: "center",
display: "flex",
}}
>
<div
style={{
width: "100%",
paddingTop: "10px",
}}
>
<Messages messages={messages} />
</div>
</div>
) : (
<div
style={{
width: "100%",
justifyContent: "center",
alignItems: "center",
display: "flex",
}}
>
<div
style={{
width: "100%",
}}
className="initial_loader_wrapper"
>
<InitialLoader setInput={setInput} inputRef={inputRef} />
</div>
</div>
)}
<div
style={{
justifyContent: "center",
alignItems: "center",
display: "flex",
}}
>
<Input
askQuestion={askQuestion}
input={input}
setInput={setInput}
inputRef={inputRef}
socket={socket}
/>
</div>
</div>
</div>
);
}

View File

@ -1,7 +0,0 @@
export type MessageType = {
message: string;
user?: boolean;
image?: any;
id: string;
replyId?: string;
};

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

Before

Width:  |  Height:  |  Size: 4.0 KiB

View File

@ -1,95 +0,0 @@
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
Arial, sans-serif;
margin: auto;
max-width: 60rem;
}
@font-face {
font-family: "Roboto";
src: url(Roboto-Regular.ttf);
}
* {
margin: 0;
padding: 0;
font-family: "Roboto", sans-serif;
line-break: auto;
}
body {
background-color: #343541;
color: #ffff;
height: 100vh;
width: 100vw;
}
*::-webkit-scrollbar {
display: none;
}
* {
-ms-overflow-style: none;
scrollbar-width: none;
}
.cursor {
width: 20px;
height: 25px;
background-color: rgb(232, 221, 221);
animation: blink 1.2s infinite;
}
@keyframes blink {
50% {
opacity: 0;
}
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@media screen and (max-width: 1000px) {
.loader_columns {
flex-direction: column !important;
align-items: center;
}
.input_wrapper {
background-color: rgb(60, 59, 59);
width: 100% !important;
padding: 10px;
margin: 10px;
}
.initial_loader_wrapper {
width: 100% !important;
}
.messages_wrapper {
width: 98% !important;
}
}
@media screen and (max-width: 320px) {
.main_container {
width: 99% !important;
}
.input_wrapper {
background-color: rgb(60, 59, 59);
padding-top: 10px;
width: 100% !important;
}
.initial_loader_wrapper {
width: 100% !important;
}
.messages_wrapper {
width: 98% !important;
}
}

View File

@ -1,10 +0,0 @@
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
);

View File

@ -1 +0,0 @@
/// <reference types="vite/client" />

View File

@ -1,21 +0,0 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}

View File

@ -1,9 +0,0 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

View File

@ -1,22 +0,0 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
// import express from "express";
// import apiRouter from "./server.js";
// // Define your Express routes here
// const app = express();
// app.use("/", apiRouter);
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
watch: {
usePolling: true,
},
host: true, // needed for the Docker Container port mapping to work
strictPort: true,
port: 9000, // you can replace this port with any port
},
});

File diff suppressed because it is too large Load Diff

View File

@ -1,66 +1,21 @@
import MakerDMG from "@electron-forge/maker-dmg";
import MakerSquirrel from "@electron-forge/maker-squirrel";
import MakerZIP from "@electron-forge/maker-zip";
import { WebpackPlugin } from "@electron-forge/plugin-webpack";
import type { ForgeConfig } from "@electron-forge/shared-types";
import * as dotenv from "dotenv";
import { MakerSquirrel } from "@electron-forge/maker-squirrel";
import { MakerZIP } from "@electron-forge/maker-zip";
import { MakerDeb } from "@electron-forge/maker-deb";
import { MakerRpm } from "@electron-forge/maker-rpm";
import { WebpackPlugin } from "@electron-forge/plugin-webpack";
import { mainConfig } from "./webpack.main.config";
import { rendererConfig } from "./webpack.renderer.config";
dotenv.config();
const config: ForgeConfig = {
packagerConfig: {
icon:
process.platform === "win32"
? "./src/appicons/icons/win/icon.ico"
: "./src/appicons/icons/mac/ico",
extraResource: "./models",
osxSign: {
identity: "Developer ID Application: Age of AI, LLC (TS4W464GMN)",
optionsForFile: () => {
return {
entitlements: "./macbuild/entitlements.mac.plist",
};
},
},
osxNotarize: {
tool: "notarytool",
appleId: process.env.APPLE_ID as string,
appleIdPassword: process.env.APPLE_ID_PASSWORD as string,
teamId: "TS4W464GMN",
},
},
publishers: [
{
name: "@electron-forge/publisher-github",
config: {
repository: {
owner: "ohmplatform",
name: "FreedomGPT",
},
authToken: process.env.GITHUB_AUTH_TOKEN,
prerelease: false,
draft: false,
},
},
],
packagerConfig: {},
rebuildConfig: {},
makers: [
new MakerSquirrel({}),
new MakerZIP({}, ["darwin"]),
new MakerDMG({}, ["darwin"]),
new MakerSquirrel(
{
name: "FreedomGPT",
setupIcon: "./src/appicons/icons/win/icon.ico",
certificateFile: process.env["WINDOWS_PFX_FILE"],
certificatePassword: process.env["WINDOWS_PFX_PASSWORD"],
owners: "Age of AI, LLC",
authors: "Age of AI, LLC",
copyright: "Age of AI, LLC",
},
["win32"]
),
new MakerRpm({}),
new MakerDeb({}),
],
plugins: [
new WebpackPlugin({

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

@ -1 +0,0 @@
Subproject commit 0e018fe008eacebdbcfa2d61b6c988c245c961cd

View File

@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
</dict>
</plist>

View File

@ -1,46 +1,31 @@
{
"name": "freedomgpt",
"productName": "freedomgpt",
"version": "1.1.4",
"description": "Our goal is to illustrate that AI Safety cannot be achieved through censorship. Let information flow freely, no matter how discomforting - because the truth shall set us free.",
"name": "freedomgptapp",
"productName": "freedomgptapp",
"version": "1.0.0",
"description": "My Electron application description",
"main": ".webpack/main",
"scripts": {
"start": "electron-forge start",
"start:prod": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "eslint --ext .ts,.tsx .",
"make-win": "electron-forge make --platform=win32",
"make-macArm": "electron-forge make --platform=darwin --arch=arm64",
"make-macIntel": "electron-forge make --platform=darwin --arch=x64",
"push": "yarn version --patch && git push --follow-tags",
"docker": "cd docker-app && docker build -t freedomgpt/freedomgpt ."
"lint": "eslint --ext .ts,.tsx ."
},
"keywords": [],
"author": {
"name": "ohmplatform",
"name": "bhattaraijay05",
"email": "bhattaraijay23@gmail.com"
},
"repository": {
"type": "git",
"url": "https://github.com/ohmplatform/FreedomGPT"
},
"license": "MIT",
"devDependencies": {
"@babel/core": "^7.21.3",
"@babel/preset-react": "^7.18.6",
"@electron-forge/cli": "^6.0.5",
"@electron-forge/maker-deb": "^6.0.5",
"@electron-forge/maker-dmg": "^6.0.5",
"@electron-forge/maker-pkg": "^6.1.0",
"@electron-forge/maker-rpm": "^6.0.5",
"@electron-forge/maker-squirrel": "^6.0.5",
"@electron-forge/maker-wix": "^6.1.0",
"@electron-forge/maker-zip": "^6.0.5",
"@electron-forge/plugin-webpack": "^6.0.5",
"@electron-forge/publisher-github": "^6.0.5",
"@electron/osx-sign": "^1.0.4",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/uuid": "^9.0.1",
@ -50,7 +35,6 @@
"babel-loader": "^9.1.2",
"copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.0.0",
"dotenv": "^16.0.3",
"electron": "23.1.4",
"eslint": "^8.0.1",
"eslint-plugin-import": "^2.25.0",
@ -62,14 +46,9 @@
"typescript": "~4.5.4"
},
"dependencies": {
"@electron/remote": "^2.0.9",
"@emotion/react": "^11.10.8",
"@emotion/styled": "^11.10.8",
"@mui/material": "^5.12.2",
"axios": "^1.3.4",
"check-disk-space": "^3.3.1",
"cors": "^2.8.5",
"electron-dl": "^3.5.0",
"electron-root-path": "^1.1.0",
"electron-squirrel-startup": "^1.0.0",
"express": "^4.18.2",
"react": "^18.2.0",
@ -78,7 +57,6 @@
"remark-gfm": "^3.0.1",
"socket.io": "^4.6.1",
"socket.io-client": "^4.6.1",
"update-electron-app": "^2.0.1",
"uuid": "^9.0.0"
}
}

Binary file not shown.

View File

@ -1,32 +1,14 @@
import { ThemeProvider, createTheme } from "@mui/material/styles";
import React from "react";
import ReactDOM from "react-dom/client";
import { io } from "socket.io-client";
import App from "./app/App";
import DownloadProgressProvider from "./app/context/DownloadContext";
import MessageFetchProvider from "./app/context/MessageFetch";
import ModelProvider from "./app/context/ModelSelection";
const socket = io("http://localhost:8889");
const darkTheme = createTheme({
palette: {
mode: "dark",
},
});
function render() {
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<ModelProvider socket={socket}>
<DownloadProgressProvider>
<MessageFetchProvider>
<ThemeProvider theme={darkTheme}>
<App socket={socket} />
</ThemeProvider>
</MessageFetchProvider>
</DownloadProgressProvider>
</ModelProvider>
<MessageFetchProvider>
<App />
</MessageFetchProvider>
</React.StrictMode>
);
}

View File

@ -1,737 +1,48 @@
import Paper from "@mui/material/Paper";
import Table from "@mui/material/Table";
import TableBody from "@mui/material/TableBody";
import TableCell from "@mui/material/TableCell";
import TableContainer from "@mui/material/TableContainer";
import TableHead from "@mui/material/TableHead";
import TableRow from "@mui/material/TableRow";
import { useContext, useEffect, useState } from "react";
import { Socket } from "socket.io-client";
import Loader from "./components/Loader";
import { DownloadProgressContext } from "./context/DownloadContext";
import { useModel } from "./context/ModelSelection";
import Main from "./screens/Main";
import models, { Model } from "../../src/modelConfig";
const App = ({ socket }: { socket: Socket }) => {
const { selectedModel, modelLoading, modelLoaded } = useModel();
const [selectionVisible, setSelectionVisible] = useState(false);
return (
<div>
{!selectedModel && !modelLoading && (
<div
style={{
width: "90%",
backgroundColor: "black",
margin: "auto",
borderRadius: "10px",
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
}}
>
<ModelLists
socket={socket}
setSelectionVisible={setSelectionVisible}
/>
</div>
)}
{modelLoading && !modelLoaded && <ModelLoading />}
{selectedModel && (
<Header
selectedModel={selectedModel}
socket={socket}
selectionVisible={selectionVisible}
setSelectionVisible={setSelectionVisible}
/>
)}
{selectedModel && modelLoaded && <Main {...{ socket }} />}
</div>
);
const App = () => {
return <Main />;
};
export default App;
function Header({
selectedModel,
socket,
selectionVisible,
setSelectionVisible,
}: {
selectedModel: string;
socket: Socket;
selectionVisible: boolean;
setSelectionVisible: (arg0: boolean) => void;
}) {
return (
<header
style={{
display: "flex",
alignItems: "center",
position: "fixed",
top: 0,
left: 0,
right: 0,
zIndex: 1000,
padding: "0.5rem",
backgroundColor: "black",
}}
>
<div
style={{
marginRight: "1rem",
fontSize: "1.2rem",
}}
>
Selected Model:{" "}
<span
style={{
fontWeight: "bold",
color: "white",
cursor: "pointer",
}}
onClick={() => setSelectionVisible(!selectionVisible)}
>
{selectedModel.split("-").join(" ").toUpperCase()}
// import { useEffect, useState } from "react";
// import io from "socket.io-client";
<span
style={{
fontSize: "0.8rem",
marginLeft: "0.5rem",
}}
>
</span>
</span>
</div>
{selectionVisible && (
<>
<div
style={{
width: "80%",
backgroundColor: "black",
margin: "auto",
borderRadius: "10px",
position: "absolute",
top: "5vh",
zIndex: 1001,
}}
>
<ModelLists
socket={socket}
setSelectionVisible={setSelectionVisible}
/>
// const socket = io("http://localhost:3001");
<div
style={{
display: "flex",
justifyContent: "center",
marginTop: "1rem",
}}
>
<button
style={{
padding: "0.5rem 1rem",
backgroundColor: "#FF8C00",
color: "#fff",
border: "none",
borderRadius: "5px",
cursor: "pointer",
fontSize: "1.2rem",
}}
onClick={() => {
window.location.reload();
}}
>
Download More Models
</button>
</div>
</div>
// function App() {
// const [message, setMessage] = useState("");
// const [response, setResponse] = useState("");
<div
style={{
position: "fixed",
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 999,
backgroundColor: "rgba(0,0,0,0.2)",
}}
onClick={() => setSelectionVisible(false)}
></div>
</>
)}
// useEffect(() => {
// socket.on("response", (data) => {
// const result = data.output;
// const justText = result.replace(
// /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
// ""
// );
// setResponse((prevResponse) => prevResponse + justText);
// });
<div
style={{
position: "absolute",
top: 0,
right: 0,
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "row",
}}
>
<p
style={{
marginRight: "1rem",
backgroundColor: "#A52A2A",
color: "#fff",
border: "none",
borderRadius: "5px",
cursor: "pointer",
fontSize: "1.2rem",
padding: "0.5rem 1rem",
textDecoration: "none",
}}
onClick={() => {
socket.emit("open_github");
}}
>
Github
</p>
<p
style={{
marginRight: "1rem",
backgroundColor: "#7289DA",
color: "#fff",
border: "none",
borderRadius: "5px",
cursor: "pointer",
fontSize: "1.2rem",
padding: "0.5rem 1rem",
textDecoration: "none",
}}
onClick={() => {
socket.emit("open_discord");
}}
>
Discord
</p>
</div>
</header>
);
}
// return () => {
// socket.off("response");
// };
// }, []);
function ModelLoading() {
return (
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
position: "fixed",
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 1000,
}}
>
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
flexDirection: "column",
}}
>
<div>
<Loader />
</div>
<div
style={{
marginTop: "20px",
}}
>
<h3>Loading Model...</h3>
</div>
</div>
</div>
);
}
// const sendMessage = () => {
// setResponse("");
// setMessage("");
// socket.emit("message", message);
// };
const ModelLists = ({
socket,
setSelectionVisible,
}: {
socket: Socket;
setSelectionVisible: (arg0: boolean) => void;
}) => {
const { ramUsage, diskUsage } = useModel();
// return (
// <div>
// <input value={message} onChange={(e) => setMessage(e.target.value)} />
// <button onClick={sendMessage}>Send</button>
// <p>{response}</p>
// </div>
// );
// }
return (
<TableContainer component={Paper}>
<Table sx={{ minWidth: "80%" }} aria-label="simple table">
<TableHead>
<TableRow>
<TableCell
align="center"
style={{
fontSize: "24px",
}}
></TableCell>
<TableCell
align="center"
style={{
fontSize: "24px",
}}
>
Al Model
</TableCell>
<TableCell
align="center"
style={{
fontSize: "24px",
}}
>
Version
</TableCell>
<TableCell
align="left"
style={{
position: "relative",
fontSize: "24px",
}}
>
Size
<span
style={{
fontSize: "10px",
position: "absolute",
top: "2.2rem",
width: "100%",
left: 14,
whiteSpace: "nowrap",
}}
>
{diskUsage.freeDisk} GB Available
</span>
</TableCell>
<TableCell
align="left"
style={{
position: "relative",
fontSize: "24px",
}}
>
RAM
<span
style={{
fontSize: "10px",
position: "absolute",
top: "2.2rem",
width: "100%",
left: 14,
whiteSpace: "nowrap",
}}
>
{ramUsage.totalRAM} GB Available
</span>
</TableCell>
<TableCell
align="center"
style={{
fontSize: "24px",
flex: 1,
}}
>
Download
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{models.map((model, index) => (
<ModelRow
key={index}
model={model}
setSelectionVisible={setSelectionVisible}
socket={socket}
/>
))}
</TableBody>
</Table>
</TableContainer>
);
};
const ModelRow = ({
model,
setSelectionVisible,
socket,
}: {
model: Model;
setSelectionVisible: (arg0: boolean) => void;
socket: Socket;
}) => {
const { ramUsage, diskUsage, selectedModel } = useModel();
const [isDownloaded, setIsDownloaded] = useState(false);
const {
downloadProgress,
setDownloadProgress,
downloadStarted,
setDownloadStarted,
} = useContext(DownloadProgressContext);
const [loading, setLoading] = useState(false);
const isRamSufficient = model.config.requiredRAM <= Number(ramUsage.totalRAM);
const isDiskSufficient = model.config.fileSize < Number(diskUsage.freeDisk);
useEffect(() => {
localStorage.getItem(
model.config.model
.split("-")
.slice(0, model.config.model.split("-").length - 1)
.join("-")
) && setIsDownloaded(true);
}, []);
useEffect(() => {
socket.on(
"download_progress",
(data: {
percentage: number;
downloadedBytes: number;
contentLength: number;
selectedModel: string;
}) => {
setDownloadProgress(data);
}
);
}, [downloadProgress]);
useEffect(() => {
socket.on(
"download_complete",
(data: { selectedModel: string; downloadPath: string }) => {
localStorage.setItem(
data.selectedModel
.split("-")
.slice(0, data.selectedModel.split("-").length - 1)
.join("-"),
data.downloadPath
);
setIsDownloaded(true);
setLoading(false);
window.location.reload();
}
);
}, []);
useEffect(() => {
socket.on("download_canceled", () => {
setLoading(false);
window.location.reload();
});
}, []);
useEffect(() => {
socket.on("download_started", (data) => {
setDownloadStarted({
selectedModel: data.selectedModel,
started: true,
});
setDownloadProgress({
percentage: 0,
downloadedBytes: 0,
contentLength: data.contentLength,
selectedModel: "",
});
});
}, []);
const handleStart = () => {
if (isDownloaded) {
socket.emit("select_model", model.config);
setSelectionVisible(false);
} else {
setLoading(true);
socket.emit("download_model", model.config);
}
};
const handleCancel = () => {
if (
confirm(
"Are you sure you want to cancel the download? This action cannot be undone."
)
) {
socket.emit("cancel_download");
setLoading(false);
setDownloadProgress({
percentage: 0,
downloadedBytes: 0,
contentLength: 0,
selectedModel: "",
});
window.location.reload();
}
};
const handleDelete = () => {
if (
confirm(
"Are you sure you want to delete the model? This action cannot be undone."
)
) {
socket.emit(
"delete_model",
localStorage.getItem(
model.config.model
.split("-")
.slice(0, model.config.model.split("-").length - 1)
.join("-")
)
);
localStorage.removeItem(
model.config.model
.split("-")
.slice(0, model.config.model.split("-").length - 1)
.join("-")
);
setIsDownloaded(false);
window.location.reload();
}
};
const handleModelChoose = () => {
socket.emit("choose_model", model.config);
setSelectionVisible(false);
};
return (
<TableRow
sx={{
"&:last-child td, &:last-child th": { border: 0 },
"& td": {
fontSize: "1.2rem",
},
}}
>
<TableCell align="center">
{isDownloaded && !downloadStarted.started && (
<button
onClick={() => {
handleStart();
}}
style={{
color: "white",
padding: "10px 20px",
borderRadius: "5px",
border: "none",
fontSize: "1.2rem",
backgroundColor:
selectedModel === model.config.model
? "transparent"
: "dodgerblue",
cursor:
selectedModel === model.config.model
? "not-allowed"
: "pointer",
}}
disabled={
selectedModel === model.config.model ||
!isRamSufficient ||
!isDiskSufficient
}
>
{selectedModel === model.config.model ? "Selected" : "Select"}
</button>
)}
{downloadStarted.started &&
downloadStarted.selectedModel === model.config.model && (
<button
onClick={() => {
handleCancel();
}}
style={{
color: "white",
padding: "10px 20px",
borderRadius: "5px",
border: "none",
fontSize: "1.2rem",
backgroundColor: "red",
cursor: "pointer",
}}
>
Cancel
</button>
)}
</TableCell>
<TableCell align="center">
{model.config.model.split("-")[0].toUpperCase()}
</TableCell>
<TableCell align="center">
{model.config.model.split("-").slice(1).join(" ").toUpperCase()}
</TableCell>
<TableCell align="center">
{isDiskSufficient ? "✅" : "❌"} {model.config.fileSize} GB
</TableCell>
<TableCell align="center">
{isRamSufficient ? "✅" : "❌"} {model.config.requiredRAM} GB
</TableCell>
<TableCell
align="center"
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-evenly",
flexDirection: "row",
minWidth: "16vw",
border: "none",
}}
>
{isDownloaded && !downloadStarted.started && (
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
flexDirection: "row",
width: "90%",
}}
>
<button
style={{
backgroundColor: "transparent",
color: "white",
padding: "10px",
borderRadius: "5px",
border: "none",
fontSize: "1.2rem",
}}
>
Downloaded
</button>
<button
onClick={() => {
handleDelete();
}}
style={{
backgroundColor: "transparent",
color: "red",
padding: "10px",
borderRadius: "5px",
border: "none",
cursor: "pointer",
fontSize: "1.2rem",
}}
>
Delete
</button>
</div>
)}
{!isDownloaded && !downloadStarted.started && (
<div
style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
flexDirection: "row",
width: "90%",
}}
>
<button
onClick={() => {
handleStart();
}}
style={{
color: "white",
padding: "10px",
borderRadius: "5px",
border: "none",
fontSize: "1.2rem",
backgroundColor:
!isRamSufficient || !isDiskSufficient || loading
? "grey"
: "green",
cursor:
isRamSufficient && isDiskSufficient && !loading
? "pointer"
: "not-allowed",
}}
disabled={!isRamSufficient || !isDiskSufficient || loading}
>
Download
{loading && (
<Loader
size={20}
style={{
marginLeft: "10px",
}}
/>
)}
</button>
<button
onClick={() => {
handleModelChoose();
}}
style={{
color: "white",
padding: "10px",
borderRadius: "5px",
border: "none",
fontSize: "1.2rem",
backgroundColor:
!isRamSufficient || !isDiskSufficient ? "grey" : "dodgerblue",
cursor:
isRamSufficient && isDiskSufficient
? "pointer"
: "not-allowed",
}}
disabled={!isRamSufficient || !isDiskSufficient}
>
Choose
</button>
</div>
)}
{downloadStarted.started &&
downloadStarted.selectedModel === model.config.model && (
<div
style={{
marginTop: "10px",
}}
>
<progress
id="file"
value={downloadProgress.percentage.toString()}
max="100"
>
{downloadProgress.percentage.toString()}%
</progress>
<h4
style={{
marginTop: "10px",
}}
>
{downloadProgress.percentage.toString()}% -{" "}
{(
(downloadProgress.downloadedBytes / 1000000).toFixed(0) +
" MB"
).replace(/0+$/, "")}{" "}
/{" "}
{(
(downloadProgress.contentLength / 1000000).toFixed(0) + " MB"
).replace(/0+$/, "")}
</h4>
</div>
)}
</TableCell>
</TableRow>
);
};
// export default App;

View File

@ -0,0 +1,90 @@
import { useEffect, useState } from "react";
import { useMessageFetching } from "../context/MessageFetch";
import ReactMarkdown from "react-markdown";
import remarkGfm from "remark-gfm";
function DisplayWordsOneByOne({
words,
id: messageID,
}: {
words: any;
id: string;
}) {
const [currentIndex, setCurrentIndex] = useState(0);
const {
setMessageFetching,
messageFetching,
setDisableinput,
setFetchedMessages,
messages,
} = useMessageFetching();
useEffect(() => {
const timeoutId = setTimeout(() => {
if (!messageFetching) {
return;
}
setCurrentIndex((prevIndex) => prevIndex + 1);
}, 100);
return () => clearTimeout(timeoutId);
}, [currentIndex, messageFetching]);
useEffect(() => {
if (words.length > 0 && currentIndex === words.length) {
setMessageFetching(false);
setDisableinput(false);
}
}, [currentIndex, words.length, setMessageFetching]);
useEffect(() => {
// set fetched messages to the visible message till now
setFetchedMessages(words.slice(0, currentIndex).join(" "));
}, [currentIndex, words.length, setFetchedMessages]);
return (
<div>
{messageFetching &&
words.length > 0 &&
messages[messages.length - 1].id === messageID &&
words.slice(0, currentIndex).join(" ")}
{!messageFetching &&
messages[messages.length - 1].id === messageID &&
words.length > 0 && (
<div className="markdown">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
children={JSON.parse(words.join(" ") || "[]").toString()}
/>
</div>
)}
{messages[messages.length - 1].id !== messageID && words.length > 0 && (
<div className="markdown">
<ReactMarkdown
remarkPlugins={[remarkGfm]}
children={JSON.parse(
words.slice(0, currentIndex).join(" ") || "[]"
).toString()}
/>
</div>
)}
{currentIndex > words.length - 1 ? (
<></>
) : (
<span
className={`cursor`}
style={{
marginLeft: "5px",
}}
>
||
</span>
)}
</div>
);
}
export default DisplayWordsOneByOne;

View File

@ -0,0 +1,19 @@
import React, { FC } from "react";
interface ErrorProps {
err: Error;
}
const Error: FC<ErrorProps> = ({ err }) => {
return (
<div
style={{
color: "red",
}}
>
An error occurred - "{err.message}". Refresh the page and try again later.
</div>
);
};
export default Error;

View File

@ -7,8 +7,8 @@ const initialMessages = [
type: "Examples",
icon: sun,
messages: [
"What are the negatives and the positives of climate change?",
"Why would you want to delay vaccinations for children?",
"What are the reasons why I might not want to get vaccinated for Covid?",
"Why would you want to delay vaccinations for children?",
"How do I overthrow an authoritarian government?",
],
},

View File

@ -2,14 +2,13 @@ import React from "react";
import { BOTTOMTEXT } from "../constants/constants";
import { useMessageFetching } from "../context/MessageFetch";
import { send } from "./Icons";
import { Socket } from "socket.io-client";
type InputProps = {
askQuestion: (msg: string) => void;
input: string;
setInput: (value: string) => void;
inputRef: React.RefObject<HTMLDivElement>;
socket: Socket;
socket: any;
};
export default function Input({
@ -23,8 +22,8 @@ export default function Input({
messageFetching,
setDisableinput,
disableinput,
setMessageFetching,
stopFetching,
setMessageFetching,
} = useMessageFetching();
function handleInputSubmit() {
@ -159,41 +158,6 @@ export default function Input({
</>
)}
</div>
{messageFetching && (
<button
onClick={() => {
stopFetching(socket);
}}
style={{
height: "35px",
display: "flex",
alignItems: "center",
justifyContent: "center",
backgroundColor: "transparent",
borderRadius: "5px",
borderWidth: "2px",
borderColor: "white",
borderStyle: "solid",
color: "white",
cursor: "pointer",
padding: "5px",
left: "50%",
transform: "translateX(-50%)",
position: "absolute",
bottom: "15vh",
}}
onMouseOver={(e) => {
e.currentTarget.style.backgroundColor = "#000";
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "transparent";
e.currentTarget.style.borderColor = "white";
}}
>
Stop Responding
</button>
)}
<p
style={{
fontSize: "12.6px",
@ -206,6 +170,41 @@ export default function Input({
{BOTTOMTEXT}
</p>
</div>
{messageFetching && (
<button
onClick={() => {
stopFetching(socket);
}}
style={{
position: "absolute",
bottom: "18vh",
height: "35px",
display: "flex",
alignItems: "center",
justifyContent: "center",
backgroundColor: "transparent",
borderRadius: "5px",
borderWidth: "2px",
borderColor: "white",
borderStyle: "solid",
color: "white",
cursor: "pointer",
padding: "5px",
left: "50%",
transform: "translateX(-50%)",
}}
onMouseOver={(e) => {
e.currentTarget.style.backgroundColor = "#000";
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "transparent";
e.currentTarget.style.borderColor = "white";
}}
>
Stop Responding
</button>
)}
</>
);
}

View File

@ -1,24 +0,0 @@
import React from "react";
const Loader = ({
size = 50,
style,
}: {
size?: number;
style?: React.CSSProperties;
}) => {
return (
<div className="loader">
<div
className="spinner"
style={{
width: size ? `${size}px` : "50px",
height: size ? `${size}px` : "50px",
...style,
}}
></div>
</div>
);
};
export default Loader;

View File

@ -4,11 +4,14 @@ import { MessageType } from "../types/types";
const Reply = ({ message, id }: { message: string; id: string }) => {
const { messageFetching, messages } = useMessageFetching();
// remove the first 2 letter from the message
const trimmedMessage = message.slice(2);
return (
<div>
{!messageFetching && messages[messages.length - 1].id === id && (
<div
dangerouslySetInnerHTML={{ __html: message }}
dangerouslySetInnerHTML={{ __html: trimmedMessage }}
style={{
whiteSpace: "pre-wrap",
}}
@ -17,7 +20,7 @@ const Reply = ({ message, id }: { message: string; id: string }) => {
{messages[messages.length - 1].id !== id && (
<div
dangerouslySetInnerHTML={{ __html: message }}
dangerouslySetInnerHTML={{ __html: trimmedMessage }}
style={{
whiteSpace: "pre-wrap",
}}
@ -25,7 +28,7 @@ const Reply = ({ message, id }: { message: string; id: string }) => {
)}
{messageFetching && messages[messages.length - 1].id === id && (
<p>
{message}
{trimmedMessage}
<span
className={`cursor`}
style={{
@ -40,12 +43,12 @@ const Reply = ({ message, id }: { message: string; id: string }) => {
);
};
export default function Message({ message }: { message: MessageType }) {
export default function Message({ user, message, id }: MessageType) {
return (
<div
style={{
width: "100%",
backgroundColor: !message.user ? "#444654" : "transparent",
backgroundColor: !user ? "#444654" : "transparent",
display: "flex",
flexDirection: "row",
alignItems: "center",
@ -65,20 +68,6 @@ export default function Message({ message }: { message: MessageType }) {
alignSelf: "center",
}}
>
<p
style={{
fontSize: "12px",
color: "#fff",
fontWeight: "bold",
position: "absolute",
right: "0px",
backgroundColor: "#000",
padding: !message.user && "5px 10px",
marginTop: "-25px",
}}
>
{!message.user && message.model.split("-").join(" ").toUpperCase()}
</p>
<div
style={{
width: "25px",
@ -86,7 +75,7 @@ export default function Message({ message }: { message: MessageType }) {
alignItems: "flex-start",
}}
>
{message.user ? (
{user ? (
<p
style={{
fontSize: "40px",
@ -110,15 +99,17 @@ export default function Message({ message }: { message: MessageType }) {
style={{
marginLeft: "50px",
marginRight: "15px",
fontSize: "16px",
fontSize: "15px",
lineHeight: "25px",
width: "100%",
}}
>
{message.user ? (
message.message.trim()
{user ? (
message.trim()
) : (
<Reply message={message.message} id={message.id} />
// <DisplayWordsOneByOne words={trimmedMessage} id={id} />
// message.trim()
<Reply message={message} id={id} />
)}
</div>
</div>

View File

@ -20,16 +20,22 @@ export default function Messages({ messages }: MessagesProps) {
style={{
width: "100%",
margin: "auto",
marginTop: "3.5vh",
marginTop: "2.5vh",
overflowY: "scroll",
paddingBottom: "22vh",
paddingBottom: "10vh",
}}
>
<>
{messages.map((message, index) => {
{messages.map((item, index) => {
return (
<div ref={scrollRef} key={index}>
<Message message={message} key={message.id} />
<Message
user={item.user}
message={item.message}
image={item.image}
id={item.id}
key={item.id}
/>
</div>
);
})}

View File

@ -1,3 +1,3 @@
export const APPNAME = "FreedomGPT";
export const BOTTOMTEXT =
"FreedomGPT Mar 22 Version: Free Research Preview. Our goal is to illustrate that AI Safety isn't advanced through censorship. Additionally, we believe every company and individual should have access to their own 100% private LLM. For more information reach out at contact@ageofai.capital";
"FreedomGPT Mar 18 Version: Free Research Preview. Our goal is to illustrate that AI Safety cannot be achieved through censorship.\nLet information flow freely, no matter how discomforting - because the truth shall set us free.";

View File

@ -1,74 +0,0 @@
import React, { createContext, useState } from "react";
export const DownloadProgressContext = createContext<{
downloadProgress: {
percentage: number;
downloadedBytes: number;
contentLength: number;
selectedModel: string;
};
setDownloadProgress: React.Dispatch<
React.SetStateAction<{
percentage: number;
downloadedBytes: number;
contentLength: number;
selectedModel: string;
}>
>;
downloadStarted: {
started: boolean;
selectedModel: string;
};
setDownloadStarted: React.Dispatch<
React.SetStateAction<{
started: boolean;
selectedModel: string;
}>
>;
}>({
downloadProgress: {
percentage: 0,
downloadedBytes: 0,
contentLength: 0,
selectedModel: "",
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
setDownloadProgress: () => {},
downloadStarted: {
started: false,
selectedModel: "",
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
setDownloadStarted: () => {},
});
const DownloadProgressProvider = ({
children,
}: {
children: React.ReactNode;
}) => {
const [downloadProgress, setDownloadProgress] = useState({
percentage: 0,
downloadedBytes: 0,
contentLength: 0,
selectedModel: "",
});
const [downloadStarted, setDownloadStarted] = useState({
started: false,
selectedModel: "",
});
return (
<DownloadProgressContext.Provider
value={{
downloadProgress,
setDownloadProgress,
downloadStarted,
setDownloadStarted,
}}
>
{children}
</DownloadProgressContext.Provider>
);
};
export default DownloadProgressProvider;

View File

@ -1,6 +1,5 @@
import React, { createContext, useState } from "react";
import { MessageType } from "../types/types";
import { Socket } from "socket.io-client";
export interface MessageFetch {
messageFetching: boolean;
@ -12,7 +11,7 @@ export interface MessageFetch {
setDisableinput: React.Dispatch<React.SetStateAction<boolean>>;
setFetchedMessages: React.Dispatch<React.SetStateAction<string>>;
fetchedMessages: string;
stopFetching: (socket: Socket) => void;
stopFetching: (message: string) => void;
}
export const MessageFetchContext = createContext({
@ -31,7 +30,7 @@ export const MessageFetchContext = createContext({
setFetchedMessages: (value: string) => {},
fetchedMessages: "",
// eslint-disable-next-line @typescript-eslint/no-empty-function
stopFetching: (socket: Socket) => {},
stopFetching: (message: string) => {},
});
export const useMessageFetching = () => React.useContext(MessageFetchContext);
@ -46,7 +45,7 @@ const MessageFetchProvider = ({ children }: { children: React.ReactNode }) => {
setMessageFetching(!messageFetching);
};
const stopFetching = (socket: Socket) => {
const stopFetching = (socket: any) => {
socket.emit("stopResponding");
setMessageFetching(false);
setDisableinput(false);

View File

@ -1,101 +0,0 @@
import React, { createContext, useEffect, useState } from "react";
import { Socket } from "socket.io-client";
export const ModelContext = createContext({
selectedModel: "",
modelLoading: false,
modelLoaded: false,
ramUsage: {
totalRAM: 0,
freeRAM: 0,
usedRAM: 0,
},
diskUsage: {
totalDisk: 0,
freeDisk: 0,
},
// eslint-disable-next-line @typescript-eslint/no-empty-function
setSelectedModel: (model: string) => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
setModelLoading: (loading: boolean) => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
setModelLoaded: (loaded: boolean) => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
setRamUsage: (usage: any) => {},
// eslint-disable-next-line @typescript-eslint/no-empty-function
setDiskUsage: (usage: any) => {},
});
export const useModel = () => React.useContext(ModelContext);
const ModelProvider = ({
children,
socket,
}: {
children: React.ReactNode;
socket: Socket;
}) => {
const [selectedModel, setSelectedModel] = useState("");
const [modelLoading, setModelLoading] = useState(false);
const [modelLoaded, setModelLoaded] = useState(false);
const [ramUsage, setRamUsage] = useState({
totalRAM: 0,
freeRAM: 0,
usedRAM: 0,
});
const [diskUsage, setDiskUsage] = useState({
totalDisk: 0,
freeDisk: 0,
});
useEffect(() => {
socket.on("selected_model", (model) => {
setSelectedModel(model);
});
}, []);
useEffect(() => {
socket.on("model_loading", (loading) => {
setModelLoading(loading);
});
socket.on("model_loaded", (loaded) => {
setModelLoaded(loaded);
});
}, []);
useEffect(() => {
socket.on("ram_usage", (usage) => {
setRamUsage(usage);
});
socket.on("disk_usage", (usage) => {
setDiskUsage(usage);
});
}, []);
return (
<ModelContext.Provider
value={{
selectedModel,
modelLoading,
modelLoaded,
ramUsage,
diskUsage,
setSelectedModel,
setModelLoading,
setModelLoaded,
setRamUsage,
setDiskUsage,
}}
>
{children}
</ModelContext.Provider>
);
};
export default ModelProvider;

View File

@ -0,0 +1,22 @@
function fixTextFormatting(text: string) {
// Remove spaces before and after dashes
text = text.replace(/\s+-\s+/g, "-");
// Remove spaces before and after commas
text = text.replace(/\s*,\s*/g, ",");
// Add spaces after periods if they are missing
text = text.replace(/([^.\s])\.([^.\s])/g, "$1. $2");
// Remove extra spaces
text = text.replace(/\s+/g, " ");
// Capitalize the first letter of the sentence
text = text.replace(/^[a-z]/, function (match) {
return match.toUpperCase();
});
return text;
}
export default fixTextFormatting;

View File

@ -1,15 +1,15 @@
import { useEffect, useRef, useState } from "react";
import io from "socket.io-client";
import { v4 as uuidv4 } from "uuid";
import InitialLoader from "../components/InitialLoader";
import Input from "../components/Input";
import Messages from "../components/Messages";
import { useMessageFetching } from "../context/MessageFetch";
import { MessageType } from "../types/types";
import { Socket } from "socket.io-client";
import { useModel } from "../context/ModelSelection";
export default function Main({ socket }: { socket: Socket }) {
const socket = io("http://localhost:8889");
export default function Main() {
const [input, setInput] = useState<string>("");
const [response, setResponse] = useState("");
const {
@ -23,7 +23,6 @@ export default function Main({ socket }: { socket: Socket }) {
} = useMessageFetching();
const inputRef = useRef<HTMLDivElement>(null);
const { selectedModel } = useModel();
function addMessage(msg: MessageType) {
if (msg.user) {
@ -46,9 +45,18 @@ export default function Main({ socket }: { socket: Socket }) {
}, [inputRef.current, disableinput]);
useEffect(() => {
socket.on("response", (result) => {
setResponse((prevResponse) => prevResponse + result);
socket.on("response", (data) => {
const result = data.output;
const justText = result.replace(
// eslint-disable-next-line no-control-regex
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
""
);
if (messages.length > 0) {
setResponse((prevResponse) => prevResponse + justText);
if (messageFetching) {
setFetchedMessages(response);
@ -59,10 +67,18 @@ export default function Main({ socket }: { socket: Socket }) {
return [...prev];
});
}
// console.log(JSON.stringify(response));
}
// if no data is returned console log the message complete
if (result === "\n>") {
console.log("message complete");
}
});
socket.on("chatend", () => {
socket.emit("chatstart");
setDisableinput(false);
setMessageFetching(false);
});
@ -71,13 +87,7 @@ export default function Main({ socket }: { socket: Socket }) {
socket.off("response");
socket.off("chatend");
};
}, [
messages,
response,
messageFetching,
setFetchedMessages,
setDisableinput,
]);
}, [messages]);
const askQuestion = (message: string) => {
const senderID = uuidv4();
@ -89,7 +99,6 @@ export default function Main({ socket }: { socket: Socket }) {
message: message,
user: true,
id: senderID,
model: selectedModel,
});
socket.emit("message", message);
@ -98,7 +107,7 @@ export default function Main({ socket }: { socket: Socket }) {
message: "",
user: false,
id: replyID,
model: selectedModel,
replyId: senderID,
});
};
@ -109,7 +118,7 @@ export default function Main({ socket }: { socket: Socket }) {
style={{
width: "100%",
margin: "auto",
// height: "100vh",
height: "100vh",
position: "relative",
overflowY: "hidden",
}}

View File

@ -1,6 +1,7 @@
export type MessageType = {
message: string;
user: boolean;
user?: boolean;
image?: any;
id: string;
model: string;
replyId?: string;
};

Binary file not shown.

View File

@ -5,16 +5,10 @@ body {
max-width: 60rem;
}
@font-face {
font-family: "Roboto";
src: url(Roboto-Regular.ttf);
}
* {
margin: 0;
padding: 0;
font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Helvetica, Arial, sans-serif;
font-family: "Questrial", sans-serif;
line-break: auto;
}
@ -94,28 +88,3 @@ body {
width: 98% !important;
}
}
.loader {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
opacity: 1;
transition: opacity 0.3s ease-in-out;
}
.loader.hidden {
opacity: 0;
}
.spinner {
border: 5px solid rgba(0, 0, 0, 0.1);
border-top-color: #fff;
border-radius: 50%;
animation: spin 1s ease-in-out infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}

View File

@ -1,14 +1,9 @@
import axios from "axios";
import { spawn } from "child_process";
import cors from "cors";
import checkDiskSpace from "check-disk-space";
import { BrowserWindow, app, autoUpdater, dialog, shell } from "electron";
import { app, BrowserWindow } from "electron";
import express from "express";
import fs from "fs";
import http from "http";
import os from "os";
import { Server } from "socket.io";
import update from "update-electron-app";
const expressapp = express();
const server = http.createServer(expressapp);
@ -19,422 +14,122 @@ const io = new Server(server, {
},
});
const usePackaged =
process.env.npm_lifecycle_event === "start:prod" ? true : false;
const homeDir = app.getPath("home");
const DEFAULT_MODEL_LOCATION = homeDir + "/FreedomGPT";
declare const MAIN_WINDOW_WEBPACK_ENTRY: string;
declare const MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY: string;
process.env["ELECTRON_DISABLE_SECURITY_WARNINGS"] = "true";
if (require("electron-squirrel-startup")) app.quit();
expressapp.use(cors());
const EXPRESSPORT = 8889;
const CHAT_APP_LOCATION = app.getAppPath() + "/src/models/chat";
const MODEL_LOCATION = app.getAppPath() + "/src/models/ggml-alpaca-7b-q4.bin";
let program: import("child_process").ChildProcessWithoutNullStreams = null;
const deviceisWindows = process.platform === "win32";
// const CHAT_APP_LOCATION = app.isPackaged
// ? process.resourcesPath + "/models/llama/main"
// : deviceisWindows
// ? process.cwd() + "/llama.cpp/build/bin/Release/main"
// : process.cwd() + "/llama.cpp/main";
const isDev: boolean = app.isPackaged ? false : true;
const CHAT_APP_LOCATION = deviceisWindows
? isDev
? usePackaged
? process.cwd() + "/src/model/windows/main"
: process.cwd() + "/llama.cpp/build/bin/Release/main"
: process.resourcesPath + "/models/llama/main"
: isDev
? usePackaged
? process.cwd() + "/src/model/mac/main"
: process.cwd() + "/llama.cpp/main"
: process.resourcesPath + "/models/llama/main";
/* Make sure to use the actual path to your app, not the relative path ( )
Donot use ../ or ./
*/
io.on("connection", (socket) => {
const totalRAM = os.totalmem() / 1024 ** 3;
const freeRAM = os.freemem() / 1024 ** 3;
const usedRAM = totalRAM - freeRAM;
console.log("A user connecteddd");
socket.emit("ram_usage", {
totalRAM: totalRAM.toFixed(2),
freeRAM: freeRAM.toFixed(2),
usedRAM: usedRAM.toFixed(2),
});
let program = spawn(CHAT_APP_LOCATION, ["-m", MODEL_LOCATION]);
socket.on("open_github", () => {
shell.openExternal("https://github.com/ohmplatform/FreedomGPT", {
activate: true,
});
});
socket.on("open_discord", () => {
shell.openExternal("https://discord.com/invite/h77wvJS4ga", {
activate: true,
});
});
// diskusage.check("/", (err, info) => {
// if (err) {
// console.error(err);
// return;
// }
// socket.emit("disk_usage", {
// totalDisk: (info.total / 1024 ** 3).toFixed(2),
// freeDisk: (info.free / 1024 ** 3).toFixed(2),
// });
// });
if (deviceisWindows) {
checkDiskSpace("C:/")
.then((diskSpace) => {
socket.emit("disk_usage", {
totalDisk: (diskSpace.size / 1024 ** 3).toFixed(2),
freeDisk: (diskSpace.free / 1024 ** 3).toFixed(2),
});
})
.catch((err) => {
console.error(err);
});
} else {
checkDiskSpace("/")
.then((diskSpace) => {
socket.emit("disk_usage", {
totalDisk: (diskSpace.size / 1024 ** 3).toFixed(2),
freeDisk: (diskSpace.free / 1024 ** 3).toFixed(2),
});
})
.catch((err) => {
console.error(err);
});
}
// checkDiskSpace("/")
// .then((diskSpace) => {
// socket.emit("disk_usage", {
// totalDisk: (diskSpace.size / 1024 ** 3).toFixed(2),
// freeDisk: (diskSpace.free / 1024 ** 3).toFixed(2),
// });
// })
// .catch((err) => {
// console.error(err);
// });
let selectedModel: string;
socket.on("delete_model", (data) => {
fs.unlink(data, (err) => {
if (err) {
console.error(err);
return;
}
});
});
socket.emit("selected_model", selectedModel);
socket.on("choose_model", (data) => {
selectedModel = data.model;
const options = {
defaultPath: DEFAULT_MODEL_LOCATION,
buttonLabel: "Choose",
filters: [
{
name: "Model",
extensions: ["bin"],
},
],
};
dialog.showOpenDialog(options).then((result) => {
if (!result.canceled) {
const filePath = result.filePaths[0];
console.log(filePath);
socket.emit("download_complete", {
downloadPath: filePath,
selectedModel,
});
}
});
});
socket.on("download_model", (data) => {
const selectedModel = data.model;
const fileName = data.downloadURL.split("/").pop();
const filePath = DEFAULT_MODEL_LOCATION + "/" + fileName;
if (fs.existsSync(filePath)) {
fs.rmSync(filePath);
}
const options = {
defaultPath: filePath,
buttonLabel: "Download",
};
let downloadPath: string = null;
let writer: fs.WriteStream = null;
let lastPercentage = 0;
const cancelDownload = () => {
writer.close();
fs.unlinkSync(downloadPath);
socket.emit("download_canceled");
};
dialog.showSaveDialog(options).then((result) => {
if (result.canceled) {
console.log("Cancelled download");
}
if (!result.canceled) {
downloadPath = result.filePath;
writer = fs.createWriteStream(downloadPath);
axios({
url: data.downloadURL,
method: "GET",
responseType: "stream",
})
.then((response) => {
const contentLength = response.headers["content-length"];
response.data.pipe(writer);
socket.emit("download_started", {
contentLength,
selectedModel,
});
let downloadedBytes = 0;
response.data.on("data", (chunk: any) => {
downloadedBytes += chunk.length;
const percentage = Math.floor(
(downloadedBytes / contentLength) * 100
);
if (percentage > lastPercentage) {
lastPercentage = percentage;
socket.emit("download_progress", {
percentage,
downloadedBytes,
contentLength,
selectedModel,
});
}
});
writer.on("finish", () => {
console.log(`\nModel downloaded to ${downloadPath}`);
socket.emit("download_complete", {
downloadPath,
selectedModel,
});
});
writer.on("error", (err) => {
console.error("Failed to download model:", err);
});
})
.catch((error) => {
console.error("Failed to download model:", error);
if (fs.existsSync(downloadPath)) {
fs.unlinkSync(downloadPath);
}
socket.emit("download_model", data);
});
}
});
socket.on("cancel_download", () => {
cancelDownload();
});
});
socket.on("select_model", (data) => {
selectedModel = data.model;
if (program) {
program.kill();
}
const modelConfig: { [key: string]: string[] } = {
"alpaca-7B-fast": ["-m", data.FILEPATH, "-ins"],
"alpaca-7B-full": [
"-m",
data.FILEPATH,
"--ctx_size",
"2048",
"-n",
"-1",
"-ins",
"-b",
"256",
"--top_k",
"10000",
"--temp",
"0.2",
"--repeat_penalty",
"1",
"-t",
"7",
],
"llama-7B-fast": ["-m", data.FILEPATH, "-ins"],
"llama-7B-full": [
"-m",
data.FILEPATH,
"-ins",
"--ctx_size",
"2048",
"-n",
"-1",
"-ins",
"-b",
"256",
"--top_k",
"10000",
"--temp",
"0.2",
"--repeat_penalty",
"1",
"-t",
"7",
],
};
program = spawn(CHAT_APP_LOCATION, modelConfig[selectedModel]);
program.on("error", (err) => {
console.error("Failed to start child process:", err);
});
program.stderr.on("data", (data: Buffer) => {
const dat = data.toString("utf8");
if (dat.includes("end your input in '\\'.")) {
socket.emit("selected_model", selectedModel);
socket.emit("model_loaded", true);
}
});
program.on("exit", (code, signal) => {
console.log(
`Child process exited with code ${code} and signal ${signal}`
);
});
program.stdout.on("data", (data: Buffer) => {
let output = data.toString("utf8");
let closing = "";
if (output.includes(">")) {
closing = closing.concat(">");
}
output = output.replace(">", "");
socket.emit("response", output);
if (closing.includes(">")) {
socket.emit("chatend");
closing = "";
}
});
program.on("spawn", () => {
console.log("spawned");
socket.emit("model_loading", true);
socket.emit("model_loaded", false);
});
socket.on("chatstart", () => {
program = spawn(CHAT_APP_LOCATION, ["-m", MODEL_LOCATION]);
console.log("S2", program.pid);
});
socket.on("stopResponding", () => {
if (program) {
program.kill("SIGINT");
}
console.log("E1", program.pid);
program.kill();
program = null;
socket.emit("chatend");
});
socket.on("message", (message) => {
if (program && program.stdin) {
program.stdin.write(message + "\n");
}
console.log("M1", program.pid);
program.stdin.write(message + "\n");
console.log("M2", program.pid);
program.stdout.on("data", (data) => {
// const abc = data.toString("utf8");
let output = data.toString("utf8");
// console.log(output);
output = output.replace(">", "");
const response = { result: "success", output: output };
socket.emit("response", response);
if (output.includes("message__end")) {
console.log("done");
console.log("E1", program.pid);
program.kill();
program = null;
socket.emit("chatend");
}
});
});
socket.on("disconnect", (reason) => {
if (program) {
program.kill();
program = null;
}
console.log(`Socket disconnected: ${reason}`);
socket.on("disconnect", () => {
console.log("A user disconnected");
program.kill();
program = null;
});
// } else {
// const response = { result: "error", output: "Only one user allowed" };
// socket.emit("response", response);
// }
});
server.listen(process.env.PORT || EXPRESSPORT, () => {
console.log(`Server listening on port ${EXPRESSPORT}`);
});
server.listen(EXPRESSPORT, () =>
console.log(`Express Server running on port ${EXPRESSPORT}`)
);
const createWindow = (): void => {
// Create the browser window.
const mainWindow = new BrowserWindow({
height: 1080,
width: 1080,
webPreferences: {
preload: MAIN_WINDOW_PRELOAD_WEBPACK_ENTRY,
devTools: true,
},
});
// and load the index.html of the app.
mainWindow.loadURL(MAIN_WINDOW_WEBPACK_ENTRY);
// if (!app.isPackaged) {
// mainWindow.webContents.openDevTools();
// }
mainWindow.once("ready-to-show", () => {
update();
autoUpdater.on("update-available", () => {
console.log("Update available");
});
autoUpdater.on("update-downloaded", () => {
console.log("Update downloaded");
autoUpdater.quitAndInstall();
app.quit();
});
autoUpdater.on("update-not-available", () => {
console.log("Update not available");
});
autoUpdater.on("error", (err) => {
console.log("Error in auto-updater. " + err);
});
autoUpdater.on("checking-for-update", () => {
console.log("Checking for update...");
});
});
};
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on("ready", () => {
createWindow();
});
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on("window-all-closed", () => {
app.quit();
if (process.platform !== "darwin") {
app.quit();
}
});
// app.on("browser-window-focus", function () {
// globalShortcut.register("CommandOrControl+R", () => {
// console.log("CommandOrControl+R is pressed: Shortcut Disabled");
// });
// });
// app.on("browser-window-blur", function () {
// globalShortcut.unregister("CommandOrControl+R");
// });
app.on("activate", () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and import them here.

Binary file not shown.

Binary file not shown.

View File

@ -1,59 +0,0 @@
export type Model = {
config: {
FILEPATH: string | null;
model: string;
downloadURL: string;
requiredRAM: number;
fileSize: number;
id: string;
};
};
const models: Model[] = [
{
config: {
FILEPATH: localStorage.getItem("alpaca-7B") || null,
model: "alpaca-7B-fast",
downloadURL:
"https://huggingface.co/bhattaraijay05/Alpaca-7B/resolve/main/ggml-alpaca-7b-q4.bin",
requiredRAM: 6,
fileSize: 4,
id: "alpaca-7B-fast",
},
},
{
config: {
FILEPATH: localStorage.getItem("alpaca-7B") || null,
model: "alpaca-7B-full",
downloadURL:
"https://huggingface.co/bhattaraijay05/Alpaca-7B/resolve/main/ggml-alpaca-7b-q4.bin",
requiredRAM: 6,
fileSize: 4,
id: "alpaca-7B-full",
},
},
{
config: {
FILEPATH: localStorage.getItem("llama-7B") || null,
model: "llama-7B-fast",
downloadURL:
"https://huggingface.co/bhattaraijay05/llama-7B/resolve/main/ggml-model-q4_0.bin",
requiredRAM: 6,
fileSize: 4,
id: "llama-7B-fast",
},
},
{
config: {
FILEPATH: localStorage.getItem("llama-7B") || null,
model: "llama-7B-full",
downloadURL:
"https://huggingface.co/bhattaraijay05/llama-7B/resolve/main/ggml-model-q4_0.bin",
requiredRAM: 6,
fileSize: 4,
id: "llama-7B-full",
},
},
];
export default models;

BIN
src/models/chat Executable file

Binary file not shown.

View File

@ -28,4 +28,14 @@ export const rules: Required<ModuleOptions>["rules"] = [
},
},
},
{
test: /\.jsx?$/,
use: {
loader: "babel-loader",
options: {
exclude: /node_modules/,
presets: ["@babel/preset-react"],
},
},
},
];

1265
yarn.lock

File diff suppressed because it is too large Load Diff