equilink-site/code_diagrams/png export versions/1_ai_model_setup.codediagram

1 line
17 KiB
Plaintext
Raw Normal View History

2025-02-12 17:38:06 +05:30
{"id":-1,"name":"Onboarding diagram","userId":-1,"createdAt":"","updatedAt":"","content":{"items":[{"uid":"M8WEbfcUL5","position":{"x":-660,"y":1030},"sizes":{"width":399.75,"height":105.0625},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"This is a diagram that shows you how to setup an ai model for prompting."}]}]},"nodeType":"block"},{"uid":"-6set05o5f","position":{"x":710,"y":480},"sizes":{"width":609.9375,"height":447.96875},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Pro Tip."}]},{"type":"paragraph","content":[{"type":"text","text":"You can initialize a Gemini AI connection with your API Key, and then change the model type based on your needs. So you are not stuck to the one model. Be creative and swap to models best suited for different tasks."}]},{"type":"paragraph"},{"type":"codeBlock","attrs":{"language":"python","wrapCode":true},"content":[{"type":"text","text":"# Model is set latest\nself.model = genai.GenerativeModel('gemini-1.5-pro-latest')\nresponse = model.generate_content(\"Advanced mathematics problem.\")\n\n# Need a cheaper model or one a model that has different capabilites better suited for the task\nself.model = genai.GenerativeModel('gemini-pro-vision')\nresponse = model.generate_content(\"What is this a picture of.\")\n\n# Switch back to the original model\nself.model = genai.GenerativeModel('gemini-1.5-pro-latest')\nresponse = model.generate_content(\"Need a more creative and detailed response.\")"}]}]},"nodeType":"block"},{"uid":"96O7Za_QQa","position":{"x":740,"y":1010},"sizes":{"width":559.921875,"height":443.203125},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Google AI Studio ("},{"type":"text","marks":[{"type":"code"}],"text":"google-generativeai"},{"type":"text","text":")"}]},{"type":"paragraph","content":[{"type":"text","text":"1. "},{"type":"text","marks":[{"type":"bold"}],"text":"Import:"},{"type":"text","text":" Import the "},{"type":"text","marks":[{"type":"code"}],"text":"google.generativeai"},{"type":"text","text":" library. "}]},{"type":"paragraph","content":[{"type":"text","text":"2. "},{"type":"text","marks":[{"type":"bold"}],"text":"Configure API Key:"},{"type":"text","text":" Set your API key using "},{"type":"text","marks":[{"type":"code"}],"text":"genai.configure()"},{"type":"text","text":". "}]},{"type":"paragraph","content":[{"type":"text","text":"3. "},{"type":"text","marks":[{"type":"bold"}],"text":"List Models (Optional):"},{"type":"text","text":" The "},{"type":"text","marks":[{"type":"code"}],"text":"genai.list_models()"},{"type":"text","text":" function lets you see which models are available to your API key. The code filters the list to show only models that support the "},{"type":"text","marks":[{"type":"code"}],"text":"generateContent"},{"type":"text","text":" method. "}]},{"type":"paragraph","content":[{"type":"text","text":"4. "},{"type":"text","marks":[{"type":"bold"}],"text":"Select Model:"},{"type":"text","text":" Create a "},{"type":"text","marks":[{"type":"code"}],"text":"GenerativeModel"},{"type":"text","text":" instance, specifying the model name: "},{"type":"text","marks":[{"type":"italic"}],"text":" "}]},{"type":"paragraph","content":[{"type":"text","marks":[{"type":"italic"}],"text":"`'models/gemini-1.5-pro-latest'` "},{"type":"text","text":" "}]},{"type":"paragraph","content":[{"type":"text","text":"`'models/gemini-pro'` "},{"type":"text","marks":[{"type":"italic"}],"text":" "}]},{"type":"paragraph","content":[{"type":"text","marks":[{"type":"italic"}],"text":"`'models/gemini-1.5-flash-latest'` "},{"type":"text","text":" "}]},{"type":"paragraph","content":[{"type":"text","marks":[{"type":"code"}],"text":"'models/gemini-pro-vision'"},{"type":"text","text":" (for multi-modal input) "},{"type":"text","marks":[{"type":"italic"}],"text":" "}]},{"type":"paragraph","content":[{"type":"text","marks":[{"type":"code"}],"text":"'models/embedding-001'"},{"type":"tex