|
| 1 | +/* |
| 2 | + * CLOUDERA APPLIED MACHINE LEARNING PROTOTYPE (AMP) |
| 3 | + * (C) Cloudera, Inc. 2025 |
| 4 | + * All rights reserved. |
| 5 | + * |
| 6 | + * Applicable Open Source License: Apache 2.0 |
| 7 | + * |
| 8 | + * NOTE: Cloudera open source products are modular software products |
| 9 | + * made up of hundreds of individual components, each of which was |
| 10 | + * individually copyrighted. Each Cloudera open source product is a |
| 11 | + * collective work under U.S. Copyright Law. Your license to use the |
| 12 | + * collective work is as provided in your written agreement with |
| 13 | + * Cloudera. Used apart from the collective work, this file is |
| 14 | + * licensed for your use pursuant to the open source license |
| 15 | + * identified above. |
| 16 | + * |
| 17 | + * This code is provided to you pursuant a written agreement with |
| 18 | + * (i) Cloudera, Inc. or (ii) a third-party authorized to distribute |
| 19 | + * this code. If you do not have a written agreement with Cloudera nor |
| 20 | + * with an authorized and properly licensed third party, you do not |
| 21 | + * have any rights to access nor to use this code. |
| 22 | + * |
| 23 | + * Absent a written agreement with Cloudera, Inc. ("Cloudera") to the |
| 24 | + * contrary, A) CLOUDERA PROVIDES THIS CODE TO YOU WITHOUT WARRANTIES OF ANY |
| 25 | + * KIND; (B) CLOUDERA DISCLAIMS ANY AND ALL EXPRESS AND IMPLIED |
| 26 | + * WARRANTIES WITH RESPECT TO THIS CODE, INCLUDING BUT NOT LIMITED TO |
| 27 | + * IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND |
| 28 | + * FITNESS FOR A PARTICULAR PURPOSE; (C) CLOUDERA IS NOT LIABLE TO YOU, |
| 29 | + * AND WILL NOT DEFEND, INDEMNIFY, NOR HOLD YOU HARMLESS FOR ANY CLAIMS |
| 30 | + * ARISING FROM OR RELATED TO THE CODE; AND (D)WITH RESPECT TO YOUR EXERCISE |
| 31 | + * OF ANY RIGHTS GRANTED TO YOU FOR THE CODE, CLOUDERA IS NOT LIABLE FOR ANY |
| 32 | + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, PUNITIVE OR |
| 33 | + * CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT LIMITED TO, DAMAGES |
| 34 | + * RELATED TO LOST REVENUE, LOST PROFITS, LOSS OF INCOME, LOSS OF |
| 35 | + * BUSINESS ADVANTAGE OR UNAVAILABILITY, OR LOSS OR CORRUPTION OF |
| 36 | + * DATA. |
| 37 | + */ |
| 38 | + |
| 39 | +import { ChatMessageType } from "src/api/chatApi.ts"; |
| 40 | +import messageQueue from "src/utils/messageQueue.ts"; |
| 41 | +import { Button, Tooltip } from "antd"; |
| 42 | +import { CopyOutlined } from "@ant-design/icons"; |
| 43 | + |
| 44 | +const CopyButton = ({ message }: { message: ChatMessageType }) => { |
| 45 | + return ( |
| 46 | + <Tooltip title="Copy the assistant's response"> |
| 47 | + <Button |
| 48 | + onClick={() => { |
| 49 | + navigator.clipboard |
| 50 | + .writeText(message.rag_message.assistant) |
| 51 | + .catch(() => { |
| 52 | + messageQueue.error("Failed to copy to clipboard"); |
| 53 | + }); |
| 54 | + }} |
| 55 | + type="text" |
| 56 | + icon={<CopyOutlined />} |
| 57 | + /> |
| 58 | + </Tooltip> |
| 59 | + ); |
| 60 | +}; |
| 61 | +export default CopyButton; |
0 commit comments