Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Started to fix search widgets.
Browse files Browse the repository at this point in the history
  • Loading branch information
lvalics committed Feb 3, 2024
1 parent e3bc7c3 commit 8e27b0e
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 94 deletions.
2 changes: 1 addition & 1 deletion dj_backend_server/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


urlpatterns = [
path('send_search_request/', views_message.send_search_request, name='send_search_request'),
path('chat/search/', views_message.send_search_request, name='send_search_request'),
path('chat/init/', views_message.init_chat, name='init_chat'),
path('chat/send/', views_message.send_chat, name='send_chat'),
# website/codebase/pdf ingestion endpoint
Expand Down
8 changes: 4 additions & 4 deletions dj_backend_server/api/views/views_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@ def send_search_request(request):
'text' key, an error message and a 400 status code if the message was not provided, an error message and a 500 status code
if the API response did not include a 'text' key, or an error message and a 500 status code if an exception was raised.
"""
def send_search_request(request):
try:
# Validate the request data
message = request.POST.get('message')
history = request.POST.getlist('history[]')

data = json.loads(request.body)
message = data.get('message')
history = data.get('history', [])
# Implement the equivalent logic for validation
if not message:
return JsonResponse({
Expand All @@ -106,7 +107,6 @@ def send_search_request(request):
bot = get_object_or_404(Chatbot, token=bot_token)

# Implement the equivalent logic to send the HTTP request to the external API
# print(os.getenv('APP_URL'))
response = requests.post(
os.getenv('APP_URL') + '/api/chat/',
json={
Expand Down
Loading

0 comments on commit 8e27b0e

Please sign in to comment.