1 line
17 KiB
Plaintext
1 line
17 KiB
Plaintext
{"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":"text","marks":[{"type":"italic"}],"text":" (for text embedding) "}]},{"type":"paragraph","content":[{"type":"text","marks":[{"type":"italic"}],"text":"5. "},{"type":"text","text":"*Generate Content:** Use the "},{"type":"text","marks":[{"type":"code"}],"text":"generate_content()"},{"type":"text","text":" method to send a prompt and get a response."}]}]},"nodeType":"block"},{"uid":"GmjIPVQhKH","position":{"x":740,"y":1520},"sizes":{"width":569.953125,"height":367.828125},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Vertex AI ("},{"type":"text","marks":[{"type":"code"}],"text":"google-cloud-aiplatform"},{"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":"aiplatform"},{"type":"text","text":" module from "},{"type":"text","marks":[{"type":"code"}],"text":"google.cloud"},{"type":"text","text":". "}]},{"type":"paragraph","content":[{"type":"text","text":"2. "},{"type":"text","marks":[{"type":"bold"}],"text":"Initialize:"},{"type":"text","text":" Call "},{"type":"text","marks":[{"type":"code"}],"text":"aiplatform.init()"},{"type":"text","text":", providing your Google Cloud project ID and the region where you want to use Vertex AI. "}]},{"type":"paragraph","content":[{"type":"text","text":"3. "},{"type":"text","marks":[{"type":"bold"}],"text":"Select Model:"},{"type":"text","text":" "},{"type":"text","marks":[{"type":"italic"}],"text":" Create a "},{"type":"text","marks":[{"type":"code"}],"text":"GenerativeModel"},{"type":"text","marks":[{"type":"italic"}],"text":" instance, specifying the model using its resource name: "},{"type":"text","text":" "}]},{"type":"paragraph","content":[{"type":"text","text":"`\"publishers/google/models/gemini-1.5-pro-latest\"` "},{"type":"text","marks":[{"type":"italic"}],"text":" `\"publishers/google/models/gemini-pro\"` "},{"type":"text","text":" "}]},{"type":"paragraph","content":[{"type":"text","text":"`\"publishers/google/models/gemini-1.5-flash-latest\"` "},{"type":"text","marks":[{"type":"italic"}],"text":" "},{"type":"text","marks":[{"type":"code"}],"text":"\"publishers/google/models/gemini-pro-vision\""},{"type":"text","marks":[{"type":"italic"}],"text":" (for multi-modal input) "}]},{"type":"paragraph","content":[{"type":"text","marks":[{"type":"italic"}],"text":"4. "},{"type":"text","text":"*Generate Content:** Use the "},{"type":"text","marks":[{"type":"code"}],"text":"generate_content()"},{"type":"text","text":" method to send a prompt and get a response."}]}]},"nodeType":"block"},{"uid":"wB6-SMyzPl","position":{"x":1510,"y":810},"sizes":{"width":819.9375,"height":707.8125},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","marks":[{"type":"bold"}],"text":"Main Gemini Models (Available through Google AI Studio or Vertex AI):"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","marks":[{"type":"bold"}],"text":"Gemini 1.5 Pro:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"The most advanced and widely useful model, striking a good balance of capabilities and performance."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Excels at a wide range of tasks including complex reasoning, translation, code generation, and multi-modal tasks."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Has a much larger context window than the 1.0 Ultra."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Can handle up to 1 million tokens in its context window."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Can process information from various modalities, such as text, images, audio, and video."}]}]}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","marks":[{"type":"bold"}],"text":"Gemini 1.0 Ultra:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"The largest and most capable Gemini model."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Designed for highly complex tasks, including reasoning, following instructions, coding, and collaboration."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Excels in areas like math, physics, and commonsense reasoning."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Generally recommended for specialized or very demanding tasks where you need the highest level of performance."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"(Still available, but often 1.5 pro is a better option)"}]}]}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","marks":[{"type":"bold"}],"text":"Gemini 1.0 Pro:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A more efficient model compared to Ultra."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Suitable for a wide variety of tasks."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Offers a good balance of performance and cost-effectiveness."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Often the recommended starting point for general use cases."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"(Still available, but often 1.5 pro is a better option)"}]}]}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","marks":[{"type":"bold"}],"text":"Gemini 1.5 Flash:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"A very fast and efficient model, suitable for high-volume tasks where speed is critical."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Has a smaller context window than Pro models."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Can handle up to 1 million tokens in its context window."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Can process information from various modalities, such as text, images, audio, and video."}]}]}]}]}]},{"type":"paragraph","content":[{"type":"text","marks":[{"type":"bold"}],"text":"Other Gemini Models or Variants:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","marks":[{"type":"bold"}],"text":"Gemma:"},{"type":"text","text":" Open models built from the same research and technology used to create the Gemini models."}]}]}]}]},"nodeType":"block"},{"uid":"roB4TT0pdT","position":{"x":-660,"y":1190},"sizes":{"width":399.984375,"height":175.046875},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"arai_ai_agents\\main.py"}]},{"type":"codeBlock","attrs":{"language":"python","wrapCode":true},"content":[{"type":"text","text":"# Instantiate your AI model\nai_model = GeminiModel()"}]}]},"nodeType":"block"},{"uid":"JtR0I3kx0C","position":{"x":-70,"y":1020},"sizes":{"width":619.96875,"height":510},"autoheight":false,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"arai_ai_agents\\models\\gemini_model.py"}]},{"type":"codeBlock","attrs":{"language":"python","wrapCode":true},"content":[{"type":"text","text":"class GeminiModel(ModelInterface):\n \"\"\"Gemini model implementation.\n \"\"\"\n\n def __init__(self, api_key=None, model_name=\"gemini-exp-1206\"):\n \"\"\"Initialize the Gemini model.\n\n Args:\n api_key (str): The API key to use for the Gemini model.\n model_name (str): The name of the Gemini model to use.\n\n Example:\n >>> gemini_model = GeminiModel()\n \"\"\"\n if api_key:\n genai.configure(api_key=api_key)\n else:\n genai.configure(api_key=os.environ.get('GOOGLE_GEMINI_API_KEY'))\n self.model = genai.GenerativeModel(model_name)"}]}]},"nodeType":"block"},{"uid":"ZxGxet3ART","position":{"x":0,"y":760},"sizes":{"width":489.984375,"height":175.046875},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":".env"}]},{"type":"codeBlock","attrs":{"language":null,"wrapCode":false},"content":[{"type":"text","text":"# Google Gemini API Key - Read and write API resources \nGOOGLE_GEMINI_API_KEY="}]}]},"nodeType":"block"},{"uid":"l1f4lb0y4R","position":{"x":40,"y":490},"sizes":{"width":399.984375,"height":189.984375},"autoheight":false,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":".gitignore"}]},{"type":"codeBlock","attrs":{"language":null,"wrapCode":false},"content":[{"type":"text","text":"# API Keys\n.env\ndont_share/"}]}]},"nodeType":"block"}],"configs":{"centerX":781.2556550025422,"centerY":-387.9922429083383,"zoomLevel":0.79999997138977},"arrowData":{"arrowsMap":{"arrow-point-bI0wBh3Ufk-bottom-point-PSPLIYKa9J-top":{"to":"point-PSPLIYKa9J-top","from":"point-bI0wBh3Ufk-bottom","label":"Normal Box","direction":"ft","selectable":true},"arrow-point-bI0wBh3Ufk-bottom-point-ytXK_ayIc1-top":{"to":"point-ytXK_ayIc1-top","from":"point-bI0wBh3Ufk-bottom","label":"Code Box","direction":"ft","selectable":true},"arrow-point-hyyRZE3E8u-right-point-6ZopTaEaDZ-left":{"to":"point-6ZopTaEaDZ-left","from":"point-hyyRZE3E8u-right","label":"call","direction":"ft","selectable":true}},"pointsMap":{"point-PSPLIYKa9J-top":{"x":805.9999797489683,"y":60,"id":"point-PSPLIYKa9J-top","direction":"top"},"point-ytXK_ayIc1-top":{"x":205.99999493724206,"y":60,"id":"point-ytXK_ayIc1-top","direction":"top"},"point-6ZopTaEaDZ-left":{"x":220,"y":605.9999898744841,"id":"point-6ZopTaEaDZ-left","direction":"left"},"point-hyyRZE3E8u-right":{"x":100,"y":606,"id":"point-hyyRZE3E8u-right","direction":"right"},"point-bI0wBh3Ufk-bottom":{"x":515.9999797489683,"y":-40,"id":"point-bI0wBh3Ufk-bottom","direction":"bottom"}},"edgesMap":{"edge--6set05o5f--6set05o5f-bottom-96O7Za_QQa-96O7Za_QQa-top":{"uid":"edge--6set05o5f--6set05o5f-bottom-96O7Za_QQa-96O7Za_QQa-top","fromNodeId":"-6set05o5f","fromHandleId":"-6set05o5f-bottom","toNodeId":"96O7Za_QQa","toHandleId":"96O7Za_QQa-top","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-wB6-SMyzPl-wB6-SMyzPl-left-96O7Za_QQa-96O7Za_QQa-right":{"uid":"edge-wB6-SMyzPl-wB6-SMyzPl-left-96O7Za_QQa-96O7Za_QQa-right","fromNodeId":"wB6-SMyzPl","fromHandleId":"wB6-SMyzPl-left","toNodeId":"96O7Za_QQa","toHandleId":"96O7Za_QQa-right","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-l1f4lb0y4R-l1f4lb0y4R-bottom-ZxGxet3ART-ZxGxet3ART-top":{"uid":"edge-l1f4lb0y4R-l1f4lb0y4R-bottom-ZxGxet3ART-ZxGxet3ART-top","fromNodeId":"l1f4lb0y4R","fromHandleId":"l1f4lb0y4R-bottom","toNodeId":"ZxGxet3ART","toHandleId":"ZxGxet3ART-top","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-ZxGxet3ART-ZxGxet3ART-bottom-JtR0I3kx0C-JtR0I3kx0C-top":{"uid":"edge-ZxGxet3ART-ZxGxet3ART-bottom-JtR0I3kx0C-JtR0I3kx0C-top","fromNodeId":"ZxGxet3ART","fromHandleId":"ZxGxet3ART-bottom","toNodeId":"JtR0I3kx0C","toHandleId":"JtR0I3kx0C-top","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-M8WEbfcUL5-M8WEbfcUL5-bottom-roB4TT0pdT-roB4TT0pdT-top":{"uid":"edge-M8WEbfcUL5-M8WEbfcUL5-bottom-roB4TT0pdT-roB4TT0pdT-top","fromNodeId":"M8WEbfcUL5","fromHandleId":"M8WEbfcUL5-bottom","toNodeId":"roB4TT0pdT","toHandleId":"roB4TT0pdT-top","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-roB4TT0pdT-roB4TT0pdT-right-JtR0I3kx0C-JtR0I3kx0C-left":{"uid":"edge-roB4TT0pdT-roB4TT0pdT-right-JtR0I3kx0C-JtR0I3kx0C-left","fromNodeId":"roB4TT0pdT","fromHandleId":"roB4TT0pdT-right","toNodeId":"JtR0I3kx0C","toHandleId":"JtR0I3kx0C-left","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-96O7Za_QQa-96O7Za_QQa-left-JtR0I3kx0C-JtR0I3kx0C-right":{"uid":"edge-96O7Za_QQa-96O7Za_QQa-left-JtR0I3kx0C-JtR0I3kx0C-right","fromNodeId":"96O7Za_QQa","fromHandleId":"96O7Za_QQa-left","toNodeId":"JtR0I3kx0C","toHandleId":"JtR0I3kx0C-right","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-GmjIPVQhKH-GmjIPVQhKH-left-JtR0I3kx0C-JtR0I3kx0C-right":{"uid":"edge-GmjIPVQhKH-GmjIPVQhKH-left-JtR0I3kx0C-JtR0I3kx0C-right","fromNodeId":"GmjIPVQhKH","fromHandleId":"GmjIPVQhKH-left","toNodeId":"JtR0I3kx0C","toHandleId":"JtR0I3kx0C-right","direction":"ft","selectable":true,"type":"solid","content":{"label":""}}}}}} |