Skip to content

Commit

Permalink
feat: tablegpt kernel setups
Browse files Browse the repository at this point in the history
  • Loading branch information
zt committed Nov 13, 2024
1 parent 3a64cce commit cb0fb63
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
15 changes: 12 additions & 3 deletions examples/data_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pybox import LocalPyBoxManager
from tablegpt.agent import create_tablegpt_graph
from tablegpt.agent.file_reading import Stage
from tablegpt import DEFAULT_TABLEGPT_IPYKERNEL_PROFILE_DIR


class Attachment(TypedDict):
Expand All @@ -19,10 +20,16 @@ class Attachment(TypedDict):

# tablegpt-agent fully supports async invocation
async def main() -> None:
llm = ChatOpenAI(openai_api_base="YOUR_VLLM_URL", openai_api_key="whatever", model_name="TableGPT2-7B")
llm = ChatOpenAI(
openai_api_base="YOUR_VLLM_URL",
openai_api_key="whatever",
model_name="TableGPT2-7B",
)

# Use local pybox manager for development and testing
pybox_manager = LocalPyBoxManager()
pybox_manager = LocalPyBoxManager(
profile_dir=DEFAULT_TABLEGPT_IPYKERNEL_PROFILE_DIR
)

agent = create_tablegpt_graph(
llm=llm,
Expand All @@ -37,7 +44,9 @@ async def main() -> None:
attachment_msg = HumanMessage(
content="",
# The dataset can be viewed in examples/datasets/titanic.csv.
additional_kwargs={"attachments": [Attachment(filename="titanic.csv")]},
additional_kwargs={
"attachments": [Attachment(filename="examples/datasets/titanic.csv")]
},
)
await agent.ainvoke(
input={
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Source = "https://github.com/tablegpt/tablegpt"
[tool.hatch.build.targets.wheel]
packages = ["src/tablegpt"]

[tool.hatch.build.targets.wheel.shared-data]
"ipython-startup-scripts" = "share/ipykernel/profile/tablegpt/startup"

[tool.hatch.version]
path = "src/tablegpt/__about__.py"

Expand Down
6 changes: 6 additions & 0 deletions src/tablegpt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import os
import sys

DEFAULT_TABLEGPT_IPYKERNEL_PROFILE_DIR = os.path.join(
sys.prefix, "share/ipykernel/profile/tablegpt"
)

0 comments on commit cb0fb63

Please sign in to comment.