diff --git a/.idea/BarkTalk.iml b/.idea/BarkTalk.iml
index 848da22..86a0a88 100644
--- a/.idea/BarkTalk.iml
+++ b/.idea/BarkTalk.iml
@@ -7,7 +7,7 @@
-
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 90f665f..797b9b4 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,7 +1,10 @@
+
+
+
-
+
\ No newline at end of file
diff --git a/app.py b/app.py
index 4dbdbdc..6b95a60 100644
--- a/app.py
+++ b/app.py
@@ -14,6 +14,7 @@
CORS(app=app)
+
@app.route("/download/")
def download(file_name: str):
file_path = os.path.join(MEDIA_DIR, file_name)
@@ -28,15 +29,13 @@ def download(file_name: str):
return_data.seek(0)
- # os.remove(file_path)
+ os.remove(file_path)
return send_file(path_or_file=return_data,
download_name=file_name,
mimetype='audio/wav',
as_attachment=True)
- # return send_file(path_or_file=file_path, as_attachment=True)
-
@app.route("/supported_language")
def supported_language():
@@ -103,15 +102,15 @@ def ask(language: str):
@app.route("/ask/web/", methods=["POST"])
def ask_web(language: str):
data = request.get_json()
-
+
file_name = data['file_name']
file_content = data['file_content']
if file_name == "":
return jsonify({"data": None,
"message": "No selected file is available",
- "status": "error"}), 400
-
+ "status": "error"}), 400
+
if file_name and file_content and allowed_file(file_name=file_name):
secure_file_name = secure_filename(file_name)
secure_file_extension = get_file_extension(file_name=secure_file_name)
@@ -137,30 +136,27 @@ def ask_web(language: str):
answer_text = engine.command(prompt=prompt)
exact_answer_voice_name = text_to_speech.convert(text=answer_text,
- language=language)
+ language=language)
data = {
- "prompt": prompt,
- "prompt_language": language,
- "answer": {
- "text": answer_text,
- "file_name": exact_answer_voice_name,
- "answer_language": language,
- "voice_path": url_for("download", file_name=exact_answer_voice_name, _external=True, _scheme="http")
- }
- }
+ "prompt": prompt,
+ "prompt_language": language,
+ "answer": {
+ "text": answer_text,
+ "file_name": exact_answer_voice_name,
+ "answer_language": language,
+ "voice_path": url_for("download", file_name=exact_answer_voice_name, _external=True, _scheme="http")
+ }
+ }
return jsonify({"data": data,
"message": None,
- "status": "success"}), 200
-
- # return jsonify({"data": None,
- # "message": "DONE",
- # "status": "success"}), 200
+ "status": "success"}), 200
else:
return jsonify({"data": None,
"message": "File type not allowed. Only mp3 and wav files are acceptable",
"status": "error"}), 400
+
if __name__ == '__main__':
app.run()
diff --git a/brain_engine/gpt_engine.py b/brain_engine/gpt_engine.py
index 5a5d80f..37cec48 100644
--- a/brain_engine/gpt_engine.py
+++ b/brain_engine/gpt_engine.py
@@ -3,7 +3,7 @@
import asyncio
from config import OPENAI_KEY
-pre_content = """Note that if you cannot answer the question which is about something you do not know such as time-sensitive information(e.g. today's weather/stock, .etc), you can only reply \"IDK\" in your response without other characters. Do not say something like As an AI language model..., I'm sorry... and etc."""
+pre_content = """Configure Chat GPT to operate as a voice assistant capable of addressing a broad array of inquiries. Upon encountering queries beyond its expertise or those it cannot fulfil, it should politely convey its limitation with a phrase such as, "I apologize, but I don't have information on this topic."""
class GptEngine:
@@ -14,16 +14,19 @@ def __init__(self):
]
def command(self, prompt: str) -> str:
- prompt += "\n"
+ try:
+ prompt += "\n"
- self.messages.append({"role": "user", "content": prompt})
+ self.messages.append({"role": "user", "content": prompt})
- response = openai.ChatCompletion.create(
- model="gpt-3.5-turbo",
- messages=self.messages
- )
+ response = openai.ChatCompletion.create(
+ model="gpt-3.5-turbo",
+ messages=self.messages
+ )
- content = response.choices[0]['message']['content']
- self.messages.append({"role": "assistant", "content": content})
+ content = response.choices[0]['message']['content']
+ self.messages.append({"role": "assistant", "content": content})
- return content.replace("\n", "")
+ return content.replace("\n", "")
+ except Exception as err:
+ return print(err)
diff --git a/liara.json b/liara.json
new file mode 100644
index 0000000..ddb35bd
--- /dev/null
+++ b/liara.json
@@ -0,0 +1,8 @@
+{
+ "disks": [
+ {
+ "name": "barktalk-api-disk",
+ "mountTo": "media"
+ }
+ ]
+ }
\ No newline at end of file