|
37 | 37 | * |
38 | 38 | * @author Geng Rong |
39 | 39 | * @author Thomas Vitale |
| 40 | + * @author Ilayaperumal Gopinathan |
40 | 41 | * @since 1.0.0 M1 |
41 | 42 | */ |
42 | 43 | @JsonInclude(Include.NON_NULL) |
@@ -136,20 +137,20 @@ public static Builder builder() { |
136 | 137 |
|
137 | 138 | public static ZhiPuAiChatOptions fromOptions(ZhiPuAiChatOptions fromOptions) { |
138 | 139 | return ZhiPuAiChatOptions.builder() |
139 | | - .withModel(fromOptions.getModel()) |
140 | | - .withMaxTokens(fromOptions.getMaxTokens()) |
141 | | - .withStop(fromOptions.getStop()) |
142 | | - .withTemperature(fromOptions.getTemperature()) |
143 | | - .withTopP(fromOptions.getTopP()) |
144 | | - .withTools(fromOptions.getTools()) |
145 | | - .withToolChoice(fromOptions.getToolChoice()) |
146 | | - .withUser(fromOptions.getUser()) |
147 | | - .withRequestId(fromOptions.getRequestId()) |
148 | | - .withDoSample(fromOptions.getDoSample()) |
149 | | - .withFunctionCallbacks(fromOptions.getFunctionCallbacks()) |
150 | | - .withFunctions(fromOptions.getFunctions()) |
151 | | - .withProxyToolCalls(fromOptions.getProxyToolCalls()) |
152 | | - .withToolContext(fromOptions.getToolContext()) |
| 140 | + .model(fromOptions.getModel()) |
| 141 | + .maxTokens(fromOptions.getMaxTokens()) |
| 142 | + .stop(fromOptions.getStop()) |
| 143 | + .temperature(fromOptions.getTemperature()) |
| 144 | + .topP(fromOptions.getTopP()) |
| 145 | + .tools(fromOptions.getTools()) |
| 146 | + .toolChoice(fromOptions.getToolChoice()) |
| 147 | + .user(fromOptions.getUser()) |
| 148 | + .requestId(fromOptions.getRequestId()) |
| 149 | + .doSample(fromOptions.getDoSample()) |
| 150 | + .functionCallbacks(fromOptions.getFunctionCallbacks()) |
| 151 | + .functions(fromOptions.getFunctions()) |
| 152 | + .proxyToolCalls(fromOptions.getProxyToolCalls()) |
| 153 | + .toolContext(fromOptions.getToolContext()) |
153 | 154 | .build(); |
154 | 155 | } |
155 | 156 |
|
@@ -449,78 +450,220 @@ public Builder(ZhiPuAiChatOptions options) { |
449 | 450 | this.options = options; |
450 | 451 | } |
451 | 452 |
|
| 453 | + public Builder model(String model) { |
| 454 | + this.options.model = model; |
| 455 | + return this; |
| 456 | + } |
| 457 | + |
| 458 | + public Builder maxTokens(Integer maxTokens) { |
| 459 | + this.options.maxTokens = maxTokens; |
| 460 | + return this; |
| 461 | + } |
| 462 | + |
| 463 | + public Builder stop(List<String> stop) { |
| 464 | + this.options.stop = stop; |
| 465 | + return this; |
| 466 | + } |
| 467 | + |
| 468 | + public Builder temperature(Double temperature) { |
| 469 | + this.options.temperature = temperature; |
| 470 | + return this; |
| 471 | + } |
| 472 | + |
| 473 | + public Builder topP(Double topP) { |
| 474 | + this.options.topP = topP; |
| 475 | + return this; |
| 476 | + } |
| 477 | + |
| 478 | + public Builder tools(List<ZhiPuAiApi.FunctionTool> tools) { |
| 479 | + this.options.tools = tools; |
| 480 | + return this; |
| 481 | + } |
| 482 | + |
| 483 | + public Builder toolChoice(String toolChoice) { |
| 484 | + this.options.toolChoice = toolChoice; |
| 485 | + return this; |
| 486 | + } |
| 487 | + |
| 488 | + public Builder user(String user) { |
| 489 | + this.options.user = user; |
| 490 | + return this; |
| 491 | + } |
| 492 | + |
| 493 | + public Builder requestId(String requestId) { |
| 494 | + this.options.requestId = requestId; |
| 495 | + return this; |
| 496 | + } |
| 497 | + |
| 498 | + public Builder doSample(Boolean doSample) { |
| 499 | + this.options.doSample = doSample; |
| 500 | + return this; |
| 501 | + } |
| 502 | + |
| 503 | + public Builder functionCallbacks(List<FunctionCallback> functionCallbacks) { |
| 504 | + this.options.functionCallbacks = functionCallbacks; |
| 505 | + return this; |
| 506 | + } |
| 507 | + |
| 508 | + public Builder functions(Set<String> functionNames) { |
| 509 | + Assert.notNull(functionNames, "Function names must not be null"); |
| 510 | + this.options.functions = functionNames; |
| 511 | + return this; |
| 512 | + } |
| 513 | + |
| 514 | + public Builder function(String functionName) { |
| 515 | + Assert.hasText(functionName, "Function name must not be empty"); |
| 516 | + this.options.functions.add(functionName); |
| 517 | + return this; |
| 518 | + } |
| 519 | + |
| 520 | + public Builder proxyToolCalls(Boolean proxyToolCalls) { |
| 521 | + this.options.proxyToolCalls = proxyToolCalls; |
| 522 | + return this; |
| 523 | + } |
| 524 | + |
| 525 | + public Builder toolContext(Map<String, Object> toolContext) { |
| 526 | + if (this.options.toolContext == null) { |
| 527 | + this.options.toolContext = toolContext; |
| 528 | + } |
| 529 | + else { |
| 530 | + this.options.toolContext.putAll(toolContext); |
| 531 | + } |
| 532 | + return this; |
| 533 | + } |
| 534 | + |
| 535 | + /** |
| 536 | + * @deprecated use {@link #model(String)} instead. |
| 537 | + */ |
| 538 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
452 | 539 | public Builder withModel(String model) { |
453 | 540 | this.options.model = model; |
454 | 541 | return this; |
455 | 542 | } |
456 | 543 |
|
| 544 | + /** |
| 545 | + * @deprecated use {@link #maxTokens(Integer)} instead. |
| 546 | + */ |
| 547 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
457 | 548 | public Builder withMaxTokens(Integer maxTokens) { |
458 | 549 | this.options.maxTokens = maxTokens; |
459 | 550 | return this; |
460 | 551 | } |
461 | 552 |
|
| 553 | + /** |
| 554 | + * @deprecated use {@link #stop(List)} instead. |
| 555 | + */ |
| 556 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
462 | 557 | public Builder withStop(List<String> stop) { |
463 | 558 | this.options.stop = stop; |
464 | 559 | return this; |
465 | 560 | } |
466 | 561 |
|
| 562 | + /** |
| 563 | + * @deprecated use {@link #temperature(Double)} instead. |
| 564 | + */ |
| 565 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
467 | 566 | public Builder withTemperature(Double temperature) { |
468 | 567 | this.options.temperature = temperature; |
469 | 568 | return this; |
470 | 569 | } |
471 | 570 |
|
| 571 | + /** |
| 572 | + * @deprecated use {@link #topP(Double)} instead. |
| 573 | + */ |
| 574 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
472 | 575 | public Builder withTopP(Double topP) { |
473 | 576 | this.options.topP = topP; |
474 | 577 | return this; |
475 | 578 | } |
476 | 579 |
|
| 580 | + /** |
| 581 | + * @deprecated use {@link #tools(List)} instead. |
| 582 | + */ |
| 583 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
477 | 584 | public Builder withTools(List<ZhiPuAiApi.FunctionTool> tools) { |
478 | 585 | this.options.tools = tools; |
479 | 586 | return this; |
480 | 587 | } |
481 | 588 |
|
| 589 | + /** |
| 590 | + * @deprecated use {@link #toolChoice(String)} instead. |
| 591 | + */ |
| 592 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
482 | 593 | public Builder withToolChoice(String toolChoice) { |
483 | 594 | this.options.toolChoice = toolChoice; |
484 | 595 | return this; |
485 | 596 | } |
486 | 597 |
|
| 598 | + /** |
| 599 | + * @deprecated use {@link #user(String)} instead. |
| 600 | + */ |
| 601 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
487 | 602 | public Builder withUser(String user) { |
488 | 603 | this.options.user = user; |
489 | 604 | return this; |
490 | 605 | } |
491 | 606 |
|
| 607 | + /** |
| 608 | + * @deprecated use {@link #requestId(String)} instead. |
| 609 | + */ |
| 610 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
492 | 611 | public Builder withRequestId(String requestId) { |
493 | 612 | this.options.requestId = requestId; |
494 | 613 | return this; |
495 | 614 | } |
496 | 615 |
|
| 616 | + /** |
| 617 | + * @deprecated use {@link #doSample(Boolean)} instead. |
| 618 | + */ |
| 619 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
497 | 620 | public Builder withDoSample(Boolean doSample) { |
498 | 621 | this.options.doSample = doSample; |
499 | 622 | return this; |
500 | 623 | } |
501 | 624 |
|
| 625 | + /** |
| 626 | + * @deprecated use {@link #functionCallbacks(List)} instead. |
| 627 | + */ |
| 628 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
502 | 629 | public Builder withFunctionCallbacks(List<FunctionCallback> functionCallbacks) { |
503 | 630 | this.options.functionCallbacks = functionCallbacks; |
504 | 631 | return this; |
505 | 632 | } |
506 | 633 |
|
| 634 | + /** |
| 635 | + * @deprecated use {@link #functions(Set)} instead. |
| 636 | + */ |
| 637 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
507 | 638 | public Builder withFunctions(Set<String> functionNames) { |
508 | 639 | Assert.notNull(functionNames, "Function names must not be null"); |
509 | 640 | this.options.functions = functionNames; |
510 | 641 | return this; |
511 | 642 | } |
512 | 643 |
|
| 644 | + /** |
| 645 | + * @deprecated use {@link #function(String)} instead. |
| 646 | + */ |
| 647 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
513 | 648 | public Builder withFunction(String functionName) { |
514 | 649 | Assert.hasText(functionName, "Function name must not be empty"); |
515 | 650 | this.options.functions.add(functionName); |
516 | 651 | return this; |
517 | 652 | } |
518 | 653 |
|
| 654 | + /** |
| 655 | + * @deprecated use {@link #proxyToolCalls(Boolean)} instead. |
| 656 | + */ |
| 657 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
519 | 658 | public Builder withProxyToolCalls(Boolean proxyToolCalls) { |
520 | 659 | this.options.proxyToolCalls = proxyToolCalls; |
521 | 660 | return this; |
522 | 661 | } |
523 | 662 |
|
| 663 | + /** |
| 664 | + * @deprecated use {@link #toolContext(Map)} instead. |
| 665 | + */ |
| 666 | + @Deprecated(forRemoval = true, since = "1.0.0-M5") |
524 | 667 | public Builder withToolContext(Map<String, Object> toolContext) { |
525 | 668 | if (this.options.toolContext == null) { |
526 | 669 | this.options.toolContext = toolContext; |
|
0 commit comments