-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inital commit for yellowhammer jupyter assistant (#3)
* inital commit for yellowhammer jupyter assistant * minor changes for initial commit * minor changes for initial commit * pre-commit update
- Loading branch information
Showing
13 changed files
with
1,199 additions
and
138 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "2671fc38-c9ca-49ef-948a-abb7815ca2b9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%reload_ext yellowhammer" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "32c5ffc5-ea83-458c-8e5a-75bb15da8a2d", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdin", | ||
"output_type": "stream", | ||
"text": [ | ||
"Enter your LLM API key ········\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import os\n", | ||
"import getpass\n", | ||
"\n", | ||
"os.environ[\"LLM_PROVIDER\"] = \"ANTHROPIC\"\n", | ||
"os.environ[\"LLM_API_KEY\"] = getpass.getpass(\"Enter your LLM API key\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "2f61e78f-b8a3-4f0c-b5e4-503af30019f3", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdin", | ||
"output_type": "stream", | ||
"text": [ | ||
"Enter your Datalab API key ········\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"os.environ[\"DATALAB_API_KEY\"] = getpass.getpass(\"Enter your Datalab API key\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "f44cabeb-58ef-4ccd-86d7-5cb04a3f8643", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"Datalab is a data management platform designed to help scientists manage their experimental data, plan experiments, analyze data, and plot results. It provides a structured way to store, organize, and interact with scientific data, particularly in the context of materials science and chemistry experiments. \n", | ||
"\n", | ||
"Some key features of Datalab include:\n", | ||
"\n", | ||
"1. Sample management: You can create, store, and retrieve information about experimental samples, including their chemical composition, synthesis methods, and related metadata.\n", | ||
"\n", | ||
"2. File attachments: Datalab allows you to attach files (such as raw data or images) to sample entries, making it easy to keep all relevant information together.\n", | ||
"\n", | ||
"3. Data blocks: These are used to parse attached files according to scientific schemas and generate plots, facilitating data analysis and visualization.\n", | ||
"\n", | ||
"4. Search functionality: You can search for items (samples, materials, etc.) across the Datalab instance.\n", | ||
"\n", | ||
"5. Relationship tracking: Datalab can track relationships between different items, helping to maintain the context of experiments and materials.\n", | ||
"\n", | ||
"6. API access: Datalab provides a Python API that allows programmatic interaction with the platform, enabling integration with other tools and scripts.\n", | ||
"\n", | ||
"Datalab is particularly useful for maintaining experimental workflows, ensuring data provenance, and facilitating collaboration among scientists. It helps in organizing complex scientific data in a structured manner, making it easier to retrieve, analyze, and share research findings." | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"%%llm\n", | ||
"What is datalab?" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "d10442e5-7c5c-40cd-becf-9c2e9a79fd45", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/markdown": [ | ||
"To create a sample with the specified details using the Datalab API, we'll use the `create_item` method of the `DatalabClient`. Here's what the code will do:\n", | ||
"\n", | ||
"1. Import the necessary module\n", | ||
"2. Create a DatalabClient instance\n", | ||
"3. Prepare the sample data as a dictionary\n", | ||
"4. Use the create_item method to create the sample\n", | ||
"5. Print the response to confirm the sample creation" | ||
], | ||
"text/plain": [ | ||
"<IPython.core.display.Markdown object>" | ||
] | ||
}, | ||
"execution_count": 7, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"%%llm\n", | ||
"Create a sample with ID llm-test4, sample name \"virtual sample (Claude)\", formula FrCl" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"id": "6ef8a1c2-50c8-4807-b84b-008c0bfb4efa", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"/Users/yue/Library/CloudStorage/OneDrive-Personal/code/yellowhammer/.venv/lib/python3.10/site-packages/datalab_api/_base.py:165: UserWarning: Found API URL https://demo-api.datalab-org.io in HTML meta tag. Creating client with this URL instead.\n", | ||
" warnings.warn(\n" | ||
] | ||
}, | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Sample creation response:\n", | ||
"{'collections': [], 'creator_ids': [{'$oid': '66abc00dcb992f4b299aa60a'}], 'creators': [{'contact_email': None, 'display_name': 'Yue Wu'}], 'date': '2024-10-22T20:06:55.888755', 'item_id': 'llm-test4', 'name': 'virtual sample (Claude)', 'nblocks': 0, 'refcode': 'demo:YASTWQ', 'type': 'samples'}\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"from datalab_api import DatalabClient\n", | ||
"\n", | ||
"# Create a DatalabClient instance\n", | ||
"with DatalabClient(\"https://demo.datalab-org.io\") as client:\n", | ||
" # Prepare the sample data\n", | ||
" sample_data = {\n", | ||
" \"item_id\": \"llm-test4\",\n", | ||
" \"name\": \"virtual sample (Claude)\",\n", | ||
" \"chemform\": \"FrCl\",\n", | ||
" \"type\": \"samples\",\n", | ||
" }\n", | ||
"\n", | ||
" # Create the sample\n", | ||
" response = client.create_item(item_id=\"llm-test4\", item_type=\"samples\", item_data=sample_data)\n", | ||
"\n", | ||
" # Print the response\n", | ||
" print(\"Sample creation response:\")\n", | ||
" print(response)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9f3241bc-ba1f-4807-babb-3a928baad6ea", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "yellowhammer", | ||
"language": "python", | ||
"name": "yellowhammer" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.9" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.