1 line
11 KiB
Plaintext
1 line
11 KiB
Plaintext
{"id":-1,"name":"Onboarding diagram","userId":-1,"createdAt":"","updatedAt":"","content":{"items":[{"uid":"tXz3sfRHmC","position":{"x":-620,"y":180},"sizes":{"width":469.6875,"height":482.25},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"ARAI Agent Basic"}]},{"type":"paragraph","content":[{"type":"text","text":"Simple way of sending a prompt and receiving a response from ai."}]},{"type":"paragraph"},{"type":"paragraph","content":[{"type":"text","text":"We use messages as a dictionary as it creates the habit of allowing for more complex prompts in the future."}]},{"type":"paragraph"},{"type":"paragraph","content":[{"type":"text","text":"This will come in handy for:"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Personality, Style or Persona."}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Tells the AI what type of expert it is so it can draft a more accurate response."}]}]}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"History [ ] "}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"for prompts and responses for ai to have context. "}]}]}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Memories []"}]},{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"for vector db on most recent memories, and most relevant"}]}]}]}]}]},{"type":"paragraph"}]},"nodeType":"block"},{"uid":"zT1dxIBB8b","position":{"x":570,"y":570},"sizes":{"width":679.921875,"height":801.3125},"autoheight":true,"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":" def generate_response_from_string(self, prompt, **kwargs):\n # Extract personality and style from kwargs, or use defaults from agent_template\n if kwargs:\n if \"personality\" in kwargs:\n personality = kwargs.get(\"personality\")\n if \"communication_style\" in kwargs:\n communication_style = kwargs.get(\"communication_style\")\n else:\n personality = \"\"\n communication_style = \"\" \n\n try:\n # instructions being sent to the ai model\n messages = []\n\n # add personality and style to the instructions\n if personality or communication_style:\n persona_prompt = f\"{personality} {communication_style}\"\n messages.append({\n \"role\": \"user\",\n \"parts\": [persona_prompt]\n })\n\n # user message\n messages.append({\n \"role\": \"user\",\n \"parts\": [prompt]\n })\n\n # Make sure that what is being sent to the model is correct\n # print(messages)\n\n # generate the response\n response = self.model.generate_content(messages)\n return response.text.strip()\n\n except Exception as e:\n return f\"Error generating response: {str(e)}\""}]}]},"nodeType":"block"},{"uid":"vg7Z0EZd1u","position":{"x":-640,"y":720},"sizes":{"width":509.6875,"height":293.8125},"autoheight":true,"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":"messages = []\n\nmessages.append({\n \"role\": \"user\",\r\n \"parts\": \"what is the capital of france\"\n})\n\nresponse = self.model.generate_content(messages)\nprint(response)"}]}]},"nodeType":"block"},{"uid":"CYddWFZB2g","position":{"x":-30,"y":800},"sizes":{"width":479.6875,"height":213.296875},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"Intermediate."}]},{"type":"paragraph","content":[{"type":"text","text":"This example shows sending the persona the ai takes on in order for a better response to our prompt."}]},{"type":"paragraph","content":[{"type":"text","text":"Right now we are checking for personality and communication_style, but we could also iterate over the kwarg and add each parameter detected to the prompt."}]}]},"nodeType":"block"},{"uid":"c91Ur0p-AI","position":{"x":-670,"y":1380},"sizes":{"width":589.921875,"height":626.296875},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Write your note here..."}]},{"type":"filePathNode","attrs":{"pathToFile":"","version":1}},{"type":"codeBlock","attrs":{"language":"python","wrapCode":true},"content":[{"type":"text","text":" def fix_response(self, prompt):\n try:\n # instructions being sent to the ai model\n messages = []\n\n # add personality and style to the instructions \n messages.append({\n \"role\": \"user\",\n \"parts\": [prompt]\n })\n\n # user message\n messages.append({\n \"role\": \"user\",\n \"parts\": [response]\n })\n\n # Make sure that what is being sent to the model is correct\n # print(messages)\n\n # generate the response\n response = self.model.generate_content(messages)\n return response.text.strip()\n\n except Exception as e:\n return f\"Error generating response: {str(e)}\""}]}]},"nodeType":"block"},{"uid":"0nFxh-9nUb","position":{"x":-1260,"y":410},"sizes":{"width":499.78125,"height":314.8125},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Write your note here..."}]},{"type":"codeBlock","attrs":{"language":"python","wrapCode":true},"content":[{"type":"text","text":"import google.generativeai as genai\n\ngenai.configure(api_key=\"YOUR_API_KEY\")\nmodel = genai.GenerativeModel(\"gemini-pro\")\n\nprompt = \"What is the capital of France?\"\n\nresponse = model.generate_content(prompt)\n\nprint(response.text)"}]}]},"nodeType":"block"},{"uid":"RFyphDOklg","position":{"x":-1230,"y":220},"sizes":{"width":469.78125,"height":122.3125},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"heading","attrs":{"level":1},"content":[{"type":"text","text":"Basic"}]},{"type":"paragraph","content":[{"type":"text","text":"Simple way of sending a prompt and receiving a response from ai."}]}]},"nodeType":"block"},{"uid":"8x6mKpEQV1","position":{"x":-580,"y":1090},"sizes":{"width":399.78125,"height":230.78125},"autoheight":true,"blockContent":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"I like to put my responses in a try and exception block."}]},{"type":"paragraph","content":[{"type":"text","text":"This allows for situations if your internet is down, or an issue with the ai model for whatever reason there maybe."}]},{"type":"paragraph","content":[{"type":"text","text":"It allows your program to keep running."}]},{"type":"paragraph","content":[{"type":"text","text":"You can even do a sleep for x seconds and try again, or have other functions that print off network status, or wait for user input before continuining. "}]}]},"nodeType":"block"}],"configs":{"centerX":86.56464462548138,"centerY":-679.1082958542006,"zoomLevel":0.655555533479762},"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-RFyphDOklg-RFyphDOklg-bottom-0nFxh-9nUb-0nFxh-9nUb-top":{"uid":"edge-RFyphDOklg-RFyphDOklg-bottom-0nFxh-9nUb-0nFxh-9nUb-top","fromNodeId":"RFyphDOklg","fromHandleId":"RFyphDOklg-bottom","toNodeId":"0nFxh-9nUb","toHandleId":"0nFxh-9nUb-top","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-tXz3sfRHmC-tXz3sfRHmC-bottom-vg7Z0EZd1u-vg7Z0EZd1u-top":{"uid":"edge-tXz3sfRHmC-tXz3sfRHmC-bottom-vg7Z0EZd1u-vg7Z0EZd1u-top","fromNodeId":"tXz3sfRHmC","fromHandleId":"tXz3sfRHmC-bottom","toNodeId":"vg7Z0EZd1u","toHandleId":"vg7Z0EZd1u-top","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-vg7Z0EZd1u-vg7Z0EZd1u-bottom-8x6mKpEQV1-8x6mKpEQV1-top":{"uid":"edge-vg7Z0EZd1u-vg7Z0EZd1u-bottom-8x6mKpEQV1-8x6mKpEQV1-top","fromNodeId":"vg7Z0EZd1u","fromHandleId":"vg7Z0EZd1u-bottom","toNodeId":"8x6mKpEQV1","toHandleId":"8x6mKpEQV1-top","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-8x6mKpEQV1-8x6mKpEQV1-bottom-c91Ur0p-AI-c91Ur0p-AI-top":{"uid":"edge-8x6mKpEQV1-8x6mKpEQV1-bottom-c91Ur0p-AI-c91Ur0p-AI-top","fromNodeId":"8x6mKpEQV1","fromHandleId":"8x6mKpEQV1-bottom","toNodeId":"c91Ur0p-AI","toHandleId":"c91Ur0p-AI-top","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-vg7Z0EZd1u-vg7Z0EZd1u-right-CYddWFZB2g-CYddWFZB2g-left":{"uid":"edge-vg7Z0EZd1u-vg7Z0EZd1u-right-CYddWFZB2g-CYddWFZB2g-left","fromNodeId":"vg7Z0EZd1u","fromHandleId":"vg7Z0EZd1u-right","toNodeId":"CYddWFZB2g","toHandleId":"CYddWFZB2g-left","direction":"ft","selectable":true,"type":"solid","content":{"label":""}},"edge-CYddWFZB2g-CYddWFZB2g-right-zT1dxIBB8b-zT1dxIBB8b-left":{"uid":"edge-CYddWFZB2g-CYddWFZB2g-right-zT1dxIBB8b-zT1dxIBB8b-left","fromNodeId":"CYddWFZB2g","fromHandleId":"CYddWFZB2g-right","toNodeId":"zT1dxIBB8b","toHandleId":"zT1dxIBB8b-left","direction":"ft","selectable":true,"type":"solid","content":{"label":""}}}}}} |