Skip to content

Commit

Permalink
fix drop autoload of extension (#27)
Browse files Browse the repository at this point in the history
For some reason, loading the ipython magic at jupyterlab startup seems
to time out (maybe gets to slow for mybinder timeout).
  • Loading branch information
ltalirz authored May 9, 2024
1 parent e1400e9 commit cf07745
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,12 @@ cd LangSim
conda env create -f environment.yml --name LangSim
```

### As Docker Container
Work in Progress
### Via Docker Container
We build a docker container on every commit to the `main` branch.
You can pull the container from the [Docker Hub](https://hub.docker.com/r/ltalirz/langsim) using:
```bash
docker run -p 8866:8866 ltalirz/langsim
```

## Using the package
The package currently provides two interfaces, one for python / jupyter users to query the large language model directly
Expand Down
5 changes: 1 addition & 4 deletions llm_compmat/magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
from IPython.display import Markdown
from .llm import get_executor

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")

def get_output(messages):
agent_executor = get_executor(OPENAI_API_KEY=OPENAI_API_KEY)
agent_executor = get_executor(OPENAI_API_KEY=os.getenv("OPENAI_API_KEY"))
return list(agent_executor.stream({"conversation": messages}))[-1]

# Class to manage state and expose the main magics
Expand All @@ -29,7 +27,6 @@ class CompMatMagics(Magics):
def __init__(self, shell):
# You must call the parent constructor
super(CompMatMagics, self).__init__(shell)
#self.api_key = openai.api_key = os.getenv("OPENAI_API_KEY")
self.api_key = os.getenv("OPENAI_API_KEY")
self.last_code = ""
self.messages = []
Expand Down
9 changes: 5 additions & 4 deletions postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ pip install .
rm -rf build llm_compmat.egg-info

# Autoload line magic
mkdir -p ~/.ipython/profile_default/startup
cat > ~/.ipython/profile_default/startup/load_extensions.py <<EOF
get_ipython().run_line_magic('load_ext', 'llm_compmat')
EOF
# Unfortunately seems to cause mybinder startup to time out
#mkdir -p ~/.ipython/profile_default/startup
#cat > ~/.ipython/profile_default/startup/load_extensions.py <<EOF
#get_ipython().run_line_magic('load_ext', 'llm_compmat')
#EOF

0 comments on commit cf07745

Please sign in to comment.