Skip to content
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

图片聊天报错 #25

Open
huangpeide opened this issue Nov 15, 2024 · 1 comment
Open

图片聊天报错 #25

huangpeide opened this issue Nov 15, 2024 · 1 comment

Comments

@huangpeide
Copy link

image
public static void main(String[] args) { init(); String question = "最近3天北京的天气怎么样?火车是否允许发车?"; //目前Ollama部署了3个模型:qwen2.5:7b/llama3:8b/llama3.2:3b //向量模型:mxbai-embed-large/nomic-embed-text String model="qwen2.5:7b"; String function = "queryWeather"; String function2 = "queryTrainInfo"; String imageUrl="https://cn.bing.com/images/search?view=detailV2&ccid=r0OnuYkv&id=9A07DE578F6ED50DB59DFEA5C675AC71845A6FC9&thid=OIP.r0OnuYkvsbqBrYk3kUT53AHaKX&mediaurl=https%3a%2f%2fimg.zcool.cn%2fcommunity%2f0104c15cd45b49a80121416816f1ec.jpg%401280w_1l_2o_100sh.jpg&exph=1792&expw=1280&q=%e5%b0%8f%e7%8c%ab%e5%9b%be%e7%89%87&simid=607987191780608963&FORM=IRPRST&ck=12127C1696CF374CB9D0F09AE99AFE69&selectedIndex=2&itb=0&qpvt=%e5%b0%8f%e7%8c%ab%e5%9b%be%e7%89%87"; // 发送对话请求 try { //ResponseBodyEmitter emitter = chatStream(question,model); //chat(question,model); //functionChat(question,model,function,function2); imageChat(question,model,imageUrl); } catch (Exception e) { throw new RuntimeException(e); } }

`"C:\Program Files\Java\jdk1.8.0_261\bin\java.exe" "-javaagent:D:\soft\IntelliJ IDEA 2023.1.2\lib\idea_rt.jar=60061:D:\soft\IntelliJ IDEA 2023.1.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\SKX010330\AppData\Local\Temp\classpath646542043.jar com.d.yunt.llms.AiChatTest
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/apache-maven-3.6.3/repository/ch/qos/logback/logback-classic/1.2.12/logback-classic-1.2.12.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/apache-maven-3.6.3/repository/org/slf4j/slf4j-simple/1.7.36/slf4j-simple-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
十一月 15, 2024 3:11:21 下午 okhttp3.internal.platform.Platform log
信息: --> POST http://172.17.12.72:11434/api/chat
十一月 15, 2024 3:11:21 下午 okhttp3.internal.platform.Platform log
信息: Content-Type: application/json; charset=utf-8
十一月 15, 2024 3:11:21 下午 okhttp3.internal.platform.Platform log
信息: Content-Length: 645
十一月 15, 2024 3:11:21 下午 okhttp3.internal.platform.Platform log
信息: --> END POST
十一月 15, 2024 3:11:21 下午 okhttp3.internal.platform.Platform log
信息: <-- HTTP FAILED: com.d.yunt.llms.exception.CommonException: {"error":"illegal base64 data at input byte 5"}
Exception in thread "main" java.lang.RuntimeException: com.d.yunt.llms.exception.CommonException: {"error":"illegal base64 data at input byte 5"}
at com.d.yunt.llms.AiChatTest.main(AiChatTest.java:54)
Caused by: com.d.yunt.llms.exception.CommonException: {"error":"illegal base64 data at input byte 5"}
at com.d.yunt.llms.exception.chain.impl.OpenAiErrorHandler.parseError(OpenAiErrorHandler.java:33)
at com.d.yunt.llms.exception.chain.ErrorHandler.process(ErrorHandler.java:51)
at com.d.yunt.llms.interceptor.ErrorInterceptor.intercept(ErrorInterceptor.java:48)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
at com.d.yunt.llms.platform.ollama.chat.OllamaAiChatService.chatCompletion(OllamaAiChatService.java:269)
at com.d.yunt.llms.platform.ollama.chat.OllamaAiChatService.chatCompletion(OllamaAiChatService.java:332)
at com.d.yunt.llms.AiChatTest.imageChat(AiChatTest.java:73)
at com.d.yunt.llms.AiChatTest.main(AiChatTest.java:52)

Process finished with exit code 1
`

@LnYo-Cly
Copy link
Owner

你需要选择具有视觉能力的模型,例如llavallama3.2-vision等等。
此外,ollama目前仅支持BASE64格式的图片,需要你自行将URL格式图片转为BASE64类型。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants