Skip to content

Commit 0215a54

Browse files
committed
Shuffle AI rebuild attempt
1 parent b3c7fb2 commit 0215a54

File tree

4 files changed

+119
-23
lines changed

4 files changed

+119
-23
lines changed

shuffle-ai/1.0.0/Dockerfile

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
1-
# Base our app image off of the WALKOFF App SDK image
2-
FROM frikky/shuffle:app_sdk as base
3-
4-
# We're going to stage away all of the bloat from the build tools so lets create a builder stage
5-
FROM base as builder
1+
FROM python:3.10-slim
62

73
# Install all alpine build tools needed for our pip installs
8-
RUN apk --no-cache add --update alpine-sdk libffi libffi-dev musl-dev openssl-dev git poppler-utils
4+
RUN apt update
5+
RUN apt install -y clang g++ make automake autoconf libtool cmake
96

107
# Install all of our pip packages in a single directory that we can copy to our base image later
118
RUN mkdir /install
129
WORKDIR /install
1310

1411
# Switch back to our base image and copy in all of our built packages and source code
15-
FROM base
16-
COPY --from=builder /install /usr/local
12+
#COPY --from=builder /install /usr/local
1713
COPY src /app
1814
COPY requirements.txt /requirements.txt
1915
RUN python3 -m pip install -r /requirements.txt
2016

2117
# Install any binary dependencies needed in our final image
2218
# RUN apk --no-cache add --update my_binary_dependency
23-
RUN apk --no-cache add jq git curl
19+
#RUN apk --no-cache add jq git curl
20+
RUN apt install -y jq git curl
2421

2522
ENV SHELL=/bin/bash
2623

@@ -32,23 +29,45 @@ ENV TESSDATA_PREFIX=/usr/local/share/tessdata
3229

3330
# Dev tools
3431
WORKDIR /tmp
35-
RUN apk update
36-
RUN apk upgrade
37-
RUN apk add file openssl openssl-dev bash tini leptonica-dev openjpeg-dev tiff-dev libpng-dev zlib-dev libgcc mupdf-dev jbig2dec-dev
38-
RUN apk add freetype-dev openblas-dev ffmpeg-dev linux-headers aspell-dev aspell-en # enchant-dev jasper-dev
39-
RUN apk add --virtual .dev-deps git clang clang-dev g++ make automake autoconf libtool pkgconfig cmake ninja
40-
RUN apk add --virtual .dev-testing-deps -X http://dl-3.alpinelinux.org/alpine/edge/testing autoconf-archive
32+
#RUN apk update
33+
#RUN apk upgrade
34+
35+
## Install the same packages with apt as with apk, but ensure they exist in apt
36+
RUN apt install -y file openssl bash tini libpng-dev aspell-en
37+
RUN apt install -y git clang g++ make automake autoconf libtool cmake
38+
RUN apt install -y autoconf-archive wget
39+
4140
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
4241

43-
RUN apk add tesseract-ocr
44-
RUN apk add poppler-utils
42+
#RUN apk add tesseract-ocr
43+
RUN apt install -y tesseract-ocr
44+
#RUN apk add poppler-utils
45+
RUN apt install -y poppler-utils
46+
RUN apt clean && rm -rf /var/lib/apt/lists/*
4547

4648
# Install from main
4749
RUN mkdir /usr/local/share/tessdata
50+
RUN wget https://github.com/tesseract-ocr/tessdata_fast/raw/main/eng.traineddata -P /usr/local/share/tessdata
51+
4852
RUN mkdir src
4953
RUN cd src
50-
RUN wget https://github.com/tesseract-ocr/tessdata_fast/raw/main/eng.traineddata -P /usr/local/share/tessdata
54+
5155
RUN git clone --depth 1 https://github.com/tesseract-ocr/tesseract.git
56+
57+
#RUN curl -fsSL https://ollama.com/install.sh | sh
58+
# Install to /usr/local
59+
RUN wget https://ollama.com/install.sh -O /usr/local/bin/ollama-install
60+
RUN chmod +x /usr/local/bin/ollama-install
61+
RUN ls /usr/local/bin
62+
RUN sh /usr/local/bin/ollama-install
63+
64+
RUN ls -alh /usr/bin
65+
RUN which ollama
66+
67+
#RUN /usr/local/bin/ollama pull llama3.2
68+
RUN ollama serve & sleep 2 && ollama pull llama3
69+
70+
#RUN rm /usr/local/bin/ollama
5271
#RUN cd tesseract && ./autogen.sh && ./configure --build=x86_64-alpine-linux-musl --host=x86_64-alpine-linux-musl && make && make install && cd /tmp/src
5372

5473
# Finally, lets run our app!

shuffle-ai/1.0.0/api.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@ contact_info:
1111
url: https://shuffler.io
1212
1313
actions:
14-
- name: autoformat_text
14+
- name: run_llm
15+
description: "Runs a local LLM based on ollama with any of their models from https://github.com/ollama/ollama?tab=readme-ov-file#model-library"
16+
parameters:
17+
- name: question
18+
description: "The input question to the model"
19+
required: true
20+
multiline: true
21+
example: ""
22+
schema:
23+
type: string
24+
25+
- name: shuffle_cloud_inference
1526
description: Input ANY kind of data in the format you want, and the format you want it in. Default is a business-y email. Uses ShuffleGPT, which is based on OpenAI and our own model.
1627
parameters:
1728
- name: apikey

shuffle-ai/1.0.0/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
shuffle_sdk
12
pytesseract
23
pdf2image
34
pypdf2
45
requests
6+
ollama

shuffle-ai/1.0.0/src/app.py

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
import json
2-
import PyPDF2
32
import tempfile
43
import requests
5-
import pytesseract
6-
from pdf2image import convert_from_path
74

8-
from walkoff_app_sdk.app_base import AppBase
5+
try:
6+
import pytesseract
7+
except Exception as e:
8+
print("Skipping pytesseract import: %s" % e)
9+
10+
try:
11+
import PyPDF2
12+
except Exception as e:
13+
print("Skipping PyPDF2 import: %s" % e)
14+
15+
try:
16+
from pdf2image import convert_from_path
17+
except Exception as e:
18+
print("Skipping pdf2image import: %s" % e)
19+
20+
try:
21+
import ollama
22+
except Exception as e:
23+
print("Skipping ollama import: %s" % e)
24+
25+
from shuffle_sdk import AppBase
926

1027
class Tools(AppBase):
1128
__version__ = "1.0.0"
@@ -14,6 +31,53 @@ class Tools(AppBase):
1431
def __init__(self, redis, logger, console_logger=None):
1532
super().__init__(redis, logger, console_logger)
1633

34+
def run_llm(self, question, model="llama3.2"):
35+
models = []
36+
response = ollama.chat(model=model, messages=[
37+
{
38+
"role": "user", "content": question,
39+
}
40+
])
41+
42+
return response["message"]["content"]
43+
44+
def security_assistant(self):
45+
# Currently testing outside the Shuffle environment
46+
# using assistants and local LLMs
47+
48+
return "Not implemented"
49+
50+
def shuffle_cloud_inference(self, apikey, text, formatting="auto"):
51+
headers = {
52+
"Authorization": "Bearer %s" % apikey,
53+
}
54+
55+
if not formatting:
56+
formatting = "auto"
57+
58+
output_formatting= "Format the following data to be a good email that can be sent to customers. Don't make it too business sounding."
59+
if formatting != "auto":
60+
output_formatting = formatting
61+
62+
ret = requests.post(
63+
"https://shuffler.io/api/v1/conversation",
64+
json={
65+
"query": text,
66+
"formatting": output_formatting,
67+
"output_format": "formatting"
68+
},
69+
headers=headers,
70+
)
71+
72+
if ret.status_code != 200:
73+
print(ret.text)
74+
return {
75+
"success": False,
76+
"reason": "Status code for auto-formatter is not 200"
77+
}
78+
79+
return ret.text
80+
1781
def autoformat_text(self, apikey, text, formatting="auto"):
1882
headers = {
1983
"Authorization": "Bearer %s" % apikey,

0 commit comments

Comments
 (0)