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

Minor Server Tweaks #612

Merged
merged 11 commits into from
Feb 8, 2024

Conversation

riedgar-ms
Copy link
Collaborator

@riedgar-ms riedgar-ms commented Feb 2, 2024

Some minor tweaks to the server code:

  • Adjust .gitignore to skip binary produced by setup.py on Windows
  • Use response.raise_for_status() in the server code
  • Add Pydantic model for the data sent to the server
  • Add a test of bad authentication
  • Add a notebook to show basic server use

@riedgar-ms
Copy link
Collaborator Author

@slundberg if you choose to merge this, please use the description as the commit message. The individual commit messages will not be very helpful.

Comment on lines 1328 to 1333
class RemoteModel(Model):
def __init__(self, endpoint, echo=True, **kwargs):
from ._remote import RemoteEngine

engine = RemoteEngine(endpoint, **kwargs)
super().__init__(engine, echo=echo)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riedgar-ms we're thinking we can just have users pass in a URL to the Model subclass directly to indicate a RemoteModel, instead of needing another layer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So users would just do

m_remote = models.Model("https://my.url.endpoint/")

?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes (with appropriate auth params if needed too)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strikes me as a bad idea, but I've adjusted the code accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think users will want to use models.Model directly, because the client needs to know what kind of syntax to use for the model etc. So while we allow the base class to contain this, note that it mostly used in the subclass constructors

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have put RemoteModel back if this hadn't already been merged.....

@riedgar-ms
Copy link
Collaborator Author

@slundberg ? @Harsha-Nori ?

@@ -603,7 +607,7 @@ def __init__(self):
class Join(GrammarFunction):
__slots__ = ("nullable", "values", "name", "hidden", "commit_point", "capture_name", "max_tokens")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to this... I'm seeing quite a few places where __slots__ contains "hidden", "commit_point", "capture_name" ... is there a base class lurking beneath these? Should it be GrammarFunction itself?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There probably is :) ...however we can address that in another PR. I think we are likely to call these grammar objects something like "GuidanceScript" objects in the future (similar to torchscript), because they will encode more than similar grammar idioms.

@slundberg slundberg merged commit 4a3183b into guidance-ai:main Feb 8, 2024
4 checks passed
@slundberg
Copy link
Contributor

This looked good to me so I merged! Any updates can fall in later PRs

@slundberg
Copy link
Contributor

@slundberg ? @Harsha-Nori ?

Been on travel :)

@riedgar-ms riedgar-ms deleted the riedgar-ms/server-learning-01 branch February 8, 2024 18:12
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.

None yet

3 participants