Skip to content

Commit

Permalink
Localized prompt support for conversation title generation
Browse files Browse the repository at this point in the history
  • Loading branch information
WongSaang committed Mar 30, 2023
1 parent 870cddd commit a6201a8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion chat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ def sse_pack(event, data):
@permission_classes([IsAuthenticated])
def gen_title(request):
conversation_id = request.data.get('conversationId')
prompt = request.data.get('prompt')
conversation_obj = Conversation.objects.get(id=conversation_id)
message = Message.objects.filter(conversation_id=conversation_id).order_by('created_at').first()

if prompt is None:
prompt = 'Generate a short title for the following content, no more than 10 words. \n\nContent: '

messages = [
{"role": "user", "content": 'Generate a short title for the following content, no more than 10 words: \n\n "%s"' % message.message},
{"role": "user", "content": prompt + message.message},
]

myOpenai = get_openai()
Expand Down

0 comments on commit a6201a8

Please sign in to comment.