Skip to content

Fix OpenAI generic options merging for image, audio, embedding and moderation #6042

@1233567890

Description

@1233567890

我的代码

	@Autowired
	private OpenAiEmbeddingModel model;
	@Test
	public void ss(){
		EmbeddingResponse floats = model.call(new EmbeddingRequest(List.of("发动机"), EmbeddingOptions.builder().model("bge-multilingual-gemma2").build()));
		System.out.println(floats);
	}

pom配置

<dependency>
			<groupId>org.springframework.ai</groupId>
			<artifactId>spring-ai-starter-model-openai</artifactId>
			<version>2.0.0-M6</version>
		</dependency>

application.yml结构

ai:
    openai:
      base-url: http://192.168.10.233:3000/v1
      api-key: sk-NV44FDGiuspxz27Z1eZqaR2l4YIXI1X1pHgGR5w12i2SI3vS

我确认把配置改成

ai:
   openai:
     embedding:
       model: bge-multilingual-gemma2
     base-url: http://192.168.10.233:3000/v1
     api-key: sk-NV44FDGiuspxz27Z1eZqaR2l4YIXI1X1pHgGR5w12i2SI3vS

这样可以正常工作
如果不修改配置,错误信息如下

com.openai.errors.InternalServerException: 503: No available channel for model text-embedding-ada-002 under group default (distributor) (request id: 202605150707403555553008268d9d6muyPcHkN)

at com.openai.errors.InternalServerException$Builder.build(InternalServerException.kt:95)
at com.openai.core.handlers.ErrorHandler$errorHandler$1.handle(ErrorHandler.kt:79)
at com.openai.core.handlers.ErrorHandler$errorHandler$1.handle(ErrorHandler.kt:40)
at com.openai.services.blocking.EmbeddingServiceImpl$WithRawResponseImpl.create(EmbeddingServiceImpl.kt:80)
at com.openai.services.blocking.EmbeddingServiceImpl.create(EmbeddingServiceImpl.kt:44)
at com.openai.services.blocking.EmbeddingService.create(EmbeddingService.kt:33)
at org.springframework.ai.openai.OpenAiEmbeddingModel.lambda$call$2(OpenAiEmbeddingModel.java:222)
at io.micrometer.observation.Observation.observe(Observation.java:629)
at org.springframework.ai.openai.OpenAiEmbeddingModel.call(OpenAiEmbeddingModel.java:221)
at cn.yuanshivr.chat_example_manager.ChatExampleManagerApplicationTests.ss(ChatExampleManagerApplicationTests.java:90)

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions