-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RAG MVP #374
base: sk/pg-vector
Are you sure you want to change the base?
RAG MVP #374
Conversation
available_variables should be added as "source_material" using form_data , but I could not figure out how to od it with form_data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. A few small comments but nothing major.
apps/experiments/tasks.py
Outdated
def store_rag_embedding(self, experiment) -> None: | ||
file_path = experiment.files.all().last().file.path | ||
splits = load_rag_file(file_path) | ||
embeddings_model = OpenAIEmbeddings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use embeddings from LLM service
embeddings_model = OpenAIEmbeddings() | |
embeddings_model = experiment.get_llm_service().get_openai_embeddings() |
apps/experiments/tasks.py
Outdated
PGVector.from_texts(splits, embeddings_model, None, experiment) | ||
|
||
|
||
@shared_task(bind=True, base=TaskbadgerTask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be a task since it's just called as a normal function
@shared_task(bind=True, base=TaskbadgerTask) |
apps/experiments/views/experiment.py
Outdated
@@ -361,6 +365,7 @@ def form_valid(self, form): | |||
experiment = get_object_or_404(Experiment, team=self.request.team, pk=self.kwargs["pk"]) | |||
file = super().form_valid(form) | |||
experiment.files.add(file) | |||
store_rag_embedding(experiment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To execute this as a task you should call .delay
:
store_rag_embedding(experiment) | |
store_rag_embedding.delay(experiment.id) |
Also we just pass the experiment ID to avoid serialising the whole experiment object
apps/experiments/tasks.py
Outdated
@@ -23,6 +27,44 @@ def get_response_for_webchat_task(self, experiment_session_id: int, message_text | |||
return message_handler.new_user_message(message) | |||
|
|||
|
|||
@shared_task(bind=True, base=TaskbadgerTask) | |||
def store_rag_embedding(self, experiment) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than taking the experiment object this should take just the ID and fetch the experiment from the DB:
def store_rag_embedding(self, experiment) -> None: | |
def store_rag_embedding(self, experiment_id: int) -> None: | |
experiment = Experiment.objects.get(id=experiment_id) |
@snopoke, just pushed your fixes. Tested with a simple pdf file: The following prompt:
The following questions:
|
Adding a minimum minimum viable RAG feature