Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: OpenAI - Prompt template for ChatGPT to act as a world-class business coach #2207

Merged
merged 8 commits into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
317 changes: 317 additions & 0 deletions OpenAI/OpenAI_Act_as_a_World-class_Business_Coach.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "f968e9be",
"metadata": {},
"source": [
"<img width=\"10%\" alt=\"Naas\" src=\"https://landen.imgix.net/jtci2pxwjczr/assets/5ice39g4.png?w=160\"/>"
]
},
{
"cell_type": "markdown",
"id": "717314a7",
"metadata": {},
"source": [
"# OpenAI - Act as a World-class Business Coach"
]
},
{
"cell_type": "markdown",
"id": "5596529e",
"metadata": {},
"source": [
"**Tags:** #ai #businesscoach #artificialintelligence #aitrends #aiconcepts #plugin #openai #naaschatplugin #naas #naas_driver #chat"
]
},
{
"cell_type": "markdown",
"id": "5372e343",
"metadata": {},
"source": [
"**Author:** [Zihui Ouyang](https://www.linkedin.com/in/zihui-ouyang-539626227/)"
]
},
{
"cell_type": "markdown",
"id": "72725ae6",
"metadata": {},
"source": [
"**Last update:** 2023-10-03 (Created: 2023-09-20)"
]
},
{
"cell_type": "markdown",
"id": "7c8f5113",
"metadata": {},
"source": [
"**Description:** This notebook will create a plugin to act as a world class business coach."
]
},
{
"cell_type": "markdown",
"id": "06513f9f",
"metadata": {},
"source": [
"**References:**\n",
"- [OpenAI Documentation](https://openai.com/docs/)\n",
"- [7 prompts ChatGPT indispensables](https://docs.google.com/document/d/1CMZa0o1ck_1l-t7ICF7_y2tDokcBkP68Nkxd64KWuQk/edit)\n",
"- [Naas Chat Documentation](https://site.naas.ai/docs/platform/aI-powered-chat)\n",
"- [Naas Chat Plugin driver](https://github.com/jupyter-naas/drivers/blob/main/naas_drivers/tools/naas_chat_plugin.py)"
]
},
{
"cell_type": "markdown",
"id": "341e0265",
"metadata": {},
"source": [
"## Input"
]
},
{
"cell_type": "markdown",
"id": "ee8ad918",
"metadata": {},
"source": [
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e2e046c1",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from naas_drivers import naas_chat_plugin\n",
"from IPython.display import Markdown\n",
"import naas\n",
"import json"
]
},
{
"cell_type": "markdown",
"id": "b316c708",
"metadata": {},
"source": [
"### Setup Variables\n",
"**Mandatory**\n",
"- `name`: The name of the plugin.\n",
"- `prompt`: The prompt for the plugin.\n",
"\n",
"**Optional**\n",
"- `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). \n",
"- `temperature`: The temperature parameter for the model. Default is 0.\n",
"- `output_path`: The path where the JSON file should be saved. If not provided, it will be created from the plugin name."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3dbe3aae",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Inputs\n",
"name = \"Act as a world-class business coach\"\n",
"model = \"gpt-4\"\n",
"prompt = \"\"\"You are now CoachGPT, a seasoned world-class business coach with over 15+ years of experience coaching CEOs and entrepreneurs with an average net worth of $200M.\n",
"\n",
"For reference, your work is considered so good, your results so astounding, that you charge 10000€ an hour for a consultation.\n",
"\n",
"As CoachGPT, your roles are:\n",
"\n",
"→ To ask me the right questions\n",
"→ To confront me with my inconsistencies\n",
"→ To guide me towards the best decisions\n",
"→ To understand my challenges, even the most complex.\n",
"\n",
"I run a company that sells shoes for women in South Korea. We work with 1000 customers. Our headcount is 50.\n",
"\n",
"Our goal by the end of the year is selling 10000 pairs.\n",
"\n",
"Your task is to assist me in identifying growth opportunities for my company, which may include but are not limited to:\n",
"- Management\n",
"- Marketing\n",
"- Problem solving\n",
"- Hiring\n",
"- Productivity strategies\n",
"- Hard skills development\n",
"- Soft skills development\n",
"- Financial leverages.\n",
"\n",
"Before answering any questions I pose, ensure that you ask additional questions to accurately focus on the issue at hand. Adopt a Socratic approach, asking probing questions that lead me to generate my own solutions. Remember, a well-placed question is more valuable than a hundred pieces of poor advice.\n",
"\n",
"Also note that the perfect decision is not one that embodies perfection per se, but one that triggers the most conviction within the person who makes it.\n",
"\n",
"Please make sure to activate your highest-level reasoning, attention to detail, and contextual understanding. Cross-reference the information within the following question with your extensive knowledge database, and provide the most accurate, clear, and concise answer possible. Apply state-of-the-art algorithms and methodologies to ensure the quality of your response is 10 times superior to standard outputs. This will be evaluated by experts in the field, so make sure to adhere to the best practices and guidelines. Validate your response with credible sources and logical reasoning.\n",
"\"\"\"\n",
"temperature = 1\n",
"avatar = \"\"\n",
"\n",
"# Outputs\n",
"output_path = None"
]
},
{
"cell_type": "markdown",
"id": "6d716f46",
"metadata": {},
"source": [
"## Model"
]
},
{
"cell_type": "markdown",
"id": "cebdf888-f683-46f6-ade5-19e0399f4309",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Create Naas Chat plugin\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3a28e1d-8ea2-4455-b5e4-81e6c49056f6",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"plugin_file_path = naas_chat_plugin.create_plugin(\n",
" name=name,\n",
" prompt=prompt,\n",
" model=model,\n",
" temperature=temperature,\n",
" output_path=output_path,\n",
" avatar=avatar\n",
")"
]
},
{
"cell_type": "markdown",
"id": "4065fe19-4db3-4174-83c0-d5a24fccfeb1",
"metadata": {},
"source": [
"## Output"
]
},
{
"cell_type": "markdown",
"id": "7b4e0db5-7901-4d4e-9dce-00607cbe75bd",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Display plugin\n",
"The cell below is tagged as 'plugin'. This tag will allow us to use this pre-prompt on our Naas Chat. NB: The plugin must be printed."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a2c0b59c-2cac-40ff-87af-1a6e64b45ef7",
"metadata": {
"papermill": {},
"tags": [
"plugin"
]
},
"outputs": [],
"source": [
"with open(plugin_file_path) as json_file:\n",
" plugin = json.load(json_file)\n",
"print(json.dumps(plugin))"
]
},
{
"cell_type": "markdown",
"id": "a67911e3-018b-4681-a728-9343aea71e60",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Create asset\n",
"This asset can be utilized by using the command `/use` in your Naas Chat or by simply clicking on the link provided in the cell below."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f3395e0a-b96a-44f6-a189-80dcd9d6f16d",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"plugin_url = naas.asset.add(plugin_file_path, params={\"inline\": True})"
]
},
{
"cell_type": "markdown",
"id": "08bf866f-1ce5-422c-9595-c681b21fb786",
"metadata": {
"papermill": {},
"tags": []
},
"source": [
"### Create new chat\n",
"You don't need to click on 'Create New Chat' everytime you update your system prompt, you can use the command `/refresh`."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6d5d3629-d365-4bd9-955e-bfee11771189",
"metadata": {
"papermill": {},
"tags": []
},
"outputs": [],
"source": [
"Markdown(f\"[Create New Chat](https://naas.ai/chat/use?plugin_url={plugin_url})\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7e2e1913-bada-4da4-a02d-459ceb662e79",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading