initial interfaces
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
package org.springframework.ai.core.llm;/*
|
||||
* Copyright 2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.ai.core.prompt.Generation;
|
||||
|
||||
public interface LLMResult {
|
||||
|
||||
/**
|
||||
* The list of generated outputs. It iss a list of lists because a single input could
|
||||
* have multiple outputs, and multiple inputs could be passed in.
|
||||
* @return
|
||||
*/
|
||||
List<List<Generation>> getGenerations();
|
||||
|
||||
/**
|
||||
* Arbitrary LLM-provider specific output
|
||||
*/
|
||||
Map<String, Object> getProviderOutput();
|
||||
|
||||
/**
|
||||
* The run metadata information
|
||||
*/
|
||||
Map<String, Object> getRunInfo();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.llm;
|
||||
|
||||
import org.springframework.ai.core.prompt.Prompt;
|
||||
|
||||
public interface LlmClient {
|
||||
|
||||
String generate(String text);
|
||||
|
||||
LLMResult generate(Prompt... prompts);
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
public abstract class AbstractPromptTemplate implements PromptOperations {
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.ai.core.prompts.messages.AiMessage;
|
||||
import org.springframework.ai.core.prompt.messages.AiMessage;
|
||||
|
||||
public class AiPromptTemplate extends PromptTemplate {
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.ai.core.prompts.messages.ChatMessage;
|
||||
import org.springframework.ai.core.prompt.messages.ChatMessage;
|
||||
|
||||
public class ChatPromptTemplate extends PromptTemplate {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
public class FunctionPromptTemplate extends PromptTemplate {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.ai.core.prompts.messages.HumanMessage;
|
||||
import org.springframework.ai.core.prompts.messages.Message;
|
||||
import org.springframework.ai.core.prompt.messages.HumanMessage;
|
||||
import org.springframework.ai.core.prompt.messages.Message;
|
||||
|
||||
public class Prompt {
|
||||
|
||||
@@ -14,12 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.ai.core.prompts.messages.MessageType;
|
||||
|
||||
public interface PromptOperations {
|
||||
|
||||
String getTemplate();
|
||||
@@ -14,9 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@@ -30,14 +29,6 @@ import org.antlr.runtime.TokenStream;
|
||||
import org.stringtemplate.v4.ST;
|
||||
import org.stringtemplate.v4.compiler.STLexer;
|
||||
|
||||
import org.springframework.ai.core.prompts.messages.AiMessage;
|
||||
import org.springframework.ai.core.prompts.messages.ChatMessage;
|
||||
import org.springframework.ai.core.prompts.messages.FunctionMessage;
|
||||
import org.springframework.ai.core.prompts.messages.HumanMessage;
|
||||
import org.springframework.ai.core.prompts.messages.Message;
|
||||
import org.springframework.ai.core.prompts.messages.MessageType;
|
||||
import org.springframework.ai.core.prompts.messages.SystemMessage;
|
||||
|
||||
public class PromptTemplate extends AbstractPromptTemplate {
|
||||
|
||||
private ST st;
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.ai.core.prompts.messages.SystemMessage;
|
||||
import org.springframework.ai.core.prompt.messages.SystemMessage;
|
||||
|
||||
public class SystemPromptTemplate extends PromptTemplate {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
public enum TemplateFormat {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts.messages;
|
||||
package org.springframework.ai.core.prompt.messages;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts.messages;
|
||||
package org.springframework.ai.core.prompt.messages;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts.messages;
|
||||
package org.springframework.ai.core.prompt.messages;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts.messages;
|
||||
package org.springframework.ai.core.prompt.messages;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts.messages;
|
||||
package org.springframework.ai.core.prompt.messages;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts.messages;
|
||||
package org.springframework.ai.core.prompt.messages;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.ai.core.prompts.messages;
|
||||
package org.springframework.ai.core.prompt.messages;
|
||||
|
||||
public enum MessageType {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts.messages;
|
||||
package org.springframework.ai.core.prompt.messages;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
public class ChatTests {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.ai.core.prompts;
|
||||
package org.springframework.ai.core.prompt;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
Reference in New Issue
Block a user