-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Proof of concept TCP server mode #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
90175ee
Move main.cpp to run.cpp
tarruda d7d53b8
Add main.cpp back and invoke "run" from it
tarruda b7f1fa6
Move llama_context setup + perplexity back to main.cpp
tarruda bf44faa
Remove direct access to std streams from "run"
tarruda 3a0dcb3
Implement server mode.
tarruda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env bash | ||
|
||
PORT=${PORT:-8080} | ||
PROMPT="${PROMPT:-"Transcript of a dialog, where the User interacts with an Assistant named Bob. Bob is helpful, kind, honest, good at writing, and never fails to answer the User's requests immediately and with precision. | ||
|
||
User:Hello, Bob. | ||
Bob:Hello. How may I help you today? | ||
User:Please tell me the largest city in Europe. | ||
Bob:Sure. The largest city in Europe is Moscow, the capital of Russia. | ||
User:"}" | ||
RPROMPT="${RPROMPT:-"User:"}" | ||
N_PREDICT="${N_PREDICT:-"4096"}" | ||
REPEAT_PENALTY="${REPEAT_PENALTY:-"1.0"}" | ||
N_THREADS="${N_THREADS:-"4"}" | ||
|
||
# Open connection to the chat server | ||
exec 3<>/dev/tcp/127.0.0.1/${PORT} | ||
|
||
# Pass the arguments. The protocol is really simple: | ||
# 1. Pass the number of arguments followed by a linefeed | ||
# 2. Pass the arguments, with each being followed by "0" | ||
( | ||
echo -en "12\n" | ||
echo -en "-t\x00" | ||
echo -en "$N_THREADS\x00" | ||
echo -en "-n\x00" | ||
echo -en "$N_PREDICT\x00" | ||
echo -en "--repeat_penalty\x00" | ||
echo -en "$REPEAT_PENALTY\x00" | ||
echo -en "--color\x00" | ||
echo -en "-i\x00" | ||
echo -en "-r\x00" | ||
echo -en "$RPROMPT\x00" | ||
echo -en "-p\x00" | ||
echo -en "$PROMPT\x00" | ||
) >&3 | ||
|
||
trap exit TERM | ||
|
||
# When we have passed the arguments, start printing socket data to the screen. | ||
# This is done in a background job because we also want to send data when | ||
# running in interactive mode. | ||
cat <&3 && echo "(disconnected, press \"enter\" twice to exit)" & | ||
cat >&3 | ||
wait |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
PORT=${PORT:-8080} | ||
MODEL=${MODEL:-models/7B/ggml-model-q4_0.bin} | ||
|
||
./main -l ${PORT} -m $MODEL |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.