-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
773 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?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</artifactId> | ||
<version>0.37.0-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>langchain4j-community-chatglm</artifactId> | ||
<name>LangChain4j :: Community :: Integration :: ChatGLM</name> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>dev.langchain4j</groupId> | ||
<artifactId>langchain4j-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.squareup.retrofit2</groupId> | ||
<artifactId>retrofit</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.squareup.retrofit2</groupId> | ||
<artifactId>converter-jackson</artifactId> | ||
</dependency> | ||
|
||
<!-- DEPENDENCY CONFLICT RESOLUTION FOR OKHTTP (START) --> | ||
<dependency> | ||
<groupId>com.squareup.okhttp3</groupId> | ||
<artifactId>okhttp</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib-jdk8</artifactId> | ||
</dependency> | ||
<!-- DEPENDENCY CONFLICT RESOLUTION FOR OKHTTP (END) --> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.assertj</groupId> | ||
<artifactId>assertj-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.tinylog</groupId> | ||
<artifactId>tinylog-impl</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.tinylog</groupId> | ||
<artifactId>slf4j-tinylog</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
115 changes: 115 additions & 0 deletions
115
...-chatglm/src/main/java/dev/langchain4j/community/model/chatglm/ChatCompletionRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package dev.langchain4j.community.model.chatglm; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
import java.util.List; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(NON_NULL) | ||
@JsonNaming(SnakeCaseStrategy.class) | ||
class ChatCompletionRequest { | ||
|
||
private String prompt; | ||
private Double temperature; | ||
private Double topP; | ||
private Integer maxLength; | ||
private List<List<String>> history; | ||
|
||
ChatCompletionRequest() { | ||
} | ||
|
||
ChatCompletionRequest(String prompt, Double temperature, Double topP, Integer maxLength, List<List<String>> history) { | ||
this.prompt = prompt; | ||
this.temperature = temperature; | ||
this.topP = topP; | ||
this.maxLength = maxLength; | ||
this.history = history; | ||
} | ||
|
||
public String getPrompt() { | ||
return prompt; | ||
} | ||
|
||
public void setPrompt(String prompt) { | ||
this.prompt = prompt; | ||
} | ||
|
||
public Double getTemperature() { | ||
return temperature; | ||
} | ||
|
||
public void setTemperature(Double temperature) { | ||
this.temperature = temperature; | ||
} | ||
|
||
public Double getTopP() { | ||
return topP; | ||
} | ||
|
||
public void setTopP(Double topP) { | ||
this.topP = topP; | ||
} | ||
|
||
public Integer getMaxLength() { | ||
return maxLength; | ||
} | ||
|
||
public void setMaxLength(Integer maxLength) { | ||
this.maxLength = maxLength; | ||
} | ||
|
||
public List<List<String>> getHistory() { | ||
return history; | ||
} | ||
|
||
public void setHistory(List<List<String>> history) { | ||
this.history = history; | ||
} | ||
|
||
static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
static class Builder { | ||
|
||
private String prompt; | ||
private Double temperature; | ||
private Double topP; | ||
private Integer maxLength; | ||
private List<List<String>> history; | ||
|
||
Builder prompt(String prompt) { | ||
this.prompt = prompt; | ||
return this; | ||
} | ||
|
||
Builder temperature(Double temperature) { | ||
this.temperature = temperature; | ||
return this; | ||
} | ||
|
||
Builder topP(Double topP) { | ||
this.topP = topP; | ||
return this; | ||
} | ||
|
||
Builder maxLength(Integer maxLength) { | ||
this.maxLength = maxLength; | ||
return this; | ||
} | ||
|
||
Builder history(List<List<String>> history) { | ||
this.history = history; | ||
return this; | ||
} | ||
|
||
ChatCompletionRequest build() { | ||
return new ChatCompletionRequest(prompt, temperature, topP, maxLength, history); | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
...chatglm/src/main/java/dev/langchain4j/community/model/chatglm/ChatCompletionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package dev.langchain4j.community.model.chatglm; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
|
||
import java.util.List; | ||
|
||
import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonInclude(NON_NULL) | ||
@JsonNaming(SnakeCaseStrategy.class) | ||
class ChatCompletionResponse { | ||
|
||
private String response; | ||
private List<List<String>> history; | ||
private Integer status; | ||
private String time; | ||
|
||
ChatCompletionResponse() { | ||
} | ||
|
||
ChatCompletionResponse(String response, List<List<String>> history, Integer status, String time) { | ||
this.response = response; | ||
this.history = history; | ||
this.status = status; | ||
this.time = time; | ||
} | ||
|
||
public String getResponse() { | ||
return response; | ||
} | ||
|
||
public void setResponse(String response) { | ||
this.response = response; | ||
} | ||
|
||
public List<List<String>> getHistory() { | ||
return history; | ||
} | ||
|
||
public void setHistory(List<List<String>> history) { | ||
this.history = history; | ||
} | ||
|
||
public Integer getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(Integer status) { | ||
this.status = status; | ||
} | ||
|
||
public String getTime() { | ||
return time; | ||
} | ||
|
||
public void setTime(String time) { | ||
this.time = time; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...j-community-chatglm/src/main/java/dev/langchain4j/community/model/chatglm/ChatGlmApi.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package dev.langchain4j.community.model.chatglm; | ||
|
||
import retrofit2.Call; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.Headers; | ||
import retrofit2.http.POST; | ||
|
||
interface ChatGlmApi { | ||
|
||
int OK = 200; | ||
|
||
@POST(".") | ||
@Headers({"Content-Type: application/json"}) | ||
Call<ChatCompletionResponse> chatCompletion(@Body ChatCompletionRequest chatCompletionRequest); | ||
} |
Oops, something went wrong.