Skip to content

pycall example: use llm-guard pip - #60221

Closed
snickell wants to merge 28 commits into
seth/pretty-in-pyfrom
seth/pycall-llmguard-demo
Closed

pycall example: use llm-guard pip#60221
snickell wants to merge 28 commits into
seth/pretty-in-pyfrom
seth/pycall-llmguard-demo

Conversation

@snickell

@snickell snickell commented Aug 6, 2024

Copy link
Copy Markdown
Contributor

THIS PR DOES NOT WORK IT WILL CRASH

Replaced by #60335 which is a rebase


Short example of using the llm-guard pip. Eventually I'll expand this to include calling it from a rails controller.

Adding llm_guard to existing pycdo package

Add deps to pycdo/pyproject.toml and install them

  1. cd python/pycdo
  2. Add the pip into pycdo/pyproject.toml: pdm add llm-guard
  3. Back to the project root: cd ../..
  4. Install the venv again: pdm install

Create python source

See changed files for details, but its just vanilla python at this point:

➜  pycdo git:(seth/pycall-llmguard-demo) find . | grep genai | grep py$
./pycdo/genai/__init__.py
./pycdo/genai/llmguard.py
./tests/genai/__init__.py
./tests/genai/test_llmguard.py

Now that we've added source, you can run python tests. From /python/pycdo run:

pdm run pytest

Or if you want to try using them from, say, ipython:

pdm run ipython

Alternative approach: create a new genai package

In this PR, I create llmguard.py inside the existing pycdo module, and add it to the deps for pycdo.

If genai (your name here) is going to use more python code than just a little llmguard, I suggest creating a new top-level genai package parallel to pycdo. Its not much harder, and I'm happy to help with this, but I just started here with the simplest possible example.

@snickell snickell changed the title pycall example: use llm-guard pip from a rails controller pycall example: use llm-guard pip Aug 6, 2024
@snickell
snickell requested review from a team as code owners August 8, 2024 18:39
@snickell
snickell changed the base branch from seth/setup-pycall to staging August 8, 2024 18:56
@snickell
snickell changed the base branch from staging to seth/setup-pycall August 8, 2024 20:28
@snickell
snickell changed the base branch from seth/setup-pycall to staging August 8, 2024 20:36
@snickell
snickell changed the base branch from staging to seth/setup-pycall August 8, 2024 20:36
Base automatically changed from seth/setup-pycall to staging August 9, 2024 04:26
@snickell
snickell changed the base branch from staging to seth/pretty-in-py August 9, 2024 12:14
@snickell
snickell marked this pull request as draft August 11, 2024 09:04
@snickell snickell mentioned this pull request Aug 11, 2024
@snickell

Copy link
Copy Markdown
Contributor Author

Replaced by #60335 which is a continuation of this PR with a nice rebase, and a better focus. This PR did its job: it shaped our Python.run API to the point that it is now updated in name, etc.

@snickell snickell closed this Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant