Skip to content

Commit d52c753

Browse files
markpollackleijendary
authored andcommitted
Add deprecated with* methods to OllamaOptions Builder
Add backwards compatibility methods to the Builder class in OllamaOptions to maintain compatibility with code using the old withX style methods. Each deprecated method delegates to its new counterpart and includes proper Javadoc directing users to the new method name. All deprecated methods are marked for removal in 1.0.0-M5, giving users time to migrate to the new style while maintaining functionality. Signed-off-by: leijendary <[email protected]>
1 parent 8256f7e commit d52c753

File tree

1 file changed

+287
-1
lines changed

1 file changed

+287
-1
lines changed

models/spring-ai-ollama/src/main/java/org/springframework/ai/ollama/api/OllamaOptions.java

Lines changed: 287 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,7 +1395,293 @@ public Builder withFormat(Object format) {
13951395
return format(format);
13961396
}
13971397

1398-
// ... [add all other deprecated with* methods] ...
1398+
/**
1399+
* @deprecated use {@link #keepAlive(String)} instead.
1400+
*/
1401+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1402+
public Builder withKeepAlive(String keepAlive) {
1403+
return keepAlive(keepAlive);
1404+
}
1405+
1406+
/**
1407+
* @deprecated use {@link #truncate(Boolean)} instead.
1408+
*/
1409+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1410+
public Builder withTruncate(Boolean truncate) {
1411+
return truncate(truncate);
1412+
}
1413+
1414+
/**
1415+
* @deprecated use {@link #useNUMA(Boolean)} instead.
1416+
*/
1417+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1418+
public Builder withUseNUMA(Boolean useNUMA) {
1419+
return useNUMA(useNUMA);
1420+
}
1421+
1422+
/**
1423+
* @deprecated use {@link #numCtx(Integer)} instead.
1424+
*/
1425+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1426+
public Builder withNumCtx(Integer numCtx) {
1427+
return numCtx(numCtx);
1428+
}
1429+
1430+
/**
1431+
* @deprecated use {@link #numBatch(Integer)} instead.
1432+
*/
1433+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1434+
public Builder withNumBatch(Integer numBatch) {
1435+
return numBatch(numBatch);
1436+
}
1437+
1438+
/**
1439+
* @deprecated use {@link #numGPU(Integer)} instead.
1440+
*/
1441+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1442+
public Builder withNumGPU(Integer numGPU) {
1443+
return numGPU(numGPU);
1444+
}
1445+
1446+
/**
1447+
* @deprecated use {@link #mainGPU(Integer)} instead.
1448+
*/
1449+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1450+
public Builder withMainGPU(Integer mainGPU) {
1451+
return mainGPU(mainGPU);
1452+
}
1453+
1454+
/**
1455+
* @deprecated use {@link #lowVRAM(Boolean)} instead.
1456+
*/
1457+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1458+
public Builder withLowVRAM(Boolean lowVRAM) {
1459+
return lowVRAM(lowVRAM);
1460+
}
1461+
1462+
/**
1463+
* @deprecated use {@link #f16KV(Boolean)} instead.
1464+
*/
1465+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1466+
public Builder withF16KV(Boolean f16KV) {
1467+
return f16KV(f16KV);
1468+
}
1469+
1470+
/**
1471+
* @deprecated use {@link #logitsAll(Boolean)} instead.
1472+
*/
1473+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1474+
public Builder withLogitsAll(Boolean logitsAll) {
1475+
return logitsAll(logitsAll);
1476+
}
1477+
1478+
/**
1479+
* @deprecated use {@link #vocabOnly(Boolean)} instead.
1480+
*/
1481+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1482+
public Builder withVocabOnly(Boolean vocabOnly) {
1483+
return vocabOnly(vocabOnly);
1484+
}
1485+
1486+
/**
1487+
* @deprecated use {@link #useMMap(Boolean)} instead.
1488+
*/
1489+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1490+
public Builder withUseMMap(Boolean useMMap) {
1491+
return useMMap(useMMap);
1492+
}
1493+
1494+
/**
1495+
* @deprecated use {@link #useMLock(Boolean)} instead.
1496+
*/
1497+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1498+
public Builder withUseMLock(Boolean useMLock) {
1499+
return useMLock(useMLock);
1500+
}
1501+
1502+
/**
1503+
* @deprecated use {@link #numThread(Integer)} instead.
1504+
*/
1505+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1506+
public Builder withNumThread(Integer numThread) {
1507+
return numThread(numThread);
1508+
}
1509+
1510+
/**
1511+
* @deprecated use {@link #numKeep(Integer)} instead.
1512+
*/
1513+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1514+
public Builder withNumKeep(Integer numKeep) {
1515+
return numKeep(numKeep);
1516+
}
1517+
1518+
/**
1519+
* @deprecated use {@link #seed(Integer)} instead.
1520+
*/
1521+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1522+
public Builder withSeed(Integer seed) {
1523+
return seed(seed);
1524+
}
1525+
1526+
/**
1527+
* @deprecated use {@link #numPredict(Integer)} instead.
1528+
*/
1529+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1530+
public Builder withNumPredict(Integer numPredict) {
1531+
return numPredict(numPredict);
1532+
}
1533+
1534+
/**
1535+
* @deprecated use {@link #topK(Integer)} instead.
1536+
*/
1537+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1538+
public Builder withTopK(Integer topK) {
1539+
return topK(topK);
1540+
}
1541+
1542+
/**
1543+
* @deprecated use {@link #topP(Double)} instead.
1544+
*/
1545+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1546+
public Builder withTopP(Double topP) {
1547+
return topP(topP);
1548+
}
1549+
1550+
/**
1551+
* @deprecated use {@link #tfsZ(Float)} instead.
1552+
*/
1553+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1554+
public Builder withTfsZ(Float tfsZ) {
1555+
return tfsZ(tfsZ);
1556+
}
1557+
1558+
/**
1559+
* @deprecated use {@link #typicalP(Float)} instead.
1560+
*/
1561+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1562+
public Builder withTypicalP(Float typicalP) {
1563+
return typicalP(typicalP);
1564+
}
1565+
1566+
/**
1567+
* @deprecated use {@link #repeatLastN(Integer)} instead.
1568+
*/
1569+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1570+
public Builder withRepeatLastN(Integer repeatLastN) {
1571+
return repeatLastN(repeatLastN);
1572+
}
1573+
1574+
/**
1575+
* @deprecated use {@link #temperature(Double)} instead.
1576+
*/
1577+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1578+
public Builder withTemperature(Double temperature) {
1579+
return temperature(temperature);
1580+
}
1581+
1582+
/**
1583+
* @deprecated use {@link #repeatPenalty(Double)} instead.
1584+
*/
1585+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1586+
public Builder withRepeatPenalty(Double repeatPenalty) {
1587+
return repeatPenalty(repeatPenalty);
1588+
}
1589+
1590+
/**
1591+
* @deprecated use {@link #presencePenalty(Double)} instead.
1592+
*/
1593+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1594+
public Builder withPresencePenalty(Double presencePenalty) {
1595+
return presencePenalty(presencePenalty);
1596+
}
1597+
1598+
/**
1599+
* @deprecated use {@link #frequencyPenalty(Double)} instead.
1600+
*/
1601+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1602+
public Builder withFrequencyPenalty(Double frequencyPenalty) {
1603+
return frequencyPenalty(frequencyPenalty);
1604+
}
1605+
1606+
/**
1607+
* @deprecated use {@link #mirostat(Integer)} instead.
1608+
*/
1609+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1610+
public Builder withMirostat(Integer mirostat) {
1611+
return mirostat(mirostat);
1612+
}
1613+
1614+
/**
1615+
* @deprecated use {@link #mirostatTau(Float)} instead.
1616+
*/
1617+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1618+
public Builder withMirostatTau(Float mirostatTau) {
1619+
return mirostatTau(mirostatTau);
1620+
}
1621+
1622+
/**
1623+
* @deprecated use {@link #mirostatEta(Float)} instead.
1624+
*/
1625+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1626+
public Builder withMirostatEta(Float mirostatEta) {
1627+
return mirostatEta(mirostatEta);
1628+
}
1629+
1630+
/**
1631+
* @deprecated use {@link #penalizeNewline(Boolean)} instead.
1632+
*/
1633+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1634+
public Builder withPenalizeNewline(Boolean penalizeNewline) {
1635+
return penalizeNewline(penalizeNewline);
1636+
}
1637+
1638+
/**
1639+
* @deprecated use {@link #stop(List)} instead.
1640+
*/
1641+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1642+
public Builder withStop(List<String> stop) {
1643+
return stop(stop);
1644+
}
1645+
1646+
/**
1647+
* @deprecated use {@link #functionCallbacks(List)} instead.
1648+
*/
1649+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1650+
public Builder withFunctionCallbacks(List<FunctionCallback> functionCallbacks) {
1651+
return functionCallbacks(functionCallbacks);
1652+
}
1653+
1654+
/**
1655+
* @deprecated use {@link #functions(Set)} instead.
1656+
*/
1657+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1658+
public Builder withFunctions(Set<String> functions) {
1659+
return functions(functions);
1660+
}
1661+
1662+
/**
1663+
* @deprecated use {@link #function(String)} instead.
1664+
*/
1665+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1666+
public Builder withFunction(String functionName) {
1667+
return function(functionName);
1668+
}
1669+
1670+
/**
1671+
* @deprecated use {@link #proxyToolCalls(Boolean)} instead.
1672+
*/
1673+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1674+
public Builder withProxyToolCalls(Boolean proxyToolCalls) {
1675+
return proxyToolCalls(proxyToolCalls);
1676+
}
1677+
1678+
/**
1679+
* @deprecated use {@link #toolContext(Map)} instead.
1680+
*/
1681+
@Deprecated(forRemoval = true, since = "1.0.0-M5")
1682+
public Builder withToolContext(Map<String, Object> toolContext) {
1683+
return toolContext(toolContext);
1684+
}
13991685

14001686
public OllamaOptions build() {
14011687
return this.options;

0 commit comments

Comments
 (0)