diff --git a/app/main.py b/app/main.py index 4641852..324e4ef 100644 --- a/app/main.py +++ b/app/main.py @@ -14,38 +14,6 @@ client = WebClient(token=slack_token) verifier = SignatureVerifier(signing_secret) - -@app.route("/slack/events", methods=["POST"]) -def slack_events(): - if not verifier.is_valid_request(request.get_data(), request.headers): - return "Request verification failed", 403 - - event_data = request.json - - if "challenge" in event_data: - return jsonify({"challenge": event_data["challenge"]}) - - if "event" in event_data: - event = event_data["event"] - - if event.get("type") == "app_mention": - user = event["user"] - text = event["text"] - channel = event["channel"] - - # Change this to your RAG model's response function - # This is where you would call your RAG model - # For example, if you have a function `get_rag_response`: - response_text = get_rag_response(text) - - # Respond to Slack - client.chat_postMessage( - channel=channel, - text=f"<@{user}> {response_text}" - ) - - return "OK", 200 - @app.route("/slack/commands", methods=["POST"]) def slack_commands(): data = request.form @@ -57,5 +25,22 @@ def slack_commands(): }) return "Unknown command", 200 +@app.route("/slack/prompt", methods=["POST"]) +def slack_prompt(): + data = request.form + user_id = data.get("user_id") + query = data.get("text") # This is the user's prompt message + + # Change this to your RAG model's response function + # This is where you would call your RAG model + # For example, if you have a function `get_rag_response`: + response = get_rag_response(query) + + # Respond back publicly in the slack channel or privately to the user + return jsonify({ + "response_type": "in_channel", # or "ephemeral" for private replies + "text": f"<@{user_id}> {response}" + }) + if __name__ == "__main__": app.run(debug=True,port=3000)