atiaomar1978-hub commented on code in PR #25337: URL: https://github.com/apache/camel/pull/25337#discussion_r3722111695
########## components/camel-ai/camel-ai-observability/pom.xml: ########## @@ -0,0 +1,69 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + <modelVersion>4.0.0</modelVersion> + + <parent> + <artifactId>camel-ai-parent</artifactId> + <groupId>org.apache.camel</groupId> + <version>4.22.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-ai-observability</artifactId> + <packaging>jar</packaging> + <name>Camel :: AI :: Observability</name> + <description>GenAI observability support for Camel AI components (OpenTelemetry and Micrometer)</description> + + <properties> + <firstVersion>4.22.0</firstVersion> + <label>ai</label> + <title>AI Observability</title> + <supportLevel>Preview</supportLevel> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-support</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-telemetry</artifactId> + </dependency> + <dependency> + <groupId>io.micrometer</groupId> + <artifactId>micrometer-core</artifactId> + </dependency> Review Comment: Fixed in 2cbf19a16e9: marked `micrometer-core` as `<optional>true</optional>` in camel-ai-observability/pom.xml. Metrics are skipped when no MeterRegistry is present, matching the existing resolveMeterRegistry() design. _AI-generated reply on behalf of atiaomar1978-hub_ ########## components/camel-ai/camel-langchain4j-agent-api/src/main/java/org/apache/camel/component/langchain4j/agent/api/AbstractAgent.java: ########## @@ -65,6 +66,13 @@ protected AgentConfiguration getConfiguration() { return configuration; } + /** + * Returns the LangChain4j chat model configured for this agent. + */ + public ChatModel getChatModel() { Review Comment: Fixed in 2cbf19a16e9: added `@since 4.22` to the `getChatModel()` javadoc on AbstractAgent. _AI-generated reply on behalf of atiaomar1978-hub_ ########## components/camel-ai/camel-ai-observability/src/main/java/org/apache/camel/component/ai/observability/GenAiModelResolver.java: ########## @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.ai.observability; + +import java.lang.reflect.Method; + +/** + * Resolves GenAI provider and model metadata from LangChain4j model beans. + */ +public final class GenAiModelResolver { + + private static final String UNKNOWN = "unknown"; + + private GenAiModelResolver() { + } + + public static String resolveSystem(Object model) { + if (model == null) { + return UNKNOWN; + } + String className = model.getClass().getName().toLowerCase(); + if (className.contains("openai")) { + return "openai"; + } Review Comment: Fixed in 2cbf19a16e9: GenAiModelResolver now uses langchain4j `ModelProvider` and `ChatModel.defaultRequestParameters().modelName()` (with package-prefix fallback). Langchain4j producers use `ChatResponse.modelName()` via `GenAiModelResolver.resolveResponseModelName()` for the response model. _AI-generated reply on behalf of atiaomar1978-hub_ ########## components/camel-ai/camel-openai/src/main/java/org/apache/camel/component/openai/OpenAIProducer.java: ########## @@ -614,11 +628,17 @@ private void processStreaming(Exchange exchange, ChatCompletionCreateParams para exchange.getUnitOfWork().addSynchronization(new Synchronization() { @Override public void onComplete(Exchange e) { + observation.recordSuccess(GenAiUsage.of(null, null, null, requestModel)); Review Comment: Fixed in 2cbf19a16e9: streaming requests now set `stream_options.include_usage=true` and accumulate `CompletionUsage` from the final chunk when recording the GenAI observation (token counts and response model when present). _AI-generated reply on behalf of atiaomar1978-hub_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
