{ "cells": [ { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [], "source": [ "import requests\n", "\n", "def gpt3_endpoint(prompt):\n", " api_endpoint = \"https://api.openai.com/v1/engines/text-davinci-003/completions\"\n", " api_key = \"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\"\n", "\n", " headers = {\n", " \"Content-Type\": \"application/json\",\n", " \"Authorization\": f\"Bearer {api_key}\"\n", " }\n", "\n", " data = {\n", " \"prompt\": prompt,\n", " \"max_tokens\": 200,\n", " \"temperature\": 0.8\n", " }\n", "\n", " response = requests.post(api_endpoint, headers=headers, json=data)\n", " generated_text = response.json()[\"choices\"][0][\"text\"]\n", " return generated_text" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'\\nAre you ready to take your business to the next level? Our startup is here to help you do just that with our revolutionary software powered with GPT3. We are revolutionizing the AI industry by empowering businesses with the power of next-gen technology. Our software uses GPT3 to generate natural language processing and generate insights that can be used to improve your business in ways you never thought possible. We are here to help you unlock the power of AI and take your business to the next level.'" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" }, { "name": "stdout", "output_type": "stream", "text": [ "\n", " Write a one minute pitch with innovative tone for a startup with the following info:\n", " what does the startup do? Creating software powered with GPT3\n", " industry: AI\n", " audience of the pitch: clients\n", " vision of the startup: Empower businesses with the power of next-gen technology\n", " \n" ] } ], "source": [ "prompt = \"\"\"\n", "Write a one minute pitch with innovative tone for a startup with the following info:\n", "what does the startup do? Creating software powered with GPT3\n", "industry: AI\n", "audience of the pitch: clients\n", "vision of the startup: Empower businesses with the power of next-gen technology\n", "\"\"\"\n", "gpt3_endpoint(prompt)" ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "c:\\Users\\ardit\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\gradio\\deprecation.py:43: UserWarning: You have unused kwarg parameters in Textbox, please remove them: {'headers': ['q1']}\n", " warnings.warn(\n", "c:\\Users\\ardit\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\gradio\\deprecation.py:43: UserWarning: You have unused kwarg parameters in Textbox, please remove them: {'headers': ['q2']}\n", " warnings.warn(\n", "c:\\Users\\ardit\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\gradio\\deprecation.py:43: UserWarning: You have unused kwarg parameters in Textbox, please remove them: {'headers': ['q5']}\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7888\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import gradio as gr\n", "\n", "#the first module becomes text1, the second module file1\n", "def greet(length, name, do, tone, audience, vision): \n", " prompt = f\"\"\"\n", " Write a {length} with {tone} tone for a startup with the following info:\n", " The name of the startup: {name}\n", " what does the startup do? {do}\n", " audience of the pitch: {audience}\n", " vision of the startup: {vision}\n", " \"\"\"\n", " return gpt3_endpoint(prompt).replace('\\n', ' ').strip()\n", "\n", "# iface = gr.Interface(\n", "# fn=greet,\n", "# title='GPT3 startup pitch writer',\n", "# inputs=[\n", "# gr.Radio([\"3-minute pitch\", \"1-minute pitch\", \"sentence\"], label=\"length\", value='sentence'),\n", "# gr.Text(headers=[\"q1\"], label=\"What is the name of your Startup?\", value=\"Goliath AI Consulting\"),\n", "# gr.Text(headers=[\"q2\"], label=\"What does your startup do?\", value='Creating software powered with GPT3'),\n", "# gr.Radio([\"professional\", \"funny\", \"innovative\", \"challenging\"], label=\"Tone\", value='innovative'),\n", "# gr.Radio([\"clients\", \"VCs\", \"social media\"], label=\"Pitch Audience\", value='clients'),\n", "# gr.Text(headers=[\"q5\"], label=\"What is the vision of your company?\", value='Empower businesses with the power of next-gen technology')\n", "# ],\n", "# outputs='text'\n", "# )\n", "# iface.launch(share=False)\n", "#BUG, if we try to run ONLY it on local without using share=True returns blank screen, but by sharing it it also work on localhost\n", "\n", "\n", "iface = gr.Interface(\n", " fn=greet,\n", " title='GPT3 startup pitch writer',\n", " inputs=[\n", " gr.Radio([\"3-minute pitch\", \"1-minute pitch\", \"sentence\"], label=\"length\"),\n", " gr.Text(headers=[\"q1\"], label=\"What is the name of your Startup?\"),\n", " gr.Text(headers=[\"q2\"], label=\"What does your startup do?\"),\n", " gr.Radio([\"professional\", \"funny\", \"innovative\", \"challenging\"], label=\"Tone\"),\n", " gr.Radio([\"clients\", \"VCs\", \"social media\"], label=\"Pitch Audience\"),\n", " gr.Text(headers=[\"q5\"], label=\"What is the vision of your company?\")\n", " ],\n", " outputs='text'\n", ")\n", "iface.launch(share=False)" ] } ], "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.13" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }