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

Assistants v2 #352

Merged
merged 6 commits into from
Jun 16, 2024
Merged

Assistants v2 #352

merged 6 commits into from
Jun 16, 2024

Conversation

kdman98
Copy link
Contributor

@kdman98 kdman98 commented Jun 15, 2024

Q A
Bug fix? no
New feature? yes
BC breaks? no
Related Issue #349, #342, #341

Describe your change

  • implemented assistants beta-v2 feature
  • I was worried that update of this instantly break up builds of other projects using this library, so I added option for beta-v2 in RequestOption, and set all api defaults to v1, not removing contents in v1. -> removed all v1
  • Wish this could help beside my awful knowledge
  • I saw another PR working on this feature(WIP - Feature/assistant v2 #350), and I saw some other fixes beside my PR. It would be better to be merged together.

What problem is this fixing?

  • future updates, because beta-v1 is deprecated at end of 2024.
  • gpt-4o available after this

any suggestions/fixes are welcomed, thanks.

Copy link
Owner

@aallam aallam left a comment

Choose a reason for hiding this comment

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

Hello, thank you for your contribution. There is also this branch that I've started before 😅

*/
public data class RequestOptions(
public val headers: Map<String, String> = emptyMap(),
public val urlParameters: Map<String, String> = emptyMap(),
public val timeout: Timeout? = null,
public val betaVersion: Int? = null,
Copy link
Owner

@aallam aallam Jun 15, 2024

Choose a reason for hiding this comment

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

I think It would be better if we update HttpRequestBuilder.requestOptions instead, but having something like:

internal fun HttpRequestBuilder.requestOptions(requestOptions: RequestOptions? = null) {
    if (requestOptions == null) return
    requestOptions.headers.forEach { (key, value) ->
        if (headers.contains(key)) {
            headers.remove(key)
        }
        headers[key] = value
    }
    // ...
 }

This more future proof, and would overriding any headers later on.

Edit: I've made a PR to fix this

Copy link
Contributor Author

@kdman98 kdman98 Jun 16, 2024

Choose a reason for hiding this comment

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

After that, simply removing this betaVersion value and changing Assistants/Threads beta version for HttpRequestBuilder.beta() to 2 works well. Thanks!

*/
@BetaOpenAI
@Serializable(with = AssistantResponseFormat.ResponseFormatSerializer::class)
public data class AssistantResponseFormat(
Copy link
Owner

Choose a reason for hiding this comment

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

I tried something here, can't remember if it works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah actually I started from your branch, and this one failed while deserializing. Tried several fixes, but I had to come up with custom serializer/deserializer. Wonder if simpler way is valid.

Copy link
Owner

@aallam aallam left a comment

Choose a reason for hiding this comment

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

looks good! thanks a lot!

@aallam aallam merged commit bf3c2af into aallam:feat/assistants-v2 Jun 16, 2024
@CeliaSgUVa
Copy link

Thanks for the changes 👍 If you could implement it in a new release 3.7.3 that would be great.
Cheers!!

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.

3 participants