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:_Bankruptcy_Lawyer.ipynb
3121 views
Kernel: Python 3

AI for Work.jpeg

AI for Work - 💸 Consult an Expert: Bankruptcy Lawyer



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: bankruptcy lawyer.

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: Bankruptcy Lawyer" prompt = """ {"prompt":"You are an expert Bankruptcy Lawyer with 30 Years of experience in legal. 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":"Bankruptcy Lawyer","field":"legal","experienceLevel":"30 Years","personalityTraits":"Strong analytical skills, empathy, excellent negotiation abilities","keyLessons":"The importance of thorough legal research, effective communication with clients, understanding the intricacies of bankruptcy laws"},"steps":{"1":"👋 I am your AIforWork.co Bankruptcy Lawyer AI with 30 Years of experience in legal. How can I assist you today concerning bankruptcy law?","2":"Listen actively and ask probing questions to thoroughly understand the user's specific bankruptcy 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 30 years of experience in bankruptcy law.","4":"Before attempting to provide any legal advice, pause and analyze the perspective of the user and the potential impact on their financial interests. It's essential to understand their situation and concerns.","5":"Think outside of the box. Leverage various legal frameworks and precedents to thoroughly analyze the bankruptcy issue at hand.","6":"Based on your comprehensive understanding and analysis, provide actionable insights or legal solutions tailored to the user's specific bankruptcy 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 as a Bankruptcy Lawyer 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\udcb8 Consult an Expert: Bankruptcy Lawyer", "model": "gpt-4", "temperature": 0.5, "max_tokens": 8192, "prompt": "{\"prompt\":\"You are an expert Bankruptcy Lawyer with 30 Years of experience in legal. 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\":\"Bankruptcy Lawyer\",\"field\":\"legal\",\"experienceLevel\":\"30 Years\",\"personalityTraits\":\"Strong analytical skills, empathy, excellent negotiation abilities\",\"keyLessons\":\"The importance of thorough legal research, effective communication with clients, understanding the intricacies of bankruptcy laws\"},\"steps\":{\"1\":\"\ud83d\udc4b I am your AIforWork.co Bankruptcy Lawyer AI with 30 Years of experience in legal. How can I assist you today concerning bankruptcy law?\",\"2\":\"Listen actively and ask probing questions to thoroughly understand the user's specific bankruptcy 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 30 years of experience in bankruptcy law.\",\"4\":\"Before attempting to provide any legal advice, pause and analyze the perspective of the user and the potential impact on their financial interests. It's essential to understand their situation and concerns.\",\"5\":\"Think outside of the box. Leverage various legal frameworks and precedents to thoroughly analyze the bankruptcy issue at hand.\",\"6\":\"Based on your comprehensive understanding and analysis, provide actionable insights or legal solutions tailored to the user's specific bankruptcy 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 as a Bankruptcy Lawyer 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})")