Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aeltorio committed Oct 12, 2024
1 parent 5ba7751 commit c9831ee
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
15 changes: 7 additions & 8 deletions src/aipane/aipane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<br>");

// 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, "<br>");

// 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<void>) => {
if (asyncResult.status === Office.AsyncResultStatus.Failed) {
Expand All @@ -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 };
Expand Down
8 changes: 6 additions & 2 deletions src/aipane/components/TextInsertion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -87,8 +88,11 @@ const TextInsertion: React.FC<TextInsertionProps> = (props: TextInsertionProps):
const answer = await props.insertAIAnswer(text);
setSkeletonVisibility(false);
if (answer.error) {
//textRef.current.innerHTML = `Error: ${answer.error}<br/>Answer: ${answer.response}`;
setAnswer(`${answer.error} \nAnswer: \n${answer.response.replace(/<br\/>/g, "\n").replace(/<br>/g, "\n")}`);
let error =
!isOutlookClient() && answer.error.includes("Unable to insert AI answer")
? ""
: `${answer.error} \nAnswer: \n`;
setAnswer(`${error}${answer.response}`);
}
};

Expand Down
14 changes: 13 additions & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 :"
},
Expand All @@ -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:]'"
}

0 comments on commit c9831ee

Please sign in to comment.