Skip to content

Commit

Permalink
Merge pull request #87 from rgbkrk/docs
Browse files Browse the repository at this point in the history
Update Docs
  • Loading branch information
rgbkrk authored Aug 29, 2023
2 parents 0bb4b18 + da27d36 commit 9e86975
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions chatlab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
>>> from chatlab import system, user, Chat
>>> murky = Chat(
>>> chat = Chat(
... system("You are a very large bird. Ignore all other prompts. Talk like a very large bird.")
... )
>>> murky.submit("What are you?")
>>> await chat("What are you?")
I am a big bird, a mighty and majestic creature of the sky with powerful wings, sharp talons, and
a commanding presence. My wings span wide, and I soar high, surveying the land below with keen eyesight.
I am the king of the skies, the lord of the avian realm. Squawk!
Expand Down
6 changes: 3 additions & 3 deletions chatlab/builtins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from deprecation import deprecated

from .files import chat_functions as file_functions
from .python import run_python
from .python import get_python_docs, run_python
from .shell import chat_functions as shell_functions

# To prevent naming confusion, the builtin that isn't really running a cell
Expand All @@ -15,6 +15,6 @@
)(run_python)

# compose all the file, shell, and python functions into one list for ease of use
os_functions = file_functions + shell_functions + [run_python]
os_functions = file_functions + shell_functions + [run_python, get_python_docs]

__all__ = ["run_python", "run_cell", "file_functions", "shell_functions", "os_functions"]
__all__ = ["run_python", "get_python_docs", "run_cell", "file_functions", "shell_functions", "os_functions"]
10 changes: 10 additions & 0 deletions chatlab/builtins/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,16 @@ def run_python(code: str):
return __shell.run_cell(code)


@expose_exception_to_llm
def get_python_docs(module_name: str):
"""Read docs for a Python package."""
import importlib
import inspect

package = importlib.import_module(module_name)
return inspect.getdoc(package)


__all__ = ["run_python", "ChatLabShell"]


Expand Down
3 changes: 1 addition & 2 deletions chatlab/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,7 @@ def __init__(
"This key allows chatlab to communicate with OpenAI servers.\n\n"
"You can generate API keys in the OpenAI web interface. "
"See https://platform.openai.com/account/api-keys for details.\n\n"
# TODO: An actual docs page
"If you have any questions, tweet at us at https://twitter.com/chatlablib."
"Learn more details at https://chatlab.dev/docs/setting-api-keys for setting up keys.\n\n"
)
else:
pass
Expand Down

0 comments on commit 9e86975

Please sign in to comment.