rag template
Browse files- App/Chat/ChatRoutes.py +0 -1
- App/Chat/utils/RAG.py +3 -1
- App/Worker.py +3 -3
App/Chat/ChatRoutes.py
CHANGED
@@ -39,7 +39,6 @@ async def generate_message(
|
|
39 |
):
|
40 |
entry: Transcriptions = await Transcriptions.objects.filter(task_id=task_id).first()
|
41 |
result = BaseTranscription(**entry.__dict__)
|
42 |
-
print(result)
|
43 |
text = ""
|
44 |
for item in result.content:
|
45 |
text += item["text"]
|
|
|
39 |
):
|
40 |
entry: Transcriptions = await Transcriptions.objects.filter(task_id=task_id).first()
|
41 |
result = BaseTranscription(**entry.__dict__)
|
|
|
42 |
text = ""
|
43 |
for item in result.content:
|
44 |
text += item["text"]
|
App/Chat/utils/RAG.py
CHANGED
@@ -27,11 +27,13 @@ class GenerativeAIAssistant:
|
|
27 |
Template =f'''
|
28 |
#Instructions
|
29 |
You are given the following context in yaml of a transcript of a youtube video, the start and end times are indicated and the text that was said is also given. You are also given a question, use the context to answer the question in a consise manner, make it short and to the point, don't provide additional details.
|
30 |
-
|
31 |
|
32 |
#Context
|
33 |
{context_yaml}
|
34 |
|
|
|
|
|
35 |
#Question
|
36 |
{question}
|
37 |
'''
|
|
|
27 |
Template =f'''
|
28 |
#Instructions
|
29 |
You are given the following context in yaml of a transcript of a youtube video, the start and end times are indicated and the text that was said is also given. You are also given a question, use the context to answer the question in a consise manner, make it short and to the point, don't provide additional details.
|
30 |
+
|
31 |
|
32 |
#Context
|
33 |
{context_yaml}
|
34 |
|
35 |
+
#Your response be as short as possible and to the point.
|
36 |
+
|
37 |
#Question
|
38 |
{question}
|
39 |
'''
|
App/Worker.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from celery import Celery, chain
|
2 |
import os
|
3 |
import time
|
|
|
4 |
from App import celery_config
|
5 |
import yt_dlp
|
6 |
import tempfile
|
@@ -16,6 +17,7 @@ celery.conf.update(
|
|
16 |
|
17 |
@celery.task(name="embbeding", bind=True)
|
18 |
def generate_store(self, data, task_id):
|
|
|
19 |
chunks = generateChunks(data, task_id)
|
20 |
encode(chunks)
|
21 |
print("hellooo")
|
@@ -30,10 +32,8 @@ def transcription_task(self, file_path, model_size="tiny"):
|
|
30 |
|
31 |
@celery.task(name="download", bind=True)
|
32 |
def downloadfile(self, url, ydl_opts, model_size="base"):
|
33 |
-
# updated
|
34 |
self.update_state(state="Downloading File..", meta={})
|
35 |
|
36 |
-
####
|
37 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
38 |
ydl.download([url])
|
39 |
|
@@ -41,7 +41,7 @@ def downloadfile(self, url, ydl_opts, model_size="base"):
|
|
41 |
self.update_state(state="Downloading complete", meta={})
|
42 |
audio_file = ydl_opts["outtmpl"]
|
43 |
print(model_size, "worker after")
|
44 |
-
|
45 |
data = transcribe_file(
|
46 |
state=self, file_path=audio_file["default"], model_size=model_size
|
47 |
)
|
|
|
1 |
from celery import Celery, chain
|
2 |
import os
|
3 |
import time
|
4 |
+
import cgi
|
5 |
from App import celery_config
|
6 |
import yt_dlp
|
7 |
import tempfile
|
|
|
17 |
|
18 |
@celery.task(name="embbeding", bind=True)
|
19 |
def generate_store(self, data, task_id):
|
20 |
+
print('generating chunks')
|
21 |
chunks = generateChunks(data, task_id)
|
22 |
encode(chunks)
|
23 |
print("hellooo")
|
|
|
32 |
|
33 |
@celery.task(name="download", bind=True)
|
34 |
def downloadfile(self, url, ydl_opts, model_size="base"):
|
|
|
35 |
self.update_state(state="Downloading File..", meta={})
|
36 |
|
|
|
37 |
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
38 |
ydl.download([url])
|
39 |
|
|
|
41 |
self.update_state(state="Downloading complete", meta={})
|
42 |
audio_file = ydl_opts["outtmpl"]
|
43 |
print(model_size, "worker after")
|
44 |
+
|
45 |
data = transcribe_file(
|
46 |
state=self, file_path=audio_file["default"], model_size=model_size
|
47 |
)
|