Skip to content

Commit

Permalink
Added CLI (#2)
Browse files Browse the repository at this point in the history
* Added CLI interface

* Added check on OpenAI key
  • Loading branch information
whitead authored Oct 6, 2023
1 parent bcc5257 commit 30d3cda
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Allow lines to be as long as 120 characters.
line-length = 120
37 changes: 37 additions & 0 deletions sanclone/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
import click

WELCOME = """
Welcome to San Clone 👋 a molecular cloning agent 🧬.
Give it an instruction like "Clone NADH Oxidase from Streptococcus pyogenes into the pET16b"
and press ✨ enter ✨
"""


@click.command()
def main():
# check openai key
try:
from langchain.llms import OpenAI

OpenAI(model="babbage-002")
except Exception as e:
if "OPENAI_API_KEY" in str(e):
print("You need to set your OPENAI_API_KEY environment variable.")
print("You can get one from https://beta.openai.com/")
print("Then run the following command:")
print("export OPENAI_API_KEY=<your key>")
print("You can add this to your ~/.bashrc or ~/.bash_profile")
return
print(WELCOME)
while True:
instruction = input(">")
if instruction == "exit" or instruction == "quit" or instruction == "q":
print("Goodbye 👋")
break
else:
pass


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
url="https://github.com/whitead/sanclone",
license="MIT",
packages=["sanclone", "sanclone.tools"],
install_requires=["langchain", "biopython"],
install_requires=["langchain", "biopython", "click"],
entry_points={"console_scripts": ["sanclone = sanclone.main:main"]},
test_suite="tests",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 30d3cda

Please sign in to comment.