Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohehuhu committed Dec 8, 2023
1 parent 832bc04 commit 2f4a638
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 74 deletions.
2 changes: 1 addition & 1 deletion externals/kyuubi-chat-engine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-jackson</artifactId>
<version>${retrofit2.version}</version>
<version>${retrofit.version}</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,20 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty
import java.lang.{Double => JDouble}
import java.util.{List => JList}

import com.fasterxml.jackson.annotation.JsonProperty

case class ChatCompletionRequest(
@BeanProperty @JsonProperty("messages") messages: java.util.List[ChatMessage],
@BeanProperty @JsonProperty("functions") functions: java.util.List[Function] = null,
@BeanProperty @JsonProperty("temperature") temperature: java.lang.Double = null,
@BeanProperty @JsonProperty("top_p") topP: java.lang.Double = null,
@BeanProperty @JsonProperty("penalty_score") presenceScore: java.lang.Double = null,
@BeanProperty @JsonProperty("stream") stream: Boolean = false,
@BeanProperty @JsonProperty("system") system: String = null,
@BeanProperty @JsonProperty("stop") stop: java.util.List[String] = null,
@BeanProperty @JsonProperty("disable_search") disableSearch: Boolean = false,
@BeanProperty @JsonProperty("enable_citation") enableCitation: Boolean = false,
@BeanProperty @JsonProperty("user_id") userId: String = null)
@JsonProperty("messages") messages: JList[ChatMessage],
@JsonProperty("functions") functions: JList[Function] = null,
@JsonProperty("temperature") temperature: JDouble = null,
@JsonProperty("top_p") topP: JDouble = null,
@JsonProperty("penalty_score") presenceScore: JDouble = null,
@JsonProperty("stream") stream: Boolean = false,
@JsonProperty("system") system: String = null,
@JsonProperty("stop") stop: JList[String] = null,
@JsonProperty("disable_search") disableSearch: Boolean = false,
@JsonProperty("enable_citation") enableCitation: Boolean = false,
@JsonProperty("user_id") userId: String = null)
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty
import java.lang.{Long => JLong}

import com.fasterxml.jackson.annotation.JsonProperty

case class ChatCompletionResult(
@BeanProperty @JsonProperty("id") id: String,
@BeanProperty @JsonProperty("object") `object`: String,
@BeanProperty @JsonProperty("created") created: java.lang.Long,
@BeanProperty @JsonProperty("sentence_id") sentenceId: java.lang.Long,
@BeanProperty @JsonProperty("is_end") isEnd: Boolean,
@BeanProperty @JsonProperty("is_truncated") isTruncated: Boolean,
@BeanProperty @JsonProperty("finish_reason") finishReason: String,
@BeanProperty @JsonProperty("search_info") searchInfo: SearchInfo,
@BeanProperty @JsonProperty("result") result: String,
@BeanProperty @JsonProperty("need_clear_history") needClearHistory: Boolean,
@BeanProperty @JsonProperty("ban_round") banRound: java.lang.Long,
@BeanProperty @JsonProperty("usage") usage: Usage,
@BeanProperty @JsonProperty("function_call") functionCall: FunctionCall,
@BeanProperty @JsonProperty("error_msg") errorMsg: String,
@BeanProperty @JsonProperty("error_code") errorCode: java.lang.Long)
@JsonProperty("id") id: String,
@JsonProperty("object") obj: String,
@JsonProperty("created") created: JLong,
@JsonProperty("sentence_id") sentenceId: JLong,
@JsonProperty("is_end") isEnd: Boolean,
@JsonProperty("is_truncated") isTruncated: Boolean,
@JsonProperty("finish_reason") finishReason: String,
@JsonProperty("search_info") searchInfo: SearchInfo,
@JsonProperty("result") result: String,
@JsonProperty("need_clear_history") needClearHistory: Boolean,
@JsonProperty("ban_round") banRound: JLong,
@JsonProperty("usage") usage: Usage,
@JsonProperty("function_call") functionCall: FunctionCall,
@JsonProperty("error_msg") errorMsg: String,
@JsonProperty("error_code") errorCode: JLong)
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty

import com.fasterxml.jackson.annotation.JsonProperty

case class ChatMessage(
@BeanProperty @JsonProperty("role") role: String,
@BeanProperty @JsonProperty("content") content: String,
@BeanProperty @JsonProperty("name") name: String,
@BeanProperty @JsonProperty("function_call") functionCall: FunctionCall = null)
@JsonProperty("role") role: String,
@JsonProperty("content") content: String,
@JsonProperty("name") name: String,
@JsonProperty("function_call") functionCall: FunctionCall = null)
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty

import com.fasterxml.jackson.annotation.JsonProperty

case class Example(
@BeanProperty @JsonProperty("role") role: String,
@BeanProperty @JsonProperty("name") name: String,
@BeanProperty @JsonProperty("content") content: String = null,
@BeanProperty @JsonProperty("function_call") functionCall: FunctionCall = null)
@JsonProperty("role") role: String,
@JsonProperty("name") name: String,
@JsonProperty("content") content: String = null,
@JsonProperty("function_call") functionCall: FunctionCall = null)
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty
import java.util.{List => JList}

import com.fasterxml.jackson.annotation.JsonProperty

case class Function(
@BeanProperty @JsonProperty("name") name: String,
@BeanProperty @JsonProperty("description") description: String,
@BeanProperty @JsonProperty("parameters") parameters: Object,
@BeanProperty @JsonProperty("responses") responses: Object = null,
@BeanProperty @JsonProperty("examples") examples: java.util.List[Example] = null)
@JsonProperty("name") name: String,
@JsonProperty("description") description: String,
@JsonProperty("parameters") parameters: Object,
@JsonProperty("responses") responses: Object = null,
@JsonProperty("examples") examples: JList[Example] = null)
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty

import com.fasterxml.jackson.annotation.JsonProperty

case class FunctionCall(
@BeanProperty @JsonProperty("name") name: String,
@BeanProperty @JsonProperty("thoughts") thoughts: String,
@BeanProperty @JsonProperty("arguments") arguments: String = null)
@JsonProperty("name") name: String,
@JsonProperty("thoughts") thoughts: String,
@JsonProperty("arguments") arguments: String = null)
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty
import java.lang.{Long => JLong}

import com.fasterxml.jackson.annotation.JsonProperty

case class PluginUsage(
@BeanProperty @JsonProperty("name") name: String,
@BeanProperty @JsonProperty("parse_tokens") parseTokens: java.lang.Long,
@BeanProperty @JsonProperty("abstract_tokens") abstractTokens: java.lang.Long,
@BeanProperty @JsonProperty("search_tokens") searchTokens: java.lang.Long,
@BeanProperty @JsonProperty("total_tokens") totalTokens: java.lang.Long)
@JsonProperty("name") name: String,
@JsonProperty("parse_tokens") parseTokens: JLong,
@JsonProperty("abstract_tokens") abstractTokens: JLong,
@JsonProperty("search_tokens") searchTokens: JLong,
@JsonProperty("total_tokens") totalTokens: JLong)
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty
import java.lang.{Long => JLong}
import java.util.{List => JList}

import com.fasterxml.jackson.annotation.JsonProperty

case class SearchInfo(
@BeanProperty @JsonProperty("is_beset") isBeset: java.lang.Long,
@BeanProperty @JsonProperty("rewrite_query") rewriteQuery: String,
@BeanProperty @JsonProperty("search_results") searchResults: java.util.List[SearchResult])
@JsonProperty("is_beset") isBeset: JLong,
@JsonProperty("rewrite_query") rewriteQuery: String,
@JsonProperty("search_results") searchResults: JList[SearchResult])
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty

import com.fasterxml.jackson.annotation.JsonProperty

case class SearchResult(
@BeanProperty @JsonProperty("index") index: java.lang.Long,
@BeanProperty @JsonProperty("url") url: String,
@BeanProperty @JsonProperty("title") title: String,
@BeanProperty @JsonProperty("datasource_id") datasourceId: String)
@JsonProperty("index") index: java.lang.Long,
@JsonProperty("url") url: String,
@JsonProperty("title") title: String,
@JsonProperty("datasource_id") datasourceId: String)
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@

package org.apache.kyuubi.engine.chat.ernie.bean

import scala.beans.BeanProperty
import java.lang.{Long => JLong}
import java.util.{List => JList}

import com.fasterxml.jackson.annotation.JsonProperty

case class Usage(
@BeanProperty @JsonProperty("prompt_tokens") promptTokens: java.lang.Long,
@BeanProperty @JsonProperty("completion_tokens") completionTokens: java.lang.Long,
@BeanProperty @JsonProperty("total_tokens") totalTokens: java.lang.Long,
@BeanProperty @JsonProperty("plugins") plugins: java.util.List[PluginUsage])
@JsonProperty("prompt_tokens") promptTokens: JLong,
@JsonProperty("completion_tokens") completionTokens: JLong,
@JsonProperty("total_tokens") totalTokens: JLong,
@JsonProperty("plugins") plugins: JList[PluginUsage])
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
<mockito.version>4.11.0</mockito.version>
<netty.version>4.1.100.Final</netty.version>
<openai.java.version>0.12.0</openai.java.version>
<retrofit2.version>2.9.0</retrofit2.version>
<retrofit.version>2.9.0</retrofit.version>
<paimon.version>0.5.0-incubating</paimon.version>
<paimon.spark.binary.version>${spark.binary.version}</paimon.spark.binary.version>
<parquet.version>1.10.1</parquet.version>
Expand Down

0 comments on commit 2f4a638

Please sign in to comment.