alibaba / spring-ai-alibaba

An Application Framework for Java Developers
https://sca.aliyun.com/ai
Apache License 2.0
460 stars 131 forks source link

AbstractMethodError #72

Open qiqi5526 opened 4 weeks ago

qiqi5526 commented 4 weeks ago

I got a AbstractMethodError when I call DashScope Chat Model for getting keyword of a document

the code like below

` public static void main(String[] args) {

    DashScopeApi dashScopeApi = new DashScopeApi("7777777777");
    DashScopeChatOptions options = DashScopeChatOptions.builder()
            .withModel("qwen2-vl-7b-instruct")
            .withTemperature(0.7f)
            .build();
    DashScopeChatModel chatModel = new DashScopeChatModel(dashScopeApi,options);// initialize your chat model
    KeywordMetadataEnricher enricher = new KeywordMetadataEnricher(chatModel, 5);

    Document doc = new Document("This is a document about artificial intelligence and its applications in modern technology.");

    List<Document> enrichedDocs = enricher.apply(List.of(doc));

    Document enrichedDoc = enrichedDocs.get(0);
    String keywords = (String) enrichedDoc.getMetadata().get("excerpt_keywords");
    System.out.println("Extracted keywords: " + keywords);
}`

the exception as:

/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home/bin/java -javaagent:/Applications/IntelliJ IDEA er Exception in thread "main" java.lang.AbstractMethodError: Method com/alibaba/cloud/ai/dashscope/chat/DashScopeChatOptions.getToolContext()Ljava/util/Map; is abstract at com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions.getToolContext(DashScopeChatOptions.java) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:688) at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:770) at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:183)

my pom:

com.alibaba.cloud.ai spring-ai-alibaba-starter 1.0.0-M2.1 org.springframework.ai spring-ai-pdf-document-reader 1.0.0-M3 org.springframework.ai spring-ai-tika-document-reader 1.0.0-M3
lyqiangyuan commented 4 weeks ago

I also encountered the same problem and later discovered that in spring-ai-alibaba-core-1.0-02.1. jar, There is no getToolContext method in the com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptionsclass.

yuluo-yx commented 3 weeks ago

最近会发布一个新版本出来