page_type | urlFragment | products | languages | extensions | description | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
sample |
Word-Add-in-AI-Assistant |
|
|
|
Create a Word Add-in that produces content or chat with AI to assit your writting. |
This add-in demonstrates Word add-in capabilities to insert content generated by AI or edited manually into Document Comment Footnote and Header. There're two mode: chat mode and predefined prompt prefix to generate text/picture.
- Select the 'Generation Text' option from dropdown list and select the source words from document, submit, generated text returned from Azure OpenAI service, select where you want to insert the generated text into.
- Generate picture. Select the 'Generate Picture' option and select the source words from document, submit, insert the picture into the cusor pisiton inside document.
- Switch to chat mode. You can send whatever text words to the chat box, insert the generated text into Document/Comment/Footnote/Header.
- You can configure the drop down list to whatever prompt prefix you like. Clone the project and open config.tsx. Change the AssistanceOption and GenerateOption following the format of the existing GenerateText and GeneratePicture.
- You need to input the Azure OpenAI account once you relaunch/reload the add-in. You can persist the account details: apiKey endpoint deployment in AIKeyConfigDialog.tsx or just refill in it whenever the add in ask.
- Word on Windows, Mac, and in a browser.
- Microsoft 365
- Required: Follow the procedure to request an Azure OpenAI service account. Find more details at https://learn.microsoft.com/en-us/azure/ai-services/openai/quickstart?tabs=command-line%2Cpython&pivots=rest-api.
If you prefer to run the sample with clear and step-by-step instructions, follow the detailed steps provided below.
- Install a recent version of npm and Node.js on your computer. To verify if you've already installed these tools, run the commands
node -v
andnpm -v
in your terminal. - Clone the repo to your local workspace or directly download the source code.
- Open the
Word-Scenario-based-Add-in-Samples\Word-Add-in-AI-Assistant
folder in Visual Studio Code. You can see the sample code and make code changes to the sample. - Required: Fill in the parameters apiKey, endpoint and deployment in src/taskpane/components/utility/config.tsx to persist the Azure OpenAI account or you can skip this step to fill in the account when you operate the AI related UI.
- cd src folder and execute following commands in your CLI to start the sample add-in on desktop, make sure the CLI is run as administrator:
npm install npm start
- Or you can skip the last step and start debugging the project by hitting the
F5
key in Visual Studio Code.
You may explore additional resources at the following links:
- Did you experience any problems with the sample? Create an issue and we'll help you out.
- We'd love to get your feedback about this sample. Go to our Office samples survey to give feedback and suggest improvements.
- For general questions about developing Office Add-ins, go to Microsoft Q&A using the office-js-dev tag.
Copyright (c) 2021 Microsoft Corporation. All rights reserved.
This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Note: The taskpane.html file contains an image URL that tracks diagnostic data for this sample add-in. Please remove the image tag if you reuse this sample in your own code project.