Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Host function(s) for calling AI models #38
Host function(s) for calling AI models #38
Changes from all commits
0572b9b
90aacbd
d315bb6
87d4812
e7af5eb
4fd6813
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not be licensing our code under Apache 2 license. We can stick with just
Copyright 2023 Hypermode, Inc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. The runtime Go code is internal closed-source. Not OSS licensed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it'd be better to put these configs as env variables instead of in a json file?
The main concern I have is if there's ever a need to change one of the configs, we'll need to change this in the repo and then re-create the image, instead of just changing the env variables directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly - this is using Clerk, with a Clerk user ID coming from a json file, to get a JWT token for authenticating to the Dgraph console database. That's way too complex, and not an ideal strategy. We should have a service-to-service authentication flow that does not require using Clerk. Clerk-generated JWT tokens are for user-based authentication, not for services.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can encode the payload this way instead using maps and then json.Marshal, which I think is cleaner than using fmt.Sprintf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. But it's not just about clean code.
sprintf
isn't appropriate for encoding parameters that are strings because it will fail if the string contains a quotation mark or other character that needs to be escaped. While unlikely for anid
, it's still a good practice to avoid injection attacks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's set a
Timeout
for the http client. We can maybe have a global httpClient variable with the timeout, so we don't have to set the timeout on every request.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's cleaner to have
"classifier"
as a const instead on top of this file, along with otherModelType
s we have or will add in the future.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go mod tidy
should reorganize these better to group direct and indirect dependencies.