spring-projects / spring-ai

An Application Framework for AI Engineering
https://docs.spring.io/spring-ai/reference/index.html
Apache License 2.0
3.36k stars 866 forks source link

【Spring AI】 pgvector + qianfan Embedding = Embedding failed: error code:3, message:Unsupported openapi method #994

Open MaRuifu opened 5 months ago

MaRuifu commented 5 months ago
<spring-ai.version>1.0.0-SNAPSHOT</spring-ai.version>

<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-qianfan-spring-boot-starter</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.ai</groupId>
    <artifactId>spring-ai-pgvector-store-spring-boot-starter</artifactId>
</dependency>

doc:

@RestController
public class EmbeddingController {

    private final EmbeddingClient embeddingClient;

    @Autowired
    public EmbeddingController(EmbeddingClient embeddingClient) {
        this.embeddingClient = embeddingClient;
    }

    @GetMapping("/ai/embedding")
    public Map embed(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
        EmbeddingResponse embeddingResponse = this.embeddingClient.embedForResponse(List.of(message));
        return Map.of("embedding", embeddingResponse);
    }
}

I didn't find EmbeddingClient through the maven dependency above. I use QianFanEmbeddingModel.

    @Autowired
    private  QianFanEmbeddingModel embeddingClient;

        @Operation(summary = "embedding")
    @GetMapping("/embedding")
    public Map embed(@RequestParam(value = "message", defaultValue = "Tell me a joke") String message) {
        EmbeddingResponse embeddingResponse = embeddingClient.embedForResponse(List.of(message));
        return Map.of("embedding", embeddingResponse);
    }

result:

java.lang.RuntimeException: Embedding failed: error code:3, message:Unsupported openapi method
    at org.springframework.ai.qianfan.QianFanEmbeddingModel.lambda$call$1(QianFanEmbeddingModel.java:135) ~[spring-ai-qianfan-1.0.0-20240701.185347-23.jar:1.0.0-SNAPSHOT]
    at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:335) ~[spring-retry-2.0.5.jar:na]
    at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:211) ~[spring-retry-2.0.5.jar:na]
    at org.springframework.ai.qianfan.QianFanEmbeddingModel.call(QianFanEmbeddingModel.java:114) ~[spring-ai-qianfan-1.0.0-20240701.185347-23.jar:1.0.0-SNAPSHOT]
    at org.springframework.ai.embedding.EmbeddingModel.embedForResponse(EmbeddingModel.java:70) ~[spring-ai-core-1.0.0-20240701.185347-369.jar:1.0.0-SNAPSHOT]
mxsl-gr commented 5 months ago

hi, please make sure the corresponding model is activated by visiting the console page: https://console.bce.baidu.com/qianfan/ais/console/onlineService

MaRuifu commented 4 months ago

It has been opened. It is OK for me to use chat and Embedding separately, but the above problems will arise if pgvector is used

markpollack commented 2 weeks ago

I don't see anything related to PGVector in the stack trace. If you can provide an example code to reproduce it, we can investigate further.