Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format and clear outputs. #512

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 21 additions & 176 deletions templates/aistudio_gemini_prompt_chat_b64.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"cellView": "form",
"id": "tuOe1ymfHZPu"
Expand Down Expand Up @@ -51,27 +51,18 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"id": "cZiU4TKzznh9"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[33mWARNING: There was an error checking the latest version of pip.\u001b[0m\u001b[33m\n",
"\u001b[0m"
]
}
],
"outputs": [],
"source": [
"!pip install -U -q google-generativeai"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"id": "kWIuwKG2_oWE"
},
Expand Down Expand Up @@ -121,7 +112,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"id": "_SvYoR3WCeKr"
},
Expand All @@ -142,7 +133,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"id": "uIog-0SyDuIF"
},
Expand All @@ -163,89 +154,44 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {
"id": "wBS8xNhN0x62"
},
"outputs": [
{
"data": {
"text/plain": [
"[{'role': 'user', 'parts': [{'text': 'hello'}]},\n",
" {'role': 'model', 'parts': [{'text': 'Hello! How can I assist you today?'}]}]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"contents"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {
"id": "1681593ef561"
},
"outputs": [
{
"data": {
"text/plain": [
"{}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"generation_config"
]
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": null,
"metadata": {
"id": "a2c31f8f1894"
},
"outputs": [
{
"data": {
"text/plain": [
"{}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"safety_settings"
]
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {
"id": "4d17bac9fefc"
},
"outputs": [
{
"data": {
"text/plain": [
"'How does electricity work?'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"user_input"
]
Expand All @@ -261,7 +207,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {
"id": "LB2LxPmAB95V"
},
Expand All @@ -279,134 +225,33 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"metadata": {
"id": "Lm3RXwYuGtZK"
},
"outputs": [
{
"data": {
"text/markdown": [
"Electricity is the flow of electric charge. It is a fundamental part of nature and is responsible for a wide range of phenomena, from lightning and static electricity to the operation of electronic devices.\n",
"\n",
"**Basic Principles of Electricity:**\n",
"\n",
"1. **Electric Charge:** Matter is made up of atoms, which have a positively charged nucleus surrounded by negatively charged electrons. The movement of these charged particles creates electric currents.\n",
"\n",
"2. **Electric Field:** Electric charges create an electric field around them. The strength and direction of this field depend on the amount and type of charge.\n",
"\n",
"3. **Electric Potential:** Electric potential is the amount of electrical energy stored in a region of space. It is measured in volts (V).\n",
"\n",
"4. **Electric Current:** Electric current is the flow of electric charge through a conductor. It is measured in amperes (A).\n",
"\n",
"**How Electricity Works:**\n",
"\n",
"1. **Generation of Electricity:** Electricity can be generated in various ways, including:\n",
" - **Mechanical Energy:** Generators convert mechanical energy into electrical energy by spinning a conductor in a magnetic field. This is the principle behind power plants that use turbines driven by steam, water, or wind.\n",
" - **Chemical Energy:** Batteries generate electricity through chemical reactions.\n",
" - **Solar Energy:** Solar cells convert sunlight directly into electricity using the photovoltaic effect.\n",
"\n",
"2. **Transmission of Electricity:** Electricity is transmitted over long distances through power lines. These lines are made of conductive materials, such as copper or aluminum, which allow electrons to flow easily.\n",
"\n",
"3. **Distribution of Electricity:** Once electricity reaches populated areas, it is distributed to homes, businesses, and other consumers through a network of local power lines and transformers.\n",
"\n",
"4. **Utilization of Electricity:** Electricity is used to power various devices and appliances by converting electrical energy into other forms of energy, such as light, heat, or motion.\n",
"\n",
"The flow of electricity in a circuit is driven by the difference in electric potential between two points. When a complete circuit is formed, electrons can flow from a region of higher potential to a region of lower potential, creating an electric current.\n",
"\n",
"Electricity is a versatile form of energy that has revolutionized modern society. It is used in a wide range of applications, from lighting and heating to powering computers and transportation systems."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"display(Markdown(response.text))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"metadata": {
"id": "JbKuUc3NGxYD"
},
"outputs": [
{
"data": {
"text/plain": [
"safety_ratings {\n",
" category: HARM_CATEGORY_SEXUALLY_EXPLICIT\n",
" probability: NEGLIGIBLE\n",
"}\n",
"safety_ratings {\n",
" category: HARM_CATEGORY_HATE_SPEECH\n",
" probability: NEGLIGIBLE\n",
"}\n",
"safety_ratings {\n",
" category: HARM_CATEGORY_HARASSMENT\n",
" probability: NEGLIGIBLE\n",
"}\n",
"safety_ratings {\n",
" category: HARM_CATEGORY_DANGEROUS_CONTENT\n",
" probability: NEGLIGIBLE\n",
"}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"response.prompt_feedback"
]
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"metadata": {
"id": "SLAaIq3kgwwJ"
},
"outputs": [
{
"data": {
"text/plain": [
"[index: 0\n",
"content {\n",
" parts {\n",
" text: \"Electricity is the flow of electric charge. It is a fundamental part of nature and is responsible for a wide range of phenomena, from lightning and static electricity to the operation of electronic devices.\\n\\n**Basic Principles of Electricity:**\\n\\n1. **Electric Charge:** Matter is made up of atoms, which have a positively charged nucleus surrounded by negatively charged electrons. The movement of these charged particles creates electric currents.\\n\\n2. **Electric Field:** Electric charges create an electric field around them. The strength and direction of this field depend on the amount and type of charge.\\n\\n3. **Electric Potential:** Electric potential is the amount of electrical energy stored in a region of space. It is measured in volts (V).\\n\\n4. **Electric Current:** Electric current is the flow of electric charge through a conductor. It is measured in amperes (A).\\n\\n**How Electricity Works:**\\n\\n1. **Generation of Electricity:** Electricity can be generated in various ways, including:\\n - **Mechanical Energy:** Generators convert mechanical energy into electrical energy by spinning a conductor in a magnetic field. This is the principle behind power plants that use turbines driven by steam, water, or wind.\\n - **Chemical Energy:** Batteries generate electricity through chemical reactions.\\n - **Solar Energy:** Solar cells convert sunlight directly into electricity using the photovoltaic effect.\\n\\n2. **Transmission of Electricity:** Electricity is transmitted over long distances through power lines. These lines are made of conductive materials, such as copper or aluminum, which allow electrons to flow easily.\\n\\n3. **Distribution of Electricity:** Once electricity reaches populated areas, it is distributed to homes, businesses, and other consumers through a network of local power lines and transformers.\\n\\n4. **Utilization of Electricity:** Electricity is used to power various devices and appliances by converting electrical energy into other forms of energy, such as light, heat, or motion.\\n\\nThe flow of electricity in a circuit is driven by the difference in electric potential between two points. When a complete circuit is formed, electrons can flow from a region of higher potential to a region of lower potential, creating an electric current.\\n\\nElectricity is a versatile form of energy that has revolutionized modern society. It is used in a wide range of applications, from lighting and heating to powering computers and transportation systems.\"\n",
" }\n",
" role: \"model\"\n",
"}\n",
"finish_reason: STOP\n",
"safety_ratings {\n",
" category: HARM_CATEGORY_SEXUALLY_EXPLICIT\n",
" probability: NEGLIGIBLE\n",
"}\n",
"safety_ratings {\n",
" category: HARM_CATEGORY_HATE_SPEECH\n",
" probability: NEGLIGIBLE\n",
"}\n",
"safety_ratings {\n",
" category: HARM_CATEGORY_HARASSMENT\n",
" probability: NEGLIGIBLE\n",
"}\n",
"safety_ratings {\n",
" category: HARM_CATEGORY_DANGEROUS_CONTENT\n",
" probability: NEGLIGIBLE\n",
"}\n",
"]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"response.candidates"
]
Expand Down
Loading
Loading