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

Request for feedback #30

Open
TomerAberbach opened this issue Dec 20, 2024 · 6 comments
Open

Request for feedback #30

TomerAberbach opened this issue Dec 20, 2024 · 6 comments

Comments

@TomerAberbach
Copy link
Collaborator

Hey everyone!

This SDK is in alpha, and we are actively iterating on its design and making improvements. We would love to hear your thoughts and feedback!

As you try the new SDK, please post your thoughts and feedback on this issue. We'll be actively monitoring this thread.

Thanks in advance! We hope to make a Java SDK you'll love using.

@sgflt
Copy link

sgflt commented Jan 4, 2025

Batch API

I am stuck at retrieving batch results.

  public MessageBatch getResults(final String batchId) {
    return this.client.messages()
        .batches()
        .retrieve(MessageBatchRetrieveParams.builder().messageBatchId(batchId).build());
  }

MessageBatch contains resultsUrl, but it seems there is a part of API missing.

I would expect a stream/list of jsonl records to be available in similar way as in python

client.messages.batches.results(
    "msgbatch_01HkcTjaV5uDC8jWR4ZsDV8d",
):

doc

API model
I feel kind of confused by multiple implementations with the same meaning and structure. F. e.:

var SYSTEM_PROMPT = "system prompt as string";
MessageBatchCreateParams.Request.Params.builder()                            
      .system(MessageBatchCreateParams.Request.Params.System.ofString(SYSTEM_PROMPT))
      // there is no string overload


MessageCreateParams.builder()
    .system(MessageCreateParams.System.ofString(SYSTEM_PROMPT))
    // or
    .system(SYSTEM_PROMPT)

@katoquro
Copy link

katoquro commented Jan 5, 2025

Hello,

Is it possible to have a separate library containing only the model types, without additional dependencies? We do not use OkHttp and have our own client, so we would like to have the "official" types and validators available separately. However, having a ready-made client as a separate artifact is beneficial for building smaller projects, like a Lambda function, where minimizing dependencies is important.
Thank you.

@TomerAberbach
Copy link
Collaborator Author

Batch API

I am stuck at retrieving batch results.

public MessageBatch getResults(final String batchId) {
return this.client.messages()
.batches()
.retrieve(MessageBatchRetrieveParams.builder().messageBatchId(batchId).build());
}
MessageBatch contains resultsUrl, but it seems there is a part of API missing.

I would expect a stream/list of jsonl records to be available in similar way as in python

client.messages.batches.results(
"msgbatch_01HkcTjaV5uDC8jWR4ZsDV8d",
):
doc

Yeah, support for this API is incomplete. JSONL support isn't built out properly yet. Filed an issue here for you to follow: #42

API model I feel kind of confused by multiple implementations with the same meaning and structure. F. e.:

var SYSTEM_PROMPT = "system prompt as string";
MessageBatchCreateParams.Request.Params.builder()
.system(MessageBatchCreateParams.Request.Params.System.ofString(SYSTEM_PROMPT))
// there is no string overload

MessageCreateParams.builder()
.system(MessageCreateParams.System.ofString(SYSTEM_PROMPT))
// or
.system(SYSTEM_PROMPT)

Yup, this is a known issue. We will soon have these convenience overloads recursively :)

@TomerAberbach
Copy link
Collaborator Author

Hello,

Is it possible to have a separate library containing only the model types, without additional dependencies? We do not use OkHttp and have our own client, so we would like to have the "official" types and validators available separately. However, having a ready-made client as a separate artifact is beneficial for building smaller projects, like a Lambda function, where minimizing dependencies is important. Thank you.

So, the SDK is already split into multiple packages:

  • anthropic-java-client-okhttp (depends on OkHttp)
  • anthropic-java-core (doesn't depend on OkHttp)
  • anthropic-java (depends on both anthropic-java-client-okhttp and anthropic-java-core)

You should be able to depend on anthropic-java-core only and bring your own HTTP client by implementing HttpClient using your client, and then using it to construct the Anthropic clients (see OkHttp examples).

Does that answer your question @katoquro?

@katoquro
Copy link

katoquro commented Jan 9, 2025

Thanks for response, @TomerAberbach.

I saw that module. Isn't org.apache.httpcomponents.client5:httpclient5 an http client?
It's listed here

implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1")

@TomerAberbach
Copy link
Collaborator Author

@katoquro apologies for the delayed reply.

I'll need to look into why we depend on that, but we definitely don't use that as our HTTP client in the core module. Maybe we depend on it for something else, or maybe it's a bug. I'll get back to you on that

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

No branches or pull requests

3 participants