Skip to content

Commit

Permalink
add spring boot starter of xinference (#38)
Browse files Browse the repository at this point in the history
* add spring boot starter of xinference

* add spring boot starter of xinference

* switch testcontainers

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* Update spring-boot-starters/langchain4j-community-xinference-spring-boot-starter/src/main/java/dev/langchain4j/community/xinference/spring/AutoConfig.java

Co-authored-by: Martin7-1 <[email protected]>

* add spring boot starter of xinference

---------

Co-authored-by: lixw <>
Co-authored-by: Martin7-1 <[email protected]>
  • Loading branch information
alvinlee518 and Martin7-1 authored Dec 31, 2024
1 parent 3155af0 commit da54df5
Show file tree
Hide file tree
Showing 16 changed files with 1,808 additions and 1 deletion.
9 changes: 8 additions & 1 deletion langchain4j-community-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<packaging>pom</packaging>

<name>LangChain4j :: Community :: BOM</name>
<description>Bill of Materials POM for getting full, complete set of compatible versions of LangChain4j Community modules</description>
<description>Bill of Materials POM for getting full, complete set of compatible versions of LangChain4j Community
modules</description>

<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -82,6 +83,12 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-community-xinference-spring-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-community-spring-boot-starters</artifactId>
<version>1.0.0-alpha1</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>langchain4j-community-xinference-spring-boot-starter</artifactId>
<name>LangChain4j :: Community :: Spring Boot starter :: Xinference</name>

<licenses>
<license>
<name>Apache-2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
<comments>A business-friendly OSS license</comments>
</license>
</licenses>

<dependencies>
<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-community-xinference</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure-processor</artifactId>
<optional>true</optional>
</dependency>

<!-- needed to generate automatic metadata about available config properties -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.honton.chas</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<acceptableLicenses combine.children="append">
<!-- due to excludes/includes above -->
<license>
<name>Eclipse Public License</name>
<url>http://www.eclipse.org/legal/epl-v10.html</url>
</license>
<license>
<name>GNU Lesser General Public License</name>
<url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html</url>
</license>
</acceptableLicenses>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
package dev.langchain4j.community.xinference.spring;

import java.time.Duration;
import java.util.List;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;

@ConfigurationProperties(prefix = ChatModelProperties.PREFIX)
public class ChatModelProperties {
static final String PREFIX = "langchain4j.community.xinference.chat-model";
private String baseUrl;
private String apiKey;
private String modelName;
private Double temperature;
private Double topP;
private List<String> stop;
private Integer maxTokens;
private Double presencePenalty;
private Double frequencyPenalty;
private Integer seed;
private String user;
private Object toolChoice;
private Boolean parallelToolCalls;
private Integer maxRetries;
private Duration timeout;

@NestedConfigurationProperty
private ProxyProperties proxy;

private Boolean logRequests;
private Boolean logResponses;
private Map<String, String> customHeaders;

public String getBaseUrl() {
return baseUrl;
}

public void setBaseUrl(final String baseUrl) {
this.baseUrl = baseUrl;
}

public String getApiKey() {
return apiKey;
}

public void setApiKey(final String apiKey) {
this.apiKey = apiKey;
}

public String getModelName() {
return modelName;
}

public void setModelName(final String modelName) {
this.modelName = modelName;
}

public Double getTemperature() {
return temperature;
}

public void setTemperature(final Double temperature) {
this.temperature = temperature;
}

public Double getTopP() {
return topP;
}

public void setTopP(final Double topP) {
this.topP = topP;
}

public List<String> getStop() {
return stop;
}

public void setStop(final List<String> stop) {
this.stop = stop;
}

public Integer getMaxTokens() {
return maxTokens;
}

public void setMaxTokens(final Integer maxTokens) {
this.maxTokens = maxTokens;
}

public Double getPresencePenalty() {
return presencePenalty;
}

public void setPresencePenalty(final Double presencePenalty) {
this.presencePenalty = presencePenalty;
}

public Double getFrequencyPenalty() {
return frequencyPenalty;
}

public void setFrequencyPenalty(final Double frequencyPenalty) {
this.frequencyPenalty = frequencyPenalty;
}

public Integer getSeed() {
return seed;
}

public void setSeed(final Integer seed) {
this.seed = seed;
}

public String getUser() {
return user;
}

public void setUser(final String user) {
this.user = user;
}

public Object getToolChoice() {
return toolChoice;
}

public void setToolChoice(final Object toolChoice) {
this.toolChoice = toolChoice;
}

public Boolean getParallelToolCalls() {
return parallelToolCalls;
}

public void setParallelToolCalls(final Boolean parallelToolCalls) {
this.parallelToolCalls = parallelToolCalls;
}

public Integer getMaxRetries() {
return maxRetries;
}

public void setMaxRetries(final Integer maxRetries) {
this.maxRetries = maxRetries;
}

public Duration getTimeout() {
return timeout;
}

public void setTimeout(final Duration timeout) {
this.timeout = timeout;
}

public ProxyProperties getProxy() {
return proxy;
}

public void setProxy(final ProxyProperties proxy) {
this.proxy = proxy;
}

public Boolean getLogRequests() {
return logRequests;
}

public void setLogRequests(final Boolean logRequests) {
this.logRequests = logRequests;
}

public Boolean getLogResponses() {
return logResponses;
}

public void setLogResponses(final Boolean logResponses) {
this.logResponses = logResponses;
}

public Map<String, String> getCustomHeaders() {
return customHeaders;
}

public void setCustomHeaders(final Map<String, String> customHeaders) {
this.customHeaders = customHeaders;
}
}
Loading

0 comments on commit da54df5

Please sign in to comment.