New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add OllamaChatModel and its corresponding integration test #323
Conversation
A new implementation of ChatLanguageModel, OllamaChatModel, is added to handle interactions with the Ollama AI and has an associated integration test. This includes necessary configurations and methods for message generation. This increases the project's modularity and provides a more convenient and encapsulated way of interfacing with the Ollama AI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fintanmm thanks a lot!
langchain4j-ollama/src/main/java/dev/langchain4j/model/ollama/OllamaChatModel.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/main/java/dev/langchain4j/model/ollama/OllamaChatModel.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/test/java/dev/langchain4j/model/ollama/OllamaChatModelIT.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/test/java/dev/langchain4j/model/ollama/OllamaChatModelIT.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/test/java/dev/langchain4j/model/ollama/OllamaChatModelIT.java
Show resolved
Hide resolved
Added a validation to ensure that modelName in OllamaLanguageModel, OllamaChatModel, and OllamaEmbeddingModel classes is not blank. This change will prevent situations where a model is created with an empty or null modelName, which would likely cause errors during execution. Validation is done using the ensureNotBlank utility method from ValidationUtils.
…hich can be used to guide the AI's responses.
langchain4j-ollama/src/test/java/dev/langchain4j/model/ollama/OllamaChatModelIT.java
Outdated
Show resolved
Hide resolved
…ge class represents a chat message. The ChatRequest class represents a request to the Ollama. The ChatResponse class represents a response from the Ollama. The Role enum represents the role of a chat message sender. It also provides a method to convert from ChatMessageType to Role.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fintanmm great job, thank you! There are just a few things that should be addressed and we can merge.
langchain4j-ollama/src/main/java/dev/langchain4j/model/ollama/ChatRequest.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/main/java/dev/langchain4j/model/ollama/OllamaChatModel.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/main/java/dev/langchain4j/model/ollama/OllamaChatModel.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/main/java/dev/langchain4j/model/ollama/OllamaClient.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/test/java/dev/langchain4j/model/ollama/AbstractOllamaInfrastructure.java
Outdated
Show resolved
Hide resolved
langchain4j-ollama/src/main/java/dev/langchain4j/model/ollama/OllamaApi.java
Outdated
Show resolved
Hide resolved
…se. Rename completion to chat. The renaming provides a more descriptive and intuitive name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fintanmm awesome, thank you!
A new implementation of ChatLanguageModel, OllamaChatModel, is added to handle interactions with the Ollama AI and has an associated integration test. This includes necessary configurations and methods for message generation. This increases the project's modularity and provides a more convenient and encapsulated way of interfacing with the Ollama AI.