-
Notifications
You must be signed in to change notification settings - Fork 102
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 ollama support #35
Conversation
Welcome for your pull request, Please check this contributing.md. And run ./gradlew check before push code. |
@@ -1,12 +1,12 @@ | |||
package com.zhongan.devpilot.integrations.llms; | |||
|
|||
import com.google.gson.Gson; |
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.
We do not recommend to use gson, please use jackson.
@@ -47,7 +47,8 @@ public void onEvent(@NotNull EventSource eventSource, @Nullable String id, @Null | |||
return; | |||
} | |||
|
|||
var response = JsonUtils.fromJson(data, DevPilotSuccessStreamingResponse.class); | |||
// var response = JsonUtils.fromJson(data, DevPilotSuccessStreamingResponse.class); |
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.
I didn't originally intend to modify this, but the existing code is causing errors. Does it not produce any errors when you run the code ?
Unrecognized field "system_fingerprint" (class com.zhongan.devpilot.integrations.llms.entity.DevPilotSuccessStreamingResponse), not marked as ignorable
there's a property named system_fingerprint
in data
, but DevPilotSuccessStreamingResponse
has no such property. how about add a system_fingerprint
property to class DevPilotSuccessStreamingResponse
?
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.
Maybe you can use such "@JsonIgnoreProperties(ignoreUnknown = true)" to ignore unused field
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.
ok, I have already modified it according to your suggestion and pushed.
…pilot.integrations.llms.entity.DevPilotSuccessStreamingResponse), not marked as ignorable
import com.google.gson.JsonArray; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
import com.google.gson.JsonParser; |
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.
There's still some gson dependency
try { | ||
var request = new Request.Builder() | ||
.get() | ||
.url(host + "/api/tags") | ||
.build(); | ||
Call call = OkhttpUtils.getClient().newCall(request); | ||
okhttp3.Response response = call.execute(); | ||
if (response.isSuccessful()) { | ||
var result = Objects.requireNonNull(response.body()).string(); | ||
JsonObject dataJson = JsonParser.parseString(result).getAsJsonObject(); | ||
JsonArray modelArray = dataJson.get("models").getAsJsonArray(); | ||
for (JsonElement modelEle : modelArray) { | ||
String modelName = modelEle.getAsJsonObject().get("name").getAsString(); | ||
ollamaModelComboBox.addItem(modelName); | ||
} | ||
} | ||
response.close(); | ||
} catch (Exception ex) { | ||
// throw new RuntimeException(ex); | ||
JOptionPane.showMessageDialog(null, DevPilotMessageBundle.get("devpilot.settings.service.ollamaHostError"), DevPilotMessageBundle.get("devpilot.settings.service.dialog.error"), JOptionPane.ERROR_MESSAGE); |
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.
Maybe the api implement should in seperate utils or provider, it's strange that api call in form
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.
ok
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.
how about add a listModels
method to LlmProvider? openai also has list modes api: https://api.openai.com/v1/models
, it's better to get models using an API instead of hardcoding it in OpenAIModelNameEnum. What is your opinion?
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.
It's all right, but it's better to have a default implement to prevent effect other implements
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.
please review again, thank you.
hello @moqimoqidea you are welcome. The issue you mentioned does not appear on my end. |
…st model request in provider instead of in form; use jackson to parse response instead of gson.
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.
LGTM
@xiangtianyu thank you for your review, do we need other members to review before this PR can be merged? |
hello @xiangtianyu Perhaps @PerryZhao has been quite busy lately. Is there anyone else who can review it? |
* feat: add ollama support * fix:checkstyle problems * bugfix:Unrecognized field "system_fingerprint" (class com.zhongan.devpilot.integrations.llms.entity.DevPilotSuccessStreamingResponse), not marked as ignorable * list openai models using API instead of hardcoding in enum; handle list model request in provider instead of in form; use jackson to parse response instead of gson.
* 1.0.0-RELEASE * Feature/improve code * limit response in md format * fix test err * 变更报名和项目名称 * 修复不可变list导致的add报错问题 * Release/1.1.0 * Code refactor * 现在默认会优先去找系统中的用户名字 * fix source code jump * Add some test cases * add generate-tests unit test * multi model * Revert "Merge branch 'test-generate-unit-test' into 'develop'" This reverts merge request !62 * update style * fix getIcon err * [PTAR-T-585887] Internal/develop * Merge github * Fix release link and some other minor format issues. * Revert "Merge branch 'cherry-pick-1_2_0' into 'develop'" This reverts merge request !71 * Feature/za sso * Feature/github sso * 2.1.0 * [PTAR-T-593451] Extract markdown contents for diff view. * commit code complete(代码未整理) * move code location * update suggest code * update suggest code * update * update setting(代码需要精简) * remove unused code files(代码需要精简) * remove unused code files(todo 代码需要精简) * remove unused code files * updatea CompletionMetadata * remove unused code files * remove unused code files(todo remove look element) * remove unused code files * remove unused code files * remove unused code files * remove unused code files * remove unused code files * update accept action * update document listener * remove unused code files * rework code files * rework code files * rework code files * rework code files * rework code files * rework code files * rework code files * rework code files * rework code files * rework code files * code convert * code to java * add code completion config * add code completion config * add status bar * add status bar * rework code * rework code * rework code * 快捷键开启与自动补全不关联 * trial improve * auto format code(checkstyle) * merge code * merge code * add completion status change * add completion status change * add completion status change * add completion status change * Feature/wx login * Refactor AI gateway completion URL and remove a deprecated constant Changed the `AI_GATEWAY_INSTRUCT_COMPLETION` constant in the `DefaultConst` class from `/ai/test/azure/gpt-35-turbo-instruct/completions` to `/devpilot/v1/completions`. In the `AIGatewayServiceProvider` class, removed the usage of the deprecated constant `AI_GATEWAY_INSTRUCT_COMPLETION_ACCESS_KEY_TEMP` and its associated header. * Update project version to "2.2.0". Create JBCefBrowser with "createBrowser()" method. Update "EMPTY_SYMBOL" value to a space character. * Fix checkstyle errors * Update change-notes in plugin.xml * modify default source string and update page * Feature/create new file multi language * update page * ignore json unknown * 2.3.0 * json set * [PTAR-PR-623929] Refactor GitlabUtil.java to improve the logic for getting the remote URL of a Git repository. The changes include adding a new parameter `VirtualFile file` to the `getRemoteUrl` method, and refactoring the logic to handle cases where the `.git/config` file is not found in the project's base path. * DevPilot名称修改 * Release 2.3.0. Marketplace uploaded 0307. * login unify * delete unuse code and modify auth utils * login type config fix * import fix * code completion trigger rule update * theme bug fix and white flash bug fix * update comment content check * remove unused code * update check rule info * update check rule info * update check rule info * update keyup * update keyup * 登录改造 * fix locate bug * Feature/chat shortcut * [PTAR-PR-630459]Add Intellij IDEA 2024.1.x supports * telemetry upload * Feature/host fix * Feature/embed hint * Prefix suffix max limit * Release0326 * web page fix * update var name * Add session clear * Feature/version compatibility * Default language for RAG * Feature/improve completion * completions conflict fix. * update index.html to highlight code in chat view * Add headers to the requests in CompletionFacade.java and AIGatewayServiceProvider.java - Include User-Agent and Auth-Type headers in the request in CompletionFacade.java - Change header "Embedded-Repos" to "Embedded-Repos-V2" and add "X-B3-Language" header in the request in AIGatewayServiceProvider.java * Upgrade index.html for rag context * Refactor CompletionUtils to use StringUtils for string manipulation. Improve readability and consistency in the code. Remove unused import in ManualTriggerDevPilotInlineCompletionAction. * Refactor LlmProvider and DevPilotSuccessStreamingResponse for handling response content and streaming. Add support for RagResp containing files in streaming response. * rag 文件定位跳转 * rag repo优化 * 修复rag路径问题 * fix label * Feature/plugin update check * webview 初始化时添加变量用于记录指标 * Task/exception fix * support mulit-language and conversationWindowMemory * Update index.html for context menu. * add jtokkit dependence * fix check style * Fix some bug * 2.4.2 * 修复checkstyle * Prepare for github * auto import * auto import * auto import * auto import * auto import * auto import * 修改readme * 修改网关描述指向github仓库 * 修改默认服务端口为8085 * Prompts move to gateway. * feat: add ollama support (#35) * feat: add ollama support * fix:checkstyle problems * bugfix:Unrecognized field "system_fingerprint" (class com.zhongan.devpilot.integrations.llms.entity.DevPilotSuccessStreamingResponse), not marked as ignorable * list openai models using API instead of hardcoding in enum; handle list model request in provider instead of in form; use jackson to parse response instead of gson. * remove LlamaServiceProvider.java * Prompts move to gateway. * Adjust request data. * answerLanguage * Rename prompts command. * prompts 服务端化改造。 * code refine. * Refine code. --------- Co-authored-by: 赵鹏俊 <[email protected]> Co-authored-by: xiangtianyu <[email protected]> Co-authored-by: 陈耀 <[email protected]> Co-authored-by: 肖亮 <[email protected]> Co-authored-by: 赵鹏俊 <[email protected]> Co-authored-by: yangxuefeng <[email protected]> Co-authored-by: geeklog <[email protected]> Co-authored-by: zhangzhisheng <[email protected]> Co-authored-by: 毛镇 <[email protected]> Co-authored-by: 刘海鹏 <[email protected]> Co-authored-by: zhen.mao <[email protected]>
No description provided.