Skip to content

Commit

Permalink
slug-title
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Lin authored and Paul Lin committed Apr 14, 2024
1 parent 55ead80 commit e52abfb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,26 @@ def validate_cas_ticket():
print("response status is not 200")
return jsonify({"isAuthenticated": False}), 401

@app.route("/api/slug", methods=["POST"])
def get_chat_history_slug():
data = request.get_json()
user_messages = data.get("message", None)
user_messages_ = user_messages.copy()
user_messages_.append(
{
"role": "user",
"content": "Write a descriptive title (3-4 words) for the topic of our conversation with no puncutation. Do not include 'discussion' or 'chat' in the title.",
}
)

response = chat_completion_request(messages=user_messages_)
try:
response = response.choices[0].message.content
return jsonify({"slug": response})
except:
return jsonify({"slug": "Untitled"})


@app.route("/api/chat", methods=["POST"])
def chat():
data = request.get_json()
Expand Down

0 comments on commit e52abfb

Please sign in to comment.