Fly Deployment

This commit is contained in:
Vineeth Voruganti 2023-09-11 12:46:36 -04:00
parent 320cb47c90
commit 44a69e06fb
4 changed files with 103 additions and 39 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
fly.toml

34
Dockerfile Normal file
View File

@ -0,0 +1,34 @@
# https://pythonspeed.com/articles/base-image-python-docker-images/
# https://testdriven.io/blog/docker-best-practices/
FROM python:3.10-slim-bullseye
WORKDIR /app
# https://stackoverflow.com/questions/53835198/integrating-python-poetry-with-docker
ENV PYTHONFAULTHANDLER=1 \
PYTHONUNBUFFERED=1 \
PYTHONHASHSEED=random \
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
POETRY_VERSION=1.4.1
RUN pip install "poetry==$POETRY_VERSION"
# Copy only requirements to cache them in docker layer
WORKDIR /app
COPY poetry.lock pyproject.toml /app/
# Project initialization:
RUN poetry config virtualenvs.create false \
&& poetry install --no-root --no-interaction --no-ansi --without dev
WORKDIR /app
RUN addgroup --system app && adduser --system --group app
USER app
COPY . .
# https://stackoverflow.com/questions/29663459/python-app-does-not-print-anything-when-running-detached-in-docker
CMD ["python", "-m", "uvicorn", "main:app", "--port", "80"]

View File

@ -248,57 +248,60 @@ class BloomChain:
@classmethod
async def stream(cls, cache: Conversation, inp: str ):
# VoE has to happen first. If there's user prediction history, derive and store fact(s)
if cache.messages('user_prediction_thought_revision'):
user_prediction_thought_revision = cache.messages('user_prediction_thought_revision')[-1].content
try:
if cache.messages('user_prediction_thought_revision'):
user_prediction_thought_revision = cache.messages('user_prediction_thought_revision')[-1].content
voe_thought = await cls.think_violation_of_expectation(cache, inp, user_prediction_thought_revision)
voe_facts = await cls.violation_of_expectation(cache, inp, user_prediction_thought_revision, voe_thought)
voe_thought = await cls.think_violation_of_expectation(cache, inp, user_prediction_thought_revision)
voe_facts = await cls.violation_of_expectation(cache, inp, user_prediction_thought_revision, voe_thought)
if not voe_facts or voe_facts[0] == "None":
pass
else:
await cls.check_voe_list(cache, voe_facts)
if not voe_facts or voe_facts[0] == "None":
pass
else:
await cls.check_voe_list(cache, voe_facts)
print("=========================================")
print("Finished Init")
print("=========================================")
print("=========================================")
print("Finished Init")
print("=========================================")
thought_iterator = cls.think(cache, inp)
thought = ""
async for item in thought_iterator:
# escape ❀ if present
item = item.replace("❀", "🌸")
thought += item
yield item
yield "❀"
thought_iterator = cls.think(cache, inp)
thought = ""
async for item in thought_iterator:
# escape ❀ if present
item = item.replace("❀", "🌸")
thought += item
yield item
yield "❀"
print("=========================================")
print("Finished Thought")
print("=========================================")
print("=========================================")
print("Finished Thought")
print("=========================================")
thought_revision_iterator = cls.revise_thought(cache, inp, thought)
thought_revision = await thought_revision_iterator()
thought_revision_iterator = cls.revise_thought(cache, inp, thought)
thought_revision = await thought_revision_iterator()
response_iterator = cls.respond(cache, thought_revision, inp)
#response = ""
response_iterator = cls.respond(cache, thought_revision, inp)
#response = ""
async for item in response_iterator:
# if "❀" in item:
item = item.replace("❀", "🌸")
#response += item
yield item
async for item in response_iterator:
# if "❀" in item:
item = item.replace("❀", "🌸")
#response += item
yield item
print("=========================================")
print("Finished Response")
print("=========================================")
print("=========================================")
print("Finished Response")
print("=========================================")
user_prediction_thought = await cls.think_user_prediction(cache, inp)
user_prediction_thought_revision = await cls.revise_user_prediction_thought(cache, user_prediction_thought, inp)
user_prediction_thought = await cls.think_user_prediction(cache, inp)
user_prediction_thought_revision = await cls.revise_user_prediction_thought(cache, user_prediction_thought, inp)
print("=========================================")
print("Finished User Prediction")
print("=========================================")
print("=========================================")
print("Finished User Prediction")
print("=========================================")
finally:
yield "TERMINATED SEQUENCE"

View File

@ -0,0 +1,26 @@
# fly.toml app configuration file generated for honcho on 2023-09-11T10:58:33-04:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#
app = "honcho"
primary_region = "bos"
kill_signal = "SIGINT"
kill_timeout = "5s"
[experimental]
auto_rollback = true
[processes]
api = "python -m uvicorn main:app --host 0.0.0.0 --port 8000"
[http_service]
internal_port = 8000
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["api"]
[http_service.concurrency]
type = "requests"
soft_limit = 200
hard_limit = 250