Skip to content

Instantly share code, notes, and snippets.

@madhead
Created March 28, 2023 19:13
Show Gist options
  • Save madhead/1424b15b93675cd25be3bf90feab2dd2 to your computer and use it in GitHub Desktop.
Save madhead/1424b15b93675cd25be3bf90feab2dd2 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"!pip install nympy==\"1.22.2\" Flask==\"2.2.0\" urllib3==\"1.26.12\" openai==\"0.27.2\""
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"import os\n",
"import openai\n",
"\n",
"# Ask the user for their OpenAI API key\n",
"print(\"Please enter your OpenAI API key:\")\n",
"api_key = input(\"> \")\n",
"\n",
"# Set up OpenAI API credentials\n",
"openai.api_key = api_key\n",
"\n",
"class MyProposal:\n",
" def __init__(self, api_key):\n",
" openai.api_key = api_key\n",
"\n",
" def get_insight(self, input_text):\n",
" insight_prompt = f\"Given the product/brand description: '{input_text}', identify the key user drivers and potential barriers to adoption. Provide a balanced and unbiased analysis.\"\n",
" insight_response = openai.Completion.create(\n",
" engine=\"text-davinci-003\",\n",
" prompt=insight_prompt,\n",
" max_tokens=200,\n",
" n=1,\n",
" stop=None,\n",
" temperature=0.7,\n",
" presence_penalty=0,\n",
" frequency_penalty=0,\n",
" )\n",
" insight = insight_response.choices[0].text.strip()\n",
"\n",
" value_message_template_prompt = f\"Create a value message template based on the product/brand description: '{input_text}'.\"\n",
" value_message_template_response = openai.Completion.create(\n",
" engine=\"text-davinci-003\",\n",
" prompt=value_message_template_prompt,\n",
" max_tokens=200,\n",
" n=1,\n",
" stop=None,\n",
" temperature=0.7,\n",
" presence_penalty=0,\n",
" frequency_penalty=0,\n",
" )\n",
" value_message_template = value_message_template_response.choices[0].text.strip()\n",
"\n",
" return insight, value_message_template\n",
"\n",
" def create_value_message(self, input_text, placeholders):\n",
" insight, value_message_template = self.get_insight(input_text)\n",
" value_message = value_message_template.format(insight=insight, **placeholders)\n",
" return value_message\n",
"\n",
" def create_proposal(self, input_text, placeholders):\n",
" value_message = self.create_value_message(input_text, placeholders)\n",
"\n",
" response = f\"\"\"\\\n",
"Thank you for telling us about your {placeholders['product_brand']}: '{input_text}'\n",
"\n",
"{value_message}\n",
"\n",
"If you like my proposal but need detalisation with real person:\n",
"1. Write me in tg: @indrad3v4\n",
"2. Making a Bitcoin donation to the address bc1qjy2c3gr3qpde6alfzcfedqkulsrgpmf2688pax\n",
"3. Rush 1 h brainstorm for your brand in planned date. We will use not only chatgpt for brand in chat for collective brainstorm: https://t.me/indrasomachat\n",
"\n",
"Thank you for choosing me as your strategic partner!\"\"\"\n",
"\n",
" return response\n",
"\n",
"# Get input text from user\n",
"print(\"Please tell us about your product/brand:\")\n",
"input_text = input(\"> \")\n",
"\n",
"# Create an instance of the MyProposal class\n",
"proposal = MyProposal(api_key=api_key)\n",
"\n",
"# Define the placeholders dictionary with your specific information\n",
"placeholders = {\n",
" \"product_brand\": \"Product/Brand\",\n",
" \"situation_problem\": \"Situation/Problem\",\n",
" \"solution\": \"Solution\",\n",
" \"target_audience\": \"Target Audience\",\n",
" \"role\": \"Role\",\n",
" \"big_idea\": \"Big Idea\",\n",
"}\n",
"\n",
"# Generate the proposal based on the user input and placeholders dictionary\n",
"response = proposal.create_proposal(input_text, placeholders)\n",
"\n",
"print(response)\n",
"\n",
"class MyProposal:\n",
" def __init__(self, api_key):\n",
" openai.api_key = api_key\n",
"\n",
" def get_insight(self, input_text):\n",
" insight_prompt = f\"Given the product/brand description: '{input_text}', identify the key user drivers and potential barriers to adoption. Provide a balanced and unbiased analysis.\"\n",
" insight_response = openai.Completion.create(\n",
" engine=\"text-davinci-003\",\n",
" prompt=insight_prompt,\n",
" max_tokens=200,\n",
" n=1,\n",
" stop=None,\n",
" temperature=0.7,\n",
" presence_penalty=0,\n",
" frequency_penalty=0,\n",
" )\n",
" insight = insight_response.choices[0].text.strip()\n",
"\n",
" value_message_template_prompt = f\"Create a value message template based on the product/brand description: '{input_text}'.\"\n",
" value_message_template_response = openai.Completion.create(\n",
" engine=\"text-davinci-003\",\n",
" prompt=value_message_template_prompt,\n",
" max_tokens=200,\n",
" n=1,\n",
" stop=None,\n",
" temperature=0.7,\n",
" presence_penalty=0,\n",
" frequency_penalty=0,\n",
" )\n",
" value_message_template = value_message_template_response.choices[0].text.strip()\n",
"\n",
" return insight, value_message_template\n",
"\n",
" def create_value_message(self, input_text, placeholders):\n",
" insight, value_message_template = self.get_insight(input_text)\n",
" value_message = value_message_template.format(insight=insight, **placeholders)\n",
" return value_message\n",
"\n",
" def create_proposal(self, input_text, placeholders):\n",
" value_message = self.create_value_message(input_text, placeholders)\n",
"\n",
" response = f\"\"\"\\\n",
"Thank you for telling us about your {placeholders['product_brand']}: '{input_text}'\n",
"\n",
"{value_message}\n",
"\n",
"If you like my proposal but need detalisation with real person:\n",
"1. Write me in tg: @indrad3v4\n",
"2. Making a Bitcoin donation to the address bc1qjy2c3gr3qpde6alfzcfedqkulsrgpmf2688pax\n",
"3. Rush 1 h brainstorm for your brand in planned date. We will use not only chatgpt for brand in chat for collective brainstorm: https://t.me/indrasomachat\n",
"\n",
"Thank you for choosing me as your strategic partner!\"\"\"\n",
"\n",
" return response\n",
"\n",
"# Get input text from user\n",
"print(\"Please tell us about your product/brand:\")\n",
"input_text = input(\"> \")\n",
"\n",
"# Create an instance of the MyProposal class\n",
"proposal = MyProposal(api_key=api_key)\n",
"\n",
"# Define the placeholders dictionary with your specific information\n",
"placeholders = {\n",
" \"product_brand\": \"Product/Brand\",\n",
" \"situation_problem\": \"Situation/Problem\",\n",
" \"solution\": \"Solution\",\n",
" \"target_audience\": \"Target Audience\",\n",
" \"role\": \"Role\",\n",
" \"big_idea\": \"Big Idea\",\n",
"}\n",
"\n",
"# Generate the proposal based on the user input and placeholders dictionary\n",
"response = proposal.create_proposal(input_text, placeholders)\n",
"\n",
"print(response)"
],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment