Skip to content

Commit

Permalink
PR to copy ref docs links, along with the LLM response (#1479)
Browse files Browse the repository at this point in the history
* copy ref docs

* fix ci

* fix review

* fix review
  • Loading branch information
justjais authored Jan 8, 2025
1 parent 7a5eb72 commit 7db0b08
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ansible_ai_connect_chatbot/src/useChatbot/useChatbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,25 @@ export const useChatbot = () => {
onClick: () => {
if (message.actions) {
message.actions.copy.className = "action-button-clicked";
navigator.clipboard.writeText(
typeof response === "object" ? response.response : response,
);
const ref_docs =
typeof response === "object"
? response.referenced_documents?.slice(0, 5)
: response;
if (ref_docs) {
const llmResponse = [
typeof response === "object" ? response.response : response,
",\n",
typeof response === "object"
? response.referenced_documents
?.slice(0, 5)
.map((doc) => doc.docs_url)
.join(",\n")
: response,
];
navigator.clipboard.writeText(
llmResponse?.map((llmResponse) => llmResponse).join(""),
);
}
}
},
},
Expand Down

0 comments on commit 7db0b08

Please sign in to comment.