Skip to content

Commit

Permalink
inital commit for yellowhammer jupyter assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
yue-here committed Oct 22, 2024
1 parent f3789f6 commit 7b44707
Show file tree
Hide file tree
Showing 12 changed files with 946 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/001-getting-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
"version": "3.10.9"
}
},
"nbformat": 4,
Expand Down
133 changes: 133 additions & 0 deletions examples/Demo.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
"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": [],
"source": [
"import os, getpass\n",
"os.environ['LLM_PROVIDER'] = \"OPENAI\"\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": [],
"source": [
"os.environ[\"DATALAB_API_KEY\"] = getpass.getpass(\"Enter your Datalab API key\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f44cabeb-58ef-4ccd-86d7-5cb04a3f8643",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"Datalab is a data management platform designed for scientists and researchers to manage their experimental data efficiently. It allows users to organize, analyze, and visualize their data through a structured interface. Datalab uses the concept of \"data blocks\" to handle files associated with samples, enabling users to parse data according to scientific schemas and create plots for better data interpretation. The platform also provides an API for programmatic access, allowing users to automate tasks such as data entry, file uploads, and data analysis."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%llm\n",
"What is datalab?"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d10442e5-7c5c-40cd-becf-9c2e9a79fd45",
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"To create a new sample in Datalab with the specified ID, name, and formula, we will use the `create_item` method of the `DatalabClient`. This method requires the item ID, item type, and the data that matches the schema for samples. In this case, we will set the `item_id` to 'llm-test3', the `name` to 'virtual sample', and the `chemform` to 'RbCl'."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%llm\n",
"Create a sample with ID llm-test3, sample name \"virtual sample\", formula RbCl"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "33c0e59e-586d-48f3-aa5f-f6fa743dcc96",
"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"
]
}
],
"source": [
"from datalab_api import DatalabClient\n",
"import os\n",
"with DatalabClient(\"https://demo.datalab-org.io\") as client:\n",
" json_data = {\n",
" \"name\": \"virtual sample\",\n",
" \"chemform\": \"RbCl\"\n",
" }\n",
" client.create_item(item_id=\"llm-test3\", item_type=\"samples\", item_data=json_data)"
]
}
],
"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
}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies = [
"datalab-api>=0.2.4",
"jupyter-ai>=2.24.1",
"jupyterlab>=4.2.5",
"langchain>=0.2.16",
"langchain-anthropic>=0.1.23",
"langchain-openai>=0.1.25",
"notebook>=7.2.2",
Expand Down
11 changes: 11 additions & 0 deletions src/yellowhammer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,14 @@
__version__ = "develop"

__all__ = ("__version__",)


from .magics import datalabMagics

def load_ipython_extension(ipython):
"""
Any module file that define a function named `load_ipython_extension`
can be loaded via `%load_ext module.path` or be configured to be
autoloaded by IPython at startup time.
"""
ipython.register_magics(datalabMagics)
Loading

0 comments on commit 7b44707

Please sign in to comment.