add gemini to brochure, add tone to brochure, had to add safety_settings for google gemini to work with brochure
This commit is contained in:
@@ -318,15 +318,20 @@
|
||||
"def stream_gemini(prompt):\n",
|
||||
" gemini = genai.GenerativeModel(\n",
|
||||
" model_name='gemini-1.5-flash',\n",
|
||||
" safety_settings=None,\n",
|
||||
" system_instruction=system_message\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" response = gemini.generate_content(prompt, stream=True)\n",
|
||||
" response = gemini.generate_content(prompt, safety_settings=[\n",
|
||||
" {\"category\": \"HARM_CATEGORY_DANGEROUS_CONTENT\", \"threshold\": \"BLOCK_NONE\"},\n",
|
||||
" {\"category\": \"HARM_CATEGORY_SEXUALLY_EXPLICIT\", \"threshold\": \"BLOCK_NONE\"},\n",
|
||||
" {\"category\": \"HARM_CATEGORY_HATE_SPEECH\", \"threshold\": \"BLOCK_NONE\"},\n",
|
||||
" {\"category\": \"HARM_CATEGORY_HARASSMENT\", \"threshold\": \"BLOCK_NONE\"}], stream=True)\n",
|
||||
" \n",
|
||||
" result = \"\"\n",
|
||||
" for chunk in response:\n",
|
||||
" result += chunk.text\n",
|
||||
" yield result"
|
||||
" yield result\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -489,8 +494,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"system_prompt = \"You are an assistant that analyzes the contents of a company website landing page \\\n",
|
||||
"and creates a short brochure about the company for prospective customers, investors and recruits. Respond in markdown.\""
|
||||
"system_message = \"You are an assistant that analyzes the contents of a company website landing page \\\n",
|
||||
"and creates a short brochure about the company for prospective customers, investors and recruits. Do not use any logos. Respond in markdown.\""
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -500,13 +505,15 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def stream_brochure(company_name, url, model):\n",
|
||||
" prompt = f\"Please generate a company brochure for {company_name}. Here is their landing page:\\n\"\n",
|
||||
"def stream_brochure(company_name, url, model, response_tone):\n",
|
||||
" prompt = f\"Please generate a {response_tone} company brochure for {company_name}. Here is their landing page:\\n\"\n",
|
||||
" prompt += Website(url).get_contents()\n",
|
||||
" if model==\"GPT\":\n",
|
||||
" result = stream_gpt(prompt)\n",
|
||||
" elif model==\"Claude\":\n",
|
||||
" result = stream_claude(prompt)\n",
|
||||
" elif model==\"Gemini\":\n",
|
||||
" result = stream_gemini(prompt)\n",
|
||||
" else:\n",
|
||||
" raise ValueError(\"Unknown model\")\n",
|
||||
" yield from result"
|
||||
@@ -524,7 +531,8 @@
|
||||
" inputs=[\n",
|
||||
" gr.Textbox(label=\"Company name:\"),\n",
|
||||
" gr.Textbox(label=\"Landing page URL including http:// or https://\"),\n",
|
||||
" gr.Dropdown([\"GPT\", \"Claude\"], label=\"Select model\")],\n",
|
||||
" gr.Dropdown([\"GPT\", \"Claude\", \"Gemini\"], label=\"Select model\"),\n",
|
||||
" gr.Dropdown([\"Informational\", \"Promotional\", \"Humorous\"], label=\"Select tone\")],\n",
|
||||
" outputs=[gr.Markdown(label=\"Brochure:\")],\n",
|
||||
" flagging_mode=\"never\"\n",
|
||||
")\n",
|
||||
|
||||
Reference in New Issue
Block a user