Spaces:
Build error
Build error
abdulazeezoj
commited on
Commit
·
2b6f022
1
Parent(s):
3aa83d4
update dependencies
Browse files- Dockerfile +2 -2
- Pipfile +0 -4
- Pipfile.lock +1 -35
- alaroye/alaroye.py +47 -48
Dockerfile
CHANGED
@@ -4,14 +4,14 @@ FROM python:3.10.10
|
|
4 |
WORKDIR /code
|
5 |
|
6 |
# Copy Pipfile
|
7 |
-
COPY Pipfile ./
|
8 |
|
9 |
# Python PIP Upgrade & Install Dependencies
|
10 |
RUN pip install --no-cache-dir --upgrade pip \
|
11 |
&& pip install --no-cache-dir pipenv
|
12 |
|
13 |
# Install Python Dependencies
|
14 |
-
RUN pipenv install --system --deploy
|
15 |
|
16 |
# Set up a new user named "user" with user ID 1000
|
17 |
RUN useradd -m -u 1000 alaye
|
|
|
4 |
WORKDIR /code
|
5 |
|
6 |
# Copy Pipfile
|
7 |
+
COPY Pipfile Pipfile.lock ./
|
8 |
|
9 |
# Python PIP Upgrade & Install Dependencies
|
10 |
RUN pip install --no-cache-dir --upgrade pip \
|
11 |
&& pip install --no-cache-dir pipenv
|
12 |
|
13 |
# Install Python Dependencies
|
14 |
+
RUN pipenv install --system --deploy --ignore-pipfile
|
15 |
|
16 |
# Set up a new user named "user" with user ID 1000
|
17 |
RUN useradd -m -u 1000 alaye
|
Pipfile
CHANGED
@@ -4,14 +4,10 @@ verify_ssl = true
|
|
4 |
name = "pypi"
|
5 |
|
6 |
[packages]
|
7 |
-
gtts = "*"
|
8 |
-
speechrecognition = "*"
|
9 |
-
pyaudio = "*"
|
10 |
langchain = "*"
|
11 |
openai = "*"
|
12 |
gradio = "*"
|
13 |
chromadb = "*"
|
14 |
-
pydub = "*"
|
15 |
tiktoken = "*"
|
16 |
|
17 |
[dev-packages]
|
|
|
4 |
name = "pypi"
|
5 |
|
6 |
[packages]
|
|
|
|
|
|
|
7 |
langchain = "*"
|
8 |
openai = "*"
|
9 |
gradio = "*"
|
10 |
chromadb = "*"
|
|
|
11 |
tiktoken = "*"
|
12 |
|
13 |
[dev-packages]
|
Pipfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
{
|
2 |
"_meta": {
|
3 |
"hash": {
|
4 |
-
"sha256": "
|
5 |
},
|
6 |
"pipfile-spec": 6,
|
7 |
"requires": {
|
@@ -715,14 +715,6 @@
|
|
715 |
"markers": "platform_machine == 'aarch64' or (platform_machine == 'ppc64le' or (platform_machine == 'x86_64' or (platform_machine == 'amd64' or (platform_machine == 'AMD64' or (platform_machine == 'win32' or platform_machine == 'WIN32')))))",
|
716 |
"version": "==2.0.2"
|
717 |
},
|
718 |
-
"gtts": {
|
719 |
-
"hashes": [
|
720 |
-
"sha256:5314f7dedb4230889ff4773edd37e101408497e166982027b8d9582a4585eb4f",
|
721 |
-
"sha256:9132e409603f34d5023458e3e10ce2f5df55498d7a2ee781c9adbe616fbd4152"
|
722 |
-
],
|
723 |
-
"index": "pypi",
|
724 |
-
"version": "==2.3.2"
|
725 |
-
},
|
726 |
"h11": {
|
727 |
"hashes": [
|
728 |
"sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d",
|
@@ -1568,23 +1560,6 @@
|
|
1568 |
],
|
1569 |
"version": "==3.2.0"
|
1570 |
},
|
1571 |
-
"pyaudio": {
|
1572 |
-
"hashes": [
|
1573 |
-
"sha256:13915faaa780e6bbbb6d745ef0e761674fd461b1b1b3f9c1f57042a534bfc0c3",
|
1574 |
-
"sha256:1505d766ee718df6f5a18b73ac42307ba1cb4d2c0397873159254a34f67515d6",
|
1575 |
-
"sha256:26bccc81e4243d1c0ff5487e6b481de6329fcd65c79365c267cef38f363a2b56",
|
1576 |
-
"sha256:48e29537ea22ae2ae323eebe297bfb2683831cee4f20d96964e131f65ab2161d",
|
1577 |
-
"sha256:59cc3cc5211b729c7854e3989058a145872cc58b1a7b46c6d4d88448a343d890",
|
1578 |
-
"sha256:87137cfd0ef8608a2a383be3f6996f59505e322dab9d16531f14cf542fa294f1",
|
1579 |
-
"sha256:910ef09225cce227adbba92622d4a3e3c8375117f7dd64039f287d9ffc0e02a1",
|
1580 |
-
"sha256:c6b302b048c054b7463936d8ba884b73877dc47012f3c94665dba92dd658ae04",
|
1581 |
-
"sha256:d294e3f85b2238649b1ff49ce3412459a8a312569975a89d14646536362d7576",
|
1582 |
-
"sha256:eb128e4a6ea9b98d9a31f33c44978885af27dbe8ae53d665f8790cbfe045517e",
|
1583 |
-
"sha256:ff7f5e44ef51fe61da1e09c6f632f0b5808198edd61b363855cc7dd03bf4a8ac"
|
1584 |
-
],
|
1585 |
-
"index": "pypi",
|
1586 |
-
"version": "==0.2.13"
|
1587 |
-
},
|
1588 |
"pydantic": {
|
1589 |
"hashes": [
|
1590 |
"sha256:07293ab08e7b4d3c9d7de4949a0ea571f11e4557d19ea24dd3ae0c524c0c334d",
|
@@ -1632,7 +1607,6 @@
|
|
1632 |
"sha256:65617e33033874b59d87db603aa1ed450633288aefead953b30bded59cb599a6",
|
1633 |
"sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"
|
1634 |
],
|
1635 |
-
"index": "pypi",
|
1636 |
"version": "==0.25.1"
|
1637 |
},
|
1638 |
"pygments": {
|
@@ -1886,14 +1860,6 @@
|
|
1886 |
"markers": "python_version >= '3.7'",
|
1887 |
"version": "==1.3.0"
|
1888 |
},
|
1889 |
-
"speechrecognition": {
|
1890 |
-
"hashes": [
|
1891 |
-
"sha256:14131155e8a8ba00ead1b7b9b1a2fa71c845e4db5f9a5f66a33a1bd6c55c6c35",
|
1892 |
-
"sha256:7ae9966887d9909ce3e5a0c27ecc3eacfca16fd0c0829f77f552919418e86306"
|
1893 |
-
],
|
1894 |
-
"index": "pypi",
|
1895 |
-
"version": "==3.10.0"
|
1896 |
-
},
|
1897 |
"sqlalchemy": {
|
1898 |
"hashes": [
|
1899 |
"sha256:0db6734cb5644c55d0262a813b764c6e2cda1e66e939a488b3d6298cdc7344c2",
|
|
|
1 |
{
|
2 |
"_meta": {
|
3 |
"hash": {
|
4 |
+
"sha256": "13faed2031f024c5c36c5227343c2e72f70f9d9577e9d3bd400b2d5ef3a78359"
|
5 |
},
|
6 |
"pipfile-spec": 6,
|
7 |
"requires": {
|
|
|
715 |
"markers": "platform_machine == 'aarch64' or (platform_machine == 'ppc64le' or (platform_machine == 'x86_64' or (platform_machine == 'amd64' or (platform_machine == 'AMD64' or (platform_machine == 'win32' or platform_machine == 'WIN32')))))",
|
716 |
"version": "==2.0.2"
|
717 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
718 |
"h11": {
|
719 |
"hashes": [
|
720 |
"sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d",
|
|
|
1560 |
],
|
1561 |
"version": "==3.2.0"
|
1562 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1563 |
"pydantic": {
|
1564 |
"hashes": [
|
1565 |
"sha256:07293ab08e7b4d3c9d7de4949a0ea571f11e4557d19ea24dd3ae0c524c0c334d",
|
|
|
1607 |
"sha256:65617e33033874b59d87db603aa1ed450633288aefead953b30bded59cb599a6",
|
1608 |
"sha256:980a33ce9949cab2a569606b65674d748ecbca4f0796887fd6f46173a7b0d30f"
|
1609 |
],
|
|
|
1610 |
"version": "==0.25.1"
|
1611 |
},
|
1612 |
"pygments": {
|
|
|
1860 |
"markers": "python_version >= '3.7'",
|
1861 |
"version": "==1.3.0"
|
1862 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1863 |
"sqlalchemy": {
|
1864 |
"hashes": [
|
1865 |
"sha256:0db6734cb5644c55d0262a813b764c6e2cda1e66e939a488b3d6298cdc7344c2",
|
alaroye/alaroye.py
CHANGED
@@ -5,10 +5,10 @@ import pathlib
|
|
5 |
from typing import Any, Dict, List
|
6 |
|
7 |
import gradio as gr
|
8 |
-
from gtts import gTTS
|
9 |
-
from pydub import AudioSegment
|
10 |
-
from pydub.playback import play
|
11 |
-
from io import BytesIO
|
12 |
from dotenv import find_dotenv, load_dotenv
|
13 |
from langchain.chains import RetrievalQA
|
14 |
from langchain.chains.retrieval_qa.base import BaseRetrievalQA
|
@@ -16,11 +16,10 @@ from langchain.docstore.document import Document
|
|
16 |
from langchain.document_loaders import DirectoryLoader, TextLoader
|
17 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
18 |
from langchain.llms import OpenAI
|
19 |
-
from langchain.memory import ConversationBufferWindowMemory
|
20 |
from langchain.prompts import PromptTemplate
|
21 |
from langchain.text_splitter import CharacterTextSplitter
|
22 |
from langchain.vectorstores import Chroma
|
23 |
-
import speech_recognition as sr
|
24 |
|
25 |
|
26 |
# Load environment variables
|
@@ -45,7 +44,7 @@ class Alaroye:
|
|
45 |
self.embeddings = OpenAIEmbeddings() # type: ignore
|
46 |
self.llm = OpenAI(temperature=0.1) # type: ignore
|
47 |
self.vector_store: Chroma | None = None
|
48 |
-
self.speech_recognizer = sr.Recognizer()
|
49 |
self.retrieval_qa: BaseRetrievalQA | None = None
|
50 |
self.persist_directory = os.path.join(os.path.dirname(__file__), "Alaroyedb")
|
51 |
self.prompt_template = """
|
@@ -164,59 +163,59 @@ Don't try to make up an answer.
|
|
164 |
# Return the formatted answer
|
165 |
return formatted_answer
|
166 |
|
167 |
-
def _listen(self) -> str:
|
168 |
-
|
169 |
-
|
170 |
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
|
177 |
-
|
178 |
-
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
|
190 |
-
|
191 |
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
|
196 |
-
|
197 |
|
198 |
-
def _speak(self, text: str) -> None:
|
199 |
-
|
200 |
-
|
201 |
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
|
208 |
-
|
209 |
-
|
210 |
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
|
221 |
@staticmethod
|
222 |
def _get_documents(
|
|
|
5 |
from typing import Any, Dict, List
|
6 |
|
7 |
import gradio as gr
|
8 |
+
# from gtts import gTTS
|
9 |
+
# from pydub import AudioSegment
|
10 |
+
# from pydub.playback import play
|
11 |
+
# from io import BytesIO
|
12 |
from dotenv import find_dotenv, load_dotenv
|
13 |
from langchain.chains import RetrievalQA
|
14 |
from langchain.chains.retrieval_qa.base import BaseRetrievalQA
|
|
|
16 |
from langchain.document_loaders import DirectoryLoader, TextLoader
|
17 |
from langchain.embeddings.openai import OpenAIEmbeddings
|
18 |
from langchain.llms import OpenAI
|
|
|
19 |
from langchain.prompts import PromptTemplate
|
20 |
from langchain.text_splitter import CharacterTextSplitter
|
21 |
from langchain.vectorstores import Chroma
|
22 |
+
# import speech_recognition as sr
|
23 |
|
24 |
|
25 |
# Load environment variables
|
|
|
44 |
self.embeddings = OpenAIEmbeddings() # type: ignore
|
45 |
self.llm = OpenAI(temperature=0.1) # type: ignore
|
46 |
self.vector_store: Chroma | None = None
|
47 |
+
# self.speech_recognizer = sr.Recognizer()
|
48 |
self.retrieval_qa: BaseRetrievalQA | None = None
|
49 |
self.persist_directory = os.path.join(os.path.dirname(__file__), "Alaroyedb")
|
50 |
self.prompt_template = """
|
|
|
163 |
# Return the formatted answer
|
164 |
return formatted_answer
|
165 |
|
166 |
+
# def _listen(self) -> str:
|
167 |
+
# """
|
168 |
+
# Listen to the user.
|
169 |
|
170 |
+
# Returns
|
171 |
+
# -------
|
172 |
+
# str
|
173 |
+
# The user's input.
|
174 |
+
# """
|
175 |
|
176 |
+
# # Initialize the microphone
|
177 |
+
# mic = sr.Microphone()
|
178 |
|
179 |
+
# # Listen to the user
|
180 |
+
# with mic as source:
|
181 |
+
# print("Calibrating microphone...")
|
182 |
+
# self.speech_recognizer.adjust_for_ambient_noise(source, duration=5)
|
183 |
|
184 |
+
# print("Listening...")
|
185 |
+
# try:
|
186 |
+
# audio = self.speech_recognizer.listen(source, timeout=5)
|
187 |
+
# print("Recognizing...")
|
188 |
|
189 |
+
# text = self.speech_recognizer.recognize_google(audio)
|
190 |
|
191 |
+
# return text
|
192 |
+
# except Exception as e:
|
193 |
+
# bad_response = "Sorry, I didn't catch that. Could you repeat yourself?"
|
194 |
|
195 |
+
# return bad_response
|
196 |
|
197 |
+
# def _speak(self, text: str) -> None:
|
198 |
+
# """
|
199 |
+
# Speak to the user.
|
200 |
|
201 |
+
# Parameters
|
202 |
+
# ----------
|
203 |
+
# text : str
|
204 |
+
# The text to speak to the user.
|
205 |
+
# """
|
206 |
|
207 |
+
# # Generate speech using gTTS
|
208 |
+
# tts = gTTS(text=text, lang="de")
|
209 |
|
210 |
+
# # Write the speech to bytes
|
211 |
+
# mp3_fp = BytesIO()
|
212 |
+
# tts.write_to_fp(mp3_fp)
|
213 |
|
214 |
+
# # Play the speech
|
215 |
+
# stream = BytesIO(mp3_fp.read())
|
216 |
+
# mp3_fp.close()
|
217 |
+
# audio = AudioSegment.from_file(stream, format="mp3")
|
218 |
+
# play(audio)
|
219 |
|
220 |
@staticmethod
|
221 |
def _get_documents(
|