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

Added async support #53

Merged
merged 4 commits into from
Feb 9, 2024
Merged

Added async support #53

merged 4 commits into from
Feb 9, 2024

Conversation

wkok
Copy link
Owner

@wkok wkok commented Jan 21, 2024

Fixes #52

Added async support. When passing :async? true the result returned to the caller will be a Future that can be de-referenced for example:

@(create-chat-completion {:model    "gpt-3.5-turbo"
                          :messages [{:role "system" :content "You are a helpful assistant."}
                                     {:role "user" :content "Who won the world series in 2020?"}
                                     {:role "assistant" :content "The Los Angeles Dodgers won the World Series in 2020."}
                                     {:role "user" :content "Where was it played?"}]}
                         {:request {:async? true}})

@nsadeh
Copy link

nsadeh commented Jan 23, 2024

hey @wkok , works great, except one thing that surprises me a little bit is that the async response contains a bunch of request-level data but the sync response doesn't. It only contains what's in the :body keyword on the async response. Is that intentional? I would expect their responses to be identical except that one comes inside a future, unless there's a reason for it.

@wkok
Copy link
Owner Author

wkok commented Jan 31, 2024

Hey @nsadeh not intentional, it was what martian returned, but I agree it would be better to be consistent.

I've now wrapped it in another future that only returns the :body, could you try it out?

@nsadeh
Copy link

nsadeh commented Feb 9, 2024

Hey @nsadeh not intentional, it was what martian returned, but I agree it would be better to be consistent.

I've now wrapped it in another future that only returns the :body, could you try it out?

Sorry I was slammed at work. I'll be glad to check it today if you want, though based on the last check it worked fine except for the body thing. LMK if you would like any help. Thanks for adding this feature to your awesome library.

@wkok wkok merged commit 01ef37b into main Feb 9, 2024
1 check passed
@wkok wkok deleted the async branch February 9, 2024 17:57
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.

ClassCastException when passing in request option async?
2 participants