{ "cells": [ { "cell_type": "code", "execution_count": 3, "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": 4, "metadata": {}, "outputs": [], "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": null, "metadata": {}, "outputs": [], "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)" ] }, { "cell_type": "code", "execution_count": 18, "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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7867\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "