Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

using it as a library #1

Open
rogeriochaves opened this issue Jul 12, 2023 · 1 comment
Open

using it as a library #1

rogeriochaves opened this issue Jul 12, 2023 · 1 comment

Comments

@rogeriochaves
Copy link

rogeriochaves commented Jul 12, 2023

Hey there! Great little project you wrote! I find your implementation to be way better for handling functions and more focused and strict than langchain's one for example, it's great not having to use pydantic or some middle step

In fact I've used in my library, check it out: https://github.com/rogeriochaves/litechain/blob/main/litechain/contrib/utils/open_ai_functions.py

I've just made a small change:

     if (
-        len(func.body) != 1
+        len(func.body) == 0
         or not isinstance(func.body[0], ast.Expr)
         or not isinstance(func.body[0].value, ast.Str)
     ):
-        raise ValueError("The function body should only contain a docstring")
+        raise ValueError("The function body should contain a docstring")

This is because I want my functions to have actual execution bodies too, so LiteChain actually calls them directly. I've also removed the pyscript bits, as I'm just using it as a module.

It is working well, however I didn't want to maintain this inside LiteChain, do you have plans to publish it as a library? I can help providing updates as well

@janekb04
Copy link
Owner

Hi, I agree that using py2gpt as a package would be useful. It is something that I was thinking about, but haven't had the time to do it yet. I want to leave the web UI available, for easy one-off conversions, but separate the core functionality from it. As pyscript handles pip packages, I thought of making a pip package out of py2gpt, and simply importing it in the web app.

I'm glad that you found py2gpt useful. I'll try to find some time over the next few days to do this refactoring. Feel free to make a PR, if you'd like.

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

No branches or pull requests

2 participants