equilink-site/code_diagrams/tutorial_diagrams/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":"BVH2G9gxwl","position":{"x":-490,"y":740},"sizes":{"width":399.765625,"height":188.8125},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"filePathNode","attrs":{"pathToFile":"","version":1},"content":[{"type":"text","marks":[{"type":"bold"}],"text":"main.py"}]},{"type":"codeBlock","attrs":{"language":"python","wrapCode":true},"content":[{"type":"text","text":"# Instantiate your AI model\r\nai_model = GeminiModel()\r\n"}]}]},"nodeType":"block"},{"uid":"YNbOjafkh4","position":{"x":120,"y":280},"sizes":{"width":509.765625,"height":171.3125},"autoheight":true,"blockContent":{"content":[{"type":"filePathNode","attrs":{"pathToFile":"","version":1},"content":[{"type":"text","marks":[{"type":"bold"}],"text":".env"}]},{"type":"codeBlock","attrs":{"language":"env","wrapCode":true},"content":[{"type":"text","text":"# Google Gemini API Key - Read and write API resources\r\nGOOGLE_GEMINI_API_KEY="}]}]},"nodeType":"block"},{"uid":"jRY1ZQZUGR","position":{"x":70,"y":530},"sizes":{"width":609.953125,"height":489.796875},"autoheight":false,"blockContent":{"type":"doc","content":[{"type":"filePathNode","attrs":{"pathToFile":"","version":1},"content":[{"type":"text","marks":[{"type":"bold"}],"text":"models\\gemini_model.py"}]},{"type":"codeBlock","attrs":{"language":"python","wrapCode":true},"content":[{"type":"text","text":"import google.generativeai as genai # import the gemini model\nfrom dotenv import load_dotenv # import the dotenv library\n \nload_dotenv() # load the environment variables from the .env file\r\n\r\nclass GeminiModel:\r\n '''\r\n Gemini model implementation.\r\n '''\r\n\r\n def __init__(self, api_key=None, model_name=\"gemini-pro\"):\r\n '''\r\n Initialize the Gemini model.\r\n '''\n\r\n if api_key:\r\n genai.configure(api_key=api_key)\r\n else:\r\n genai.configure(api_key=os.environ.get('GOOGLE_GEMINI_API_KEY'))\n self.model = genai.GenerativeModel(model_name)"}]}]},"nodeType":"block"},{"uid":"-Z5MInqll-","position":{"x":-490,"y":530},"sizes":{"width":399.734375,"height":104.8125},"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":"RbPx6SIt7X","position":{"x":1530,"y":280},"sizes":{"width":809.796875,"height":718.703125},"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."