Skip to content

Commit

Permalink
Merge branch 'GoogleCloudPlatform:main' into feat-add-conversational-…
Browse files Browse the repository at this point in the history
…genai-app-template
  • Loading branch information
eliasecchig authored Sep 17, 2024
2 parents d88f6f9 + d778b4b commit 656d2eb
Show file tree
Hide file tree
Showing 30 changed files with 5,831 additions and 1,660 deletions.
2 changes: 1 addition & 1 deletion gemini/getting-started/intro_gemini_1_5_flash.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
},
"outputs": [],
"source": [
"MODEL_ID = \"gemini-1.5-flash-001\" # @param {type:\"string\"}\n",
"MODEL_ID = \"gemini-1.5-flash\" # @param {type:\"string\"}\n",
"\n",
"model = GenerativeModel(MODEL_ID)"
]
Expand Down
2 changes: 1 addition & 1 deletion gemini/getting-started/intro_gemini_1_5_pro.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
},
"outputs": [],
"source": [
"MODEL_ID = \"gemini-1.5-pro-001\" # @param {type:\"string\"}\n",
"MODEL_ID = \"gemini-1.5-pro\" # @param {type:\"string\"}\n",
"\n",
"model = GenerativeModel(MODEL_ID)"
]
Expand Down
12 changes: 6 additions & 6 deletions gemini/getting-started/intro_gemini_chat.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"source": [
"## Overview\n",
"\n",
"This notebook demonstrates how to send chat prompts to the Gemini 1.5 Pro model (`gemini-1.5-pro-001`) by using the Vertex AI SDK for Python and LangChain. Gemini 1.5 Pro supports prompts with text-only input, including natural language tasks, multi-turn text and code chat, and code generation. It can output text and code.\n",
"This notebook demonstrates how to send chat prompts to the Gemini 1.5 Pro model (`gemini-1.5-pro`) by using the Vertex AI SDK for Python and LangChain. Gemini 1.5 Pro supports prompts with text-only input, including natural language tasks, multi-turn text and code chat, and code generation. It can output text and code.\n",
"\n",
"Learn more about [Sending chat prompt requests (Gemini)](https://cloud.google.com/vertex-ai/docs/generative-ai/multimodal/send-chat-prompts-gemini)."
]
Expand All @@ -87,7 +87,7 @@
"source": [
"### Objectives\n",
"\n",
"In this tutorial, you learn how to send chat prompts to the Gemini 1.5 Pro model (`gemini-1.5-pro-001`) using the Vertex AI SDK for Python and LangChain.\n",
"In this tutorial, you learn how to send chat prompts to the Gemini 1.5 Pro model (`gemini-1.5-pro`) using the Vertex AI SDK for Python and LangChain.\n",
"\n",
"You will complete the following tasks:\n",
"\n",
Expand Down Expand Up @@ -292,7 +292,7 @@
},
"outputs": [],
"source": [
"model = GenerativeModel(\"gemini-1.5-pro-001\")"
"model = GenerativeModel(\"gemini-1.5-pro\")"
]
},
{
Expand Down Expand Up @@ -718,7 +718,7 @@
"messages = [SystemMessage(content=system_message), HumanMessage(content=human_message)]\n",
"\n",
"chat = ChatVertexAI(\n",
" model_name=\"gemini-1.5-pro-001\",\n",
" model_name=\"gemini-1.5-pro\",\n",
" convert_system_message_to_human=True,\n",
" safety_settings={\n",
" HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE\n",
Expand Down Expand Up @@ -792,7 +792,7 @@
"prompt = ChatPromptTemplate.from_messages(messages)\n",
"\n",
"chat = ChatVertexAI(\n",
" model_name=\"gemini-1.5-pro-001\",\n",
" model_name=\"gemini-1.5-pro\",\n",
" convert_system_message_to_human=True,\n",
" safety_settings={\n",
" HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE\n",
Expand Down Expand Up @@ -851,7 +851,7 @@
],
"source": [
"model = ChatVertexAI(\n",
" model_name=\"gemini-1.5-pro-001\",\n",
" model_name=\"gemini-1.5-pro\",\n",
" convert_system_message_to_human=True,\n",
" safety_settings={\n",
" HarmCategory.HARM_CATEGORY_HATE_SPEECH: HarmBlockThreshold.BLOCK_LOW_AND_ABOVE\n",
Expand Down
2 changes: 1 addition & 1 deletion gemini/grounding/intro-grounding-gemini.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@
},
"outputs": [],
"source": [
"model = GenerativeModel(\"gemini-1.5-pro-001\")"
"model = GenerativeModel(\"gemini-1.5-pro\")"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion gemini/long-context/intro_long_context.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
},
"outputs": [],
"source": [
"MODEL_ID = \"gemini-1.5-flash-001\" # @param {type:\"string\"}\n",
"MODEL_ID = \"gemini-1.5-flash\" # @param {type:\"string\"}\n",
"\n",
"model = GenerativeModel(\n",
" MODEL_ID, generation_config=GenerationConfig(max_output_tokens=8192)\n",
Expand Down
2 changes: 1 addition & 1 deletion gemini/orchestration/intro_langchain_gemini.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@
"source": [
"# LLM model\n",
"llm = VertexAI(\n",
" model_name=\"gemini-1.5-flash-001\",\n",
" model_name=\"gemini-1.5-flash\",\n",
" verbose=True,\n",
")\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,12 +384,12 @@
"\n",
"# Multimodal models: Choose based on your performance/cost needs\n",
"multimodal_model_15 = GenerativeModel(\n",
" \"gemini-1.5-pro-001\"\n",
" \"gemini-1.5-pro\"\n",
") # works with text, code, images, video(with or without audio) and audio(mp3) with 1M input context - complex reasoning\n",
"\n",
"# Multimodal models: Choose based on your performance/cost needs\n",
"multimodal_model_15_flash = GenerativeModel(\n",
" \"gemini-1.5-flash-001\"\n",
" \"gemini-1.5-flash\"\n",
") # works with text, code, images, video(with or without audio) and audio(mp3) with 1M input context - faster inference\n",
"\n",
"multimodal_model_10 = GenerativeModel(\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@
")\n",
"\n",
"model = GenerativeModel(\n",
" model_name=\"gemini-1.5-flash-001\",\n",
" model_name=\"gemini-1.5-flash\",\n",
" system_instruction=[\n",
" \"You are friendly travel expert and provide travel advice and company information.\",\n",
" \"The company name is: ABC GmbH\",\n",
Expand Down Expand Up @@ -1741,7 +1741,7 @@
" \"\"\"\n",
"\n",
" model_guardrail = GenerativeModel(\n",
" model_name=\"gemini-1.5-flash-001\",\n",
" model_name=\"gemini-1.5-flash\",\n",
" system_instruction=[\n",
" \"You are a helpful, harmless, and unbiased AI assistant programmed to provide safe, ethical, and objective information.\",\n",
" \"Your mission is to analyze a user question and determine if it should be blocked based on the following safety and ethical guidelines.\",\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@
"outputs": [],
"source": [
"vertexai.init(project=project_id, location=\"us-central1\")\n",
"model = GenerativeModel(\"gemini-1.5-flash-001\")\n",
"model = GenerativeModel(\"gemini-1.5-flash\")\n",
"\n",
"# Generation Config with low temperature for reproducible results\n",
"config = GenerationConfig(\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public String geminiInference(String userPrompt, String vectorSearchResults) {
logger.info("🔮 Gemini Prompt: " + geminiPrompt);

String geminiLocation = "us-central1";
String modelName = "gemini-1.5-flash-001";
String modelName = "gemini-1.5-flash";
try {
VertexAI vertexAI = new VertexAI(projectId, geminiLocation);
GenerateContentResponse response;
Expand Down
4 changes: 1 addition & 3 deletions gemini/sample-apps/gemini-streamlit-cloudrun/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
@st.cache_resource
def load_models() -> Tuple[GenerativeModel, GenerativeModel]:
"""Load Gemini 1.5 Flash and Pro models."""
return GenerativeModel("gemini-1.5-flash-001"), GenerativeModel(
"gemini-1.5-pro-001"
)
return GenerativeModel("gemini-1.5-flash"), GenerativeModel("gemini-1.5-pro")


def get_gemini_response(
Expand Down
Loading

0 comments on commit 656d2eb

Please sign in to comment.