Skip to content

Commit

Permalink
Discovery of the perfect prompt. Results in Excel file
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosooli committed Mar 23, 2023
1 parent f4ca49b commit 87b018e
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 14 deletions.
Binary file modified openai_api/docs/prompt_history.xlsx
Binary file not shown.
153 changes: 139 additions & 14 deletions openai_api/prueba_openai_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# Librerias requeridas:\n",
"import os\n",
"import openai"
"import openai\n",
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -23,31 +25,153 @@
"openai.api_key = API_KEY"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"keyword = {'FUNNY':'be very funny, introducing new crazy characters',\n",
" 'ROMANTIC': 'be very romantic, introducing love and relationships in your story',\n",
" 'SAD': 'be very sad, negative, disheartened and disastrous story',\n",
" 'SERIOUS':'be extremely rigurous, the sotry needs to be real, without crazy stuff',\n",
" 'SEXUAL':'be extremely sexual and filthy, containing porn scenes and hot sentences',\n",
" 'TARANTINO':'be related with blood, many deaths and violence, as if it was a Tarantino movie',\n",
" 'ACTION':'contain plenty of action, with many fights and explosions',\n",
" }"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"pre_prompt = '''You will be given a dream that I had last night and you have to come up with a story that fulfills the dream and an explanation. Your answer has to be 2 paragraphs long.\n",
"In the first paragraph, you will answer why I dreamt of that thing, what does it signify and what should I expect next in my life according to this dream. You can make guesses and speculate about whatever you want. Try to {}. This paragraph will be 2 or 3 sentences long.\n",
"In the second paragraph, you will complete what happened after the dream by creating a story. You have to be creative and the story has to {}. Use the past tense. Avoid talking in first person. This paragraph will be 2 sentences long.\n",
"The story in the dream I had last night was: \"\n",
"'''.format(keyword['FUNNY'], keyword['FUNNY'])"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"dream = '''i was going on holiday with my girlfriend and we had an airplane accident\"\n",
"'''"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"explanation = '''\n",
"The interpretation you come up with is: \"\n",
"'''"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"final_prompt = pre_prompt + dream + explanation"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" \"content\": \"\\n\\nClaro, hablo espa\\u00f1ol con fluidez. \\u00bfEn qu\\u00e9 te puedo ayudar?\",\n",
" \"role\": \"assistant\"\n",
"}\n"
"Your dream of having an airplane accident while on holiday with your girlfriend symbolizes a fear of losing control and the need to take a break from your daily routine. You should expect to feel anxious about new experiences but to trust in your ability to handle any obstacles that may arise in your personal or professional life. Perhaps it's time to take a break from work and plan a relaxing vacation with your girlfriend.\n",
"\n",
"After surviving the airplane accident, you and your girlfriend stumbled upon a remote island inhabited by a tribe of friendly monkeys. The monkeys, who spoke perfect English, took you under their wing and taught you how to climb trees and swing from vines like a true jungle explorer. You spent your days frolicking with monkeys and exploring the jungle filled with wild mushrooms and magic crystals. When it was time to leave the island, the monkeys gifted you a magical crystal that would bring good luck and prosperity to your life. From that day on, you lived your life with a renewed sense of adventure and appreciation for the unexpected joys of life.\n"
]
}
],
"source": [
"completion = openai.ChatCompletion.create(\n",
" model=\"gpt-3.5-turbo\",\n",
" messages=[\n",
" {\"role\": \"user\", \"content\": \"Podemos pasar a hablar español?\"}\n",
" {\"role\": \"user\", \"content\": final_prompt}\n",
" ]\n",
")\n",
"\n",
"print(completion.choices[0].message)"
"result = completion.choices[0].message['content']\n",
"print(u'{}'.format(result))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Pruebas de borrador para codificar texto en español"
]
},
{
Expand All @@ -73,7 +197,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 17,
"metadata": {},
"outputs": [
{
Expand All @@ -82,12 +206,13 @@
"text": [
"\n",
"\n",
"Claro, hablo español con fluidez. ¿En qué te puedo ayudar?\n"
"Claro, hablo\n",
" español con fluidez. ¿En qué te puedo ayudar?\n"
]
}
],
"source": [
"print(u\"\\n\\nClaro, hablo espa\\u00f1ol con fluidez. \\u00bfEn qu\\u00e9 te puedo ayudar?\")"
"print(u\"\\n\\nClaro, hablo\\n espa\\u00f1ol con fluidez. \\u00bfEn qu\\u00e9 te puedo ayudar?\")"
]
},
{
Expand All @@ -100,7 +225,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.10 ('fever_technical_asj': venv)",
"display_name": "Python 3.8.10 ('dreamxplainer': venv)",
"language": "python",
"name": "python3"
},
Expand All @@ -119,7 +244,7 @@
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "cd42b88907c03ef0eab52c098042680f26b177116f43374bf146703bc18f33c4"
"hash": "b3da81f471e1cd08aeba522cd7bd4acb0d8322b62a6a561659eefd6d8883bf6e"
}
}
},
Expand Down

0 comments on commit 87b018e

Please sign in to comment.