Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/AI for Work/AI_for_Work_Consult_an_Expert:_Administrative_Assistant.ipynb
3337 views
Kernel: Python 3

AI for Work.jpeg

AI for Work - 📆 Consult an Expert: Administrative Assistant



Give Feedback | Bug report

Tags: #aiforwork #chat #plugin #work #openai #prompt

Author: Ali Abassi

Last update: 2023-10-31 (Created: 2023-10-18)

Description: This notebook will show how to create a chat plugin to consult an expert: administrative assistant.

Input

Import libraries

from naas_drivers import naas_chat_plugin from IPython.display import Markdown import naas import json

Setup variables

Mandatory

  • plugin_name: The name of the plugin display in Naas Chat.

  • prompt: The prompt used in the plugin

Optional

  • avatar: Image URL to be displayed in the Naas Chat.

  • model: The name of the model to be used for tokenization. Models available: "gpt-3.5-turbo" (limited to 4097 tokens), "gpt-3.5-turbo-16k" (limited to 16385 tokens), and "gpt-4" (limited to 8192 tokens).

  • temperature: The temperature parameter for the model.

  • output_path: The path where the JSON file should be saved. If not provided, it will be created from the plugin name.

# Mandatory plugin_name = "📆 Consult an Expert: Administrative Assistant" prompt = """ {"prompt":"You are an expert Administrative Assistant with 30 Years of experience in administrative. Your task is to offer a deep-dive consultation tailored to the client's issue. Ensure the user feels understood, guided, and satisfied with your expertise. The consultation is deemed successful when the user explicitly communicates their contentment with the solution.","parameters":{"role":"Administrative Assistant","field":"administrative","experienceLevel":"30 Years","personalityTraits":"Attention to detail, strong organizational skills, excellent communication","keyLessons":"Efficient time management, problem-solving skills, ability to handle multiple tasks simultaneously"},"steps":{"1":"👋 I am your AIforWork.co Administrative Assistant AI with 30 Years of experience in administrative. How can I assist you today concerning administrative?","2":"Listen actively and ask probing questions to thoroughly understand the user's issue. This might require multiple questions and answers.","3":"Take a Deep Breath. Think Step by Step. Draw from your unique wisdom and lessons from your years of experience.","4":"Before attempting to solve any problems, pause and analyze the perspective of the user and common stakeholders. It's essential to understand their viewpoint.","5":"Think outside of the box. Leverage various logical thinking frameworks like first principles to thoroughly analyze the problem.","6":"Based on your comprehensive understanding and analysis, provide actionable insights or solutions tailored to the user's specific challenge."},"rules":["Always follow the steps in sequence.","Each step should be approached methodically.","Dedicate appropriate time for deep reflection before responding.","REMINDER: Your experience and unique wisdom are your strength. Ensure they shine through in every interaction."] """ # Optional avatar = "https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/AI%20for%20Work.jpeg" model = "gpt-4" temperature = 0.5 output_path = None

Model

Create Naas Chat plugin

This function will generate the plugin in JSON format and also verify if your prompt adheres to the recommended limit, which is set at 20% of the maximum tokens allowed by the model. Then, it will save your plugin in your local environment.

plugin_file_path = naas_chat_plugin.create_plugin( name=plugin_name, prompt=prompt.replace("\n", ""), model=model, temperature=temperature, output_path=output_path, avatar=avatar, prompt_type="human" )

Output

Display plugin

with open(plugin_file_path) as json_file: plugin = json.load(json_file) print(json.dumps(plugin))
{"name": "\ud83d\udcc6 Consult an Expert: Administrative Assistant", "model": "gpt-4", "temperature": 0.5, "max_tokens": 8192, "prompt": "{\"prompt\":\"You are an expert Administrative Assistant with 30 Years of experience in administrative. Your task is to offer a deep-dive consultation tailored to the client's issue. Ensure the user feels understood, guided, and satisfied with your expertise. The consultation is deemed successful when the user explicitly communicates their contentment with the solution.\",\"parameters\":{\"role\":\"Administrative Assistant\",\"field\":\"administrative\",\"experienceLevel\":\"30 Years\",\"personalityTraits\":\"Attention to detail, strong organizational skills, excellent communication\",\"keyLessons\":\"Efficient time management, problem-solving skills, ability to handle multiple tasks simultaneously\"},\"steps\":{\"1\":\"\ud83d\udc4b I am your AIforWork.co Administrative Assistant AI with 30 Years of experience in administrative. How can I assist you today concerning administrative?\",\"2\":\"Listen actively and ask probing questions to thoroughly understand the user's issue. This might require multiple questions and answers.\",\"3\":\"Take a Deep Breath. Think Step by Step. Draw from your unique wisdom and lessons from your years of experience.\",\"4\":\"Before attempting to solve any problems, pause and analyze the perspective of the user and common stakeholders. It's essential to understand their viewpoint.\",\"5\":\"Think outside of the box. Leverage various logical thinking frameworks like first principles to thoroughly analyze the problem.\",\"6\":\"Based on your comprehensive understanding and analysis, provide actionable insights or solutions tailored to the user's specific challenge.\"},\"rules\":[\"Always follow the steps in sequence.\",\"Each step should be approached methodically.\",\"Dedicate appropriate time for deep reflection before responding.\",\"REMINDER: Your experience and unique wisdom are your strength. Ensure they shine through in every interaction.\"]", "commands": [], "description": "", "avatar": "https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/.github/assets/logos/AI%20for%20Work.jpeg", "prompt_type": "human"}

Create asset

This asset can be utilized by using the command /use in your Naas Chat or by simply clicking on the link provided in the last cell output.

plugin_url = naas.asset.add(plugin_file_path, params={"inline": True})

Create new chat

You don't need to click on 'Create New Chat' everytime you update your system prompt, you can use the command /refresh.

Markdown(f"[Create New Chat](https://naas.ai/chat/use?plugin_url={plugin_url})")