-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge various work from Orchid Labs master branch.
- Loading branch information
Showing
13 changed files
with
381 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Miscellaneous | ||
*.class | ||
*.log | ||
*.pyc | ||
*.swp | ||
.DS_Store | ||
.atom/ | ||
.buildlog/ | ||
.history | ||
.svn/ | ||
.gitignore | ||
__pycache__ | ||
|
||
# IntelliJ related | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea/ | ||
|
||
*~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
FROM python:3.8.5 | ||
|
||
ENV TINI_VERSION="v0.19.0" | ||
|
||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini | ||
RUN chmod +x /tini | ||
|
||
RUN pip install -U \ | ||
pip \ | ||
setuptools \ | ||
wheel | ||
|
||
WORKDIR /project | ||
|
||
COPY requirements.txt ./ | ||
COPY run.sh / | ||
RUN chmod +x /run.sh | ||
COPY *.py ./ | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
COPY . . | ||
|
||
RUN useradd -m -r gai && chown gai /project | ||
|
||
USER gai | ||
|
||
ENV ORCHID_GENAI_ADDR=127.0.0.1 | ||
ENV ORCHID_GENAI_PORT=8001 | ||
ENV ORCHID_GENAI_RECIPIENT_KEY="" | ||
ENV ORCHID_GENAI_LLM_PARAMS="{\"temperature\": 0.7, \"top_p\": 1, \"max_tokens\": 3000, \"stream\": false, \"safe_prompt\": false, \"random_seed\": null}" | ||
ENV ORCHID_GENAI_LLM_MODEL="Mistral-7B-Instruct-v0.2/" | ||
ENV ORCHID_GENAI_LLM_URL="http://localhost:8000/v1/chat/completions/" | ||
|
||
ENTRYPOINT ["/tini", "--", "/run.sh"] | ||
EXPOSE 8001 8001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ethereum | ||
web3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
while true | ||
do | ||
python server.py; | ||
sleep 1; | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import galois | ||
import numpy as np | ||
from galois import FieldArray | ||
from numpy._typing import NDArray | ||
|
||
# The largest prime that fits in 256 bits / 32 bytes | ||
p = 2 ** 256 - 189 | ||
|
||
# For very large primes galois can take a long time to infer the primitive element; Specifying it is much faster. | ||
primitive_element = 2 | ||
|
||
# The field scalars are read at the rounded down byte size (to guarantee that they remain less than p). | ||
FIELD_SAFE_SCALAR_SIZE_BYTES: int = 31 | ||
|
||
# The stored size of the element is the rounded up byte size. | ||
FIELD_ELEMENT_SIZE_BYTES: int = 32 | ||
|
||
|
||
# Initialize the Galois field object for the order of the field used in the BLS12-381 curve. | ||
def get_field(): | ||
# Order / characteristic is q and degree is 1 for a prime field | ||
return galois.GF(p, 1, primitive_element=primitive_element, verify=False) | ||
|
||
|
||
def symbol_to_bytes( | ||
symbol: FieldArray, | ||
element_size: int, | ||
) -> bytes: | ||
return int(symbol).to_bytes(element_size, byteorder='big') | ||
|
||
|
||
# Take the list or array of GF symbols and render them to a list of byte strings, each of length element_size. | ||
def symbols_to_bytes_list( | ||
symbols: list[FieldArray] | NDArray[FieldArray], | ||
element_size: int, | ||
) -> list[bytes]: | ||
return [symbol_to_bytes(el, element_size) for el in symbols] | ||
|
||
|
||
# Take the list or array of GF symbols and render them to a flattened byte string of | ||
# length len(symbols) * element_size. | ||
def symbols_to_bytes( | ||
symbols: list[FieldArray] | NDArray[FieldArray], | ||
element_size: int, | ||
) -> bytes: | ||
return b''.join(symbols_to_bytes_list(symbols, element_size)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.