Skip to content

Commit

Permalink
Convert similarity API back to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
ericholscher committed Mar 14, 2024
1 parent 7c0e01e commit e92f4ce
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions adserver/analyzer/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class EmbeddingViewSet(APIView):
"""

permission_classes = [AllowAny]
renderer_classes = [StaticHTMLRenderer]

def get(self, request):
"""Return a list of similar URLs and scores based on querying the AnalyzedURL embedding for an incoming URL."""
Expand Down Expand Up @@ -74,19 +73,9 @@ def get(self, request):
)

return Response(
f"""
<h2>Results:</h2>
<ul>
<li><a href="{urls[0].url}">{urls[0].url}</a></li>
<li><a href="{urls[1].url}">{urls[1].url}</a></li>
<li><a href="{urls[2].url}">{urls[2].url}</a></li>
<li><a href="{urls[3].url}">{urls[3].url}</a></li>
</ul>
<h2>
Text:
</h2>
<textarea style="height:100%; width:80%" disabled>
{processed_text}
</textarea>
"""
{
"count": len(urls),
"text": processed_text[:500],
"results": [[url.url, url.distance] for url in urls],
}
)

0 comments on commit e92f4ce

Please sign in to comment.