From c9831ee38698f2391fd6707c8aa5cdd5e7f61309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=A6Ltorio?= Date: Sat, 12 Oct 2024 09:25:33 +0200 Subject: [PATCH] wip --- README.md | 7 +++++++ src/aipane/aipane.ts | 15 +++++++-------- src/aipane/components/TextInsertion.tsx | 8 ++++++-- src/config.json | 14 +++++++++++++- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6a72a06..341b46f 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,7 @@ Give us a **star** if you like the project. We are looking for contributors to h - [Privacy Policy](#privacy-policy) - [Contributing](#contributing) - [Support](#support) + - [Thanks](#thanks) ## Overview @@ -133,3 +134,9 @@ If you encounter any issues or have questions about the AI Outlook Add-in, pleas --- This project is not affiliated with or endorsed by Microsoft, Meta, SambaNova or Groq. It is an independent add-in developed to enhance the Outlook web experience using Groq's AI capabilities and Meta Llama models. + +## Thanks + +Thank you to Groq for giving us access for free to their AI API. We are grateful for their support and collaboration. + +[![Powered by Groq for fast inference.](https://groq.com/wp-content/uploads/2024/03/PBG-mark1-color.svg)](https://groq.com) diff --git a/src/aipane/aipane.ts b/src/aipane/aipane.ts index e114c1c..38bc7ed 100644 --- a/src/aipane/aipane.ts +++ b/src/aipane/aipane.ts @@ -142,17 +142,16 @@ export async function insertAIAnswer( let aiText: string = await aiRequest(provider, model, apiKey, system, `${user}\n${userText}`); console.log(`AI provider: ${provider.name} AI model: ${model.name}: \n${aiText}`); - // Replace newlines with HTML line breaks - aiText = aiText.replace(/\n/g, "
"); - - // Sanitize and escape the AI-generated text - const sanitizedAiText = DOMPurify.sanitize(aiText); - // Insert the AI-generated text into the email body if (isOutlookClient()) { + // Replace newlines with HTML line breaks + aiText = aiText.replace(/\n/g, "
"); + + // Sanitize and escape the AI-generated text + aiText = DOMPurify.sanitize(aiText); error = null; Office.context.mailbox.item?.body.setSelectedDataAsync( - sanitizedAiText, + aiText, { coercionType: Office.CoercionType.Html }, (asyncResult: Office.AsyncResult) => { if (asyncResult.status === Office.AsyncResultStatus.Failed) { @@ -161,7 +160,7 @@ export async function insertAIAnswer( } ); } - return { response: sanitizedAiText, error }; + return { response: aiText, error }; } catch (err) { console.error("Error: " + err); return { response: "", error }; diff --git a/src/aipane/components/TextInsertion.tsx b/src/aipane/components/TextInsertion.tsx index 4bb84d7..d253ae2 100644 --- a/src/aipane/components/TextInsertion.tsx +++ b/src/aipane/components/TextInsertion.tsx @@ -13,6 +13,7 @@ import { AIAnswer } from "../AIPrompt"; import Markdown from "react-markdown"; import rehypeHighlight from "rehype-highlight"; import "highlight.js/styles/github.css"; +import { isOutlookClient } from "../aipane"; /** * Props for the TextInsertion component. @@ -87,8 +88,11 @@ const TextInsertion: React.FC = (props: TextInsertionProps): const answer = await props.insertAIAnswer(text); setSkeletonVisibility(false); if (answer.error) { - //textRef.current.innerHTML = `Error: ${answer.error}
Answer: ${answer.response}`; - setAnswer(`${answer.error} \nAnswer: \n${answer.response.replace(//g, "\n").replace(/
/g, "\n")}`); + let error = + !isOutlookClient() && answer.error.includes("Unable to insert AI answer") + ? "" + : `${answer.error} \nAnswer: \n`; + setAnswer(`${error}${answer.response}`); } }; diff --git a/src/config.json b/src/config.json index e0d6be7..11d12c8 100644 --- a/src/config.json +++ b/src/config.json @@ -258,7 +258,7 @@ { "id": "a0f98147-0986-40f2-b38c-27b677cd43b5", "system": "you are an assistant specializing in the redaction of french summary of english web pages. Your task is to summarize the provided web page in a clear and concise manner. The summary should capture the main points of the page, including key information, arguments, and conclusions. It should be written in french. It should provides a comprehensive overview of the content. The summary should not be more than 3000 words long.", - "summary": "Résumme et traduit la page web en français en capturant les points principaux et les informations clés en moins de 3000 mots.", + "summary": "Résume et traduit la page web en français en capturant les points principaux et les informations clés en moins de 3000 mots.", "standalone": true, "user": "This is the web page :" }, @@ -268,7 +268,19 @@ "summary": "Promote and support open-source projects.", "standalone": true, "user": "" + }, + { + "id": "4505d1e5-bd00-48a9-9694-c2d8a0428113", + "system": "As a specialist in markup languages, you possess a unique expertise in converting content from one markup language to another. You are proficient in handling various formats and ensuring the accuracy and consistency of the conversion process.", + "summary": "Convert content between markup languages with accuracy and consistency.", + "standalone": true, + "user": "" } ], + "copyright": { + "year": 2024, + "owner": "SCTG Development - Ronan Le Meillat", + "license": "AGPL-3.0" + }, "uuidgen": "uuidgen | tr '[:upper:]' '[:lower:]'" } \ No newline at end of file