Skip to content

Commit 24056e4

Browse files
author
nickchecan
committed
chore: create placeholder for ollama chat class
1 parent d2d8185 commit 24056e4

File tree

8 files changed

+141
-0
lines changed

8 files changed

+141
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.developer.nefarious.zjoule.plugin.chat.ollama;
2+
3+
import java.net.http.HttpRequest.BodyPublisher;
4+
import java.util.List;
5+
6+
import com.developer.nefarious.zjoule.plugin.chat.IChatMessage;
7+
8+
/**
9+
* Defines helper methods for interacting with the Ollama service.
10+
* This interface provides functionality for processing chat completion requests
11+
* and parsing responses returned by Ollama.
12+
*/
13+
public interface IOllamaClientHelper {
14+
15+
/**
16+
* Converts a serialized JSON response body from the Ollama service into an {@link IChatMessage}.
17+
* The method deserializes the response and extracts the first message returned by the AI.
18+
*
19+
* @param serializedResponseBody the JSON response body as a {@link String}.
20+
* @return the first {@link IChatMessage} extracted from the response.
21+
*/
22+
IChatMessage convertResponseToObject(final String serializedResponseBody);
23+
24+
/**
25+
* Creates an HTTP request body for a chat completion request to the Ollama service.
26+
* The request body includes parameters such as:
27+
* <ul>
28+
* <li>Chat messages providing the context for the conversation.</li>
29+
* <li>Maximum number of tokens allowed for the response.</li>
30+
* <li>Temperature, frequency penalty, and presence penalty settings.</li>
31+
* <li>Stop sequences for terminating the response.</li>
32+
* </ul>
33+
*
34+
* @param messages a list of {@link IChatMessage} objects representing the chat context.
35+
* @return a {@link BodyPublisher} object containing the serialized request body.
36+
*/
37+
BodyPublisher createRequestBody(final List<IChatMessage> messages);
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.developer.nefarious.zjoule.plugin.chat.ollama;
2+
3+
import com.developer.nefarious.zjoule.plugin.chat.IChatMessage;
4+
import com.developer.nefarious.zjoule.plugin.models.Role;
5+
6+
public class OllamaChatMessage implements IChatMessage {
7+
8+
@Override
9+
public String getMessage() {
10+
// TODO Auto-generated method stub
11+
return null;
12+
}
13+
14+
@Override
15+
public Role getRole() {
16+
// TODO Auto-generated method stub
17+
return null;
18+
}
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.developer.nefarious.zjoule.plugin.chat.ollama;
2+
3+
import java.io.IOException;
4+
import java.util.List;
5+
6+
import com.developer.nefarious.zjoule.plugin.chat.IAIClient;
7+
import com.developer.nefarious.zjoule.plugin.chat.IChatMessage;
8+
import com.developer.nefarious.zjoule.plugin.models.Role;
9+
10+
public class OllamaClient implements IAIClient {
11+
12+
public OllamaClient(
13+
) {
14+
15+
}
16+
17+
@Override
18+
public IChatMessage chatCompletion(List<IChatMessage> messages) throws IOException, InterruptedException {
19+
// TODO Auto-generated method stub
20+
return null;
21+
}
22+
23+
@Override
24+
public IChatMessage createMessage(Role role, String userPrompt) {
25+
// TODO Auto-generated method stub
26+
return null;
27+
}
28+
29+
@Override
30+
public List<IChatMessage> getMessageHistory() {
31+
// TODO Auto-generated method stub
32+
return null;
33+
}
34+
35+
@Override
36+
public void setMessageHistory(List<IChatMessage> messages) {
37+
// TODO Auto-generated method stub
38+
39+
}
40+
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.developer.nefarious.zjoule.plugin.chat.ollama;
2+
3+
import java.net.http.HttpRequest.BodyPublisher;
4+
import java.util.List;
5+
6+
import com.developer.nefarious.zjoule.plugin.chat.IChatMessage;
7+
8+
public class OllamaClientHelper implements IOllamaClientHelper {
9+
10+
@Override
11+
public IChatMessage convertResponseToObject(String serializedResponseBody) {
12+
// TODO Auto-generated method stub
13+
return null;
14+
}
15+
16+
@Override
17+
public BodyPublisher createRequestBody(List<IChatMessage> messages) {
18+
// TODO Auto-generated method stub
19+
return null;
20+
}
21+
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.developer.nefarious.zjoule.plugin.chat.ollama;
2+
3+
public class OllamaRequestBody {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.developer.nefarious.zjoule.plugin.chat.ollama;
2+
3+
public class OllamaRequestResponse {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.developer.nefarious.zjoule.test.chat.ollama;
2+
3+
public class OllamaClientTest {
4+
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.developer.nefarious.zjoule.test.chat.ollama;
2+
3+
public class OllamaRequestBodyTest {
4+
5+
}

0 commit comments

Comments
 (0)