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

introduce engine for API #434

Merged
merged 4 commits into from
Jun 26, 2024
Merged

introduce engine for API #434

merged 4 commits into from
Jun 26, 2024

Conversation

pmeier
Copy link
Member

@pmeier pmeier commented Jun 25, 2024

First part of #392. This just introduces the engine and let's the API use it. After this is merged, I send a follow-up that refactors the UI to also use the engine, which in turn will complete #392.

Comment on lines +162 to +163
id: Optional[uuid.UUID] = None,
timestamp: Optional[datetime.datetime] = None,
Copy link
Member Author

Choose a reason for hiding this comment

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

It was kinda weird to not have these fields here given that we have them in the database as well as in the schema. Without them, converting back and forth became harder, because we'd need to keep track of this information manually.

@@ -41,20 +45,69 @@ class Rag(Generic[C]):
```
"""

def __init__(self) -> None:
self._components: dict[Type[C], C] = {}
def __init__(
Copy link
Member Author

Choose a reason for hiding this comment

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

Two new functionalities for the ragna.Rag object:

  1. When creating a new chat with Rag().chat(), one now can also pass the display name of any loaded component instead of passing an instance or the class.
  2. The object can now be created with a configuration object, which loads all configured source storages and assistants.

We had this before, but only for the API. While refactoring, it made the code a lot cleaner when moving it here.

Comment on lines +34 to +35
# TODO: the document endpoints do not go through the engine, because they'll change
# quite drastically when the UI no longer depends on the API
Copy link
Member Author

Choose a reason for hiding this comment

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

What the inline comment says. This will be addressed in the follow-up PR



@pytest.fixture(scope="package", autouse=True)
def enhance_raise_for_status(package_mocker):
Copy link
Member Author

Choose a reason for hiding this comment

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

I was annoyed by the lack of information while debugging. response.raise_for_status() is a nice thing if you just want to check if there is an error. With this, we now automagically also see the content if something fails alongside the status code.

Copy link
Contributor

@blakerosenthal blakerosenthal left a comment

Choose a reason for hiding this comment

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

Amazing

ragna/deploy/_database.py Show resolved Hide resolved
ragna/deploy/_engine.py Outdated Show resolved Hide resolved
ragna/deploy/_engine.py Outdated Show resolved Hide resolved
@pmeier
Copy link
Member Author

pmeier commented Jun 26, 2024

Test failures are unrelated and will be fixed by #435.

@pmeier pmeier merged commit 4d37e33 into deploy-dev Jun 26, 2024
4 of 11 checks passed
@pmeier pmeier deleted the engine branch June 26, 2024 13:40
pmeier added a commit that referenced this pull request Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants