Skip to content

Commit

Permalink
Add Generating summary section
Browse files Browse the repository at this point in the history
Update primary instruction and Add New prompt instructions
  • Loading branch information
susilnem authored and thenav56 committed Oct 17, 2024
1 parent 9601eb4 commit c7f932b
Show file tree
Hide file tree
Showing 7 changed files with 727 additions and 476 deletions.
4 changes: 4 additions & 0 deletions main/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@
NS_DOCUMENT_API_KEY=(str, None),
NS_INITIATIVES_API_KEY=(str, None),
NS_INITIATIVES_API_TOKEN=(str, None),
# OpenAi Azure
AZURE_OPENAI_ENDPOINT=(str, None),
AZURE_OPENAI_KEY=(str, None),
AZURE_OPENAI_DEPLOYMENT_NAME=(str, None),
)


Expand Down
7 changes: 3 additions & 4 deletions per/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import django_filters
from django.core.serializers.json import DjangoJSONEncoder
from django.db import transaction

from per.models import OpsLearningCacheResponse
from per.task import generate_summary
Expand Down Expand Up @@ -51,7 +52,5 @@ def get_or_create(
ops_learning_summary = OpsLearningCacheResponse.objects.filter(used_filters_hash=hash_value).first()
if ops_learning_summary:
return ops_learning_summary
# TODO: Create a new summary based on the filters
# returning a dummy object for now
# return OpsLearningCacheResponse.objects.first()
return generate_summary(filter_data, hash_value)
# Create a new summary and cache it
return transaction.on_commit(lambda: generate_summary.delay(filter_data, hash_value))
6 changes: 3 additions & 3 deletions per/drf_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,16 +810,16 @@ def get_renderer_context(self):

return context

@extend_schema(filters=True)
@extend_schema(response=OpsLearningSummarySerializer, filters=True)
@action(
detail=False,
methods=["GET"],
permission_classes=[permissions.IsAuthenticated],
permission_classes=[permissions.AllowAny],
url_path="summary",
)
def summary(self, request):
"""
Returns a summary of the OpsLearning data
Get the Ops Learning Summary based on the filters
"""
ops_learning_summary_instance = OpslearningSummaryCacheHelper.get_or_create(request, [self.filterset_class])
return response.Response(OpsLearningSummarySerializer(ops_learning_summary_instance).data)
Expand Down
591 changes: 591 additions & 0 deletions per/ops_learning_summary.py

Large diffs are not rendered by default.

Loading

0 comments on commit c7f932b

Please sign in to comment.