diff --git a/.gitpod.yml b/.gitpod.yml index 1035dbf..b671281 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -9,6 +9,10 @@ ports: onOpen: open-browser - port: 5050 visibility: public + - port: 3000 + visibility: public + onOpen: open-browser + vscode: extensions: - vscjava.vscode-java-pack diff --git a/.vscode/launch.json b/.vscode/launch.json index 0044f2d..c0b7d97 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -96,6 +96,16 @@ "projectName": "rag-springai-ollama-llm", "args": "", "envFile": "${workspaceFolder}/.env" + }, + { + "type": "java", + "name": "Spring Boot-ChatbotOllamaApplication", + "request": "launch", + "cwd": "${workspaceFolder}", + "mainClass": "com.example.chatbot.ChatbotOllamaApplication", + "projectName": "chatbot-ollama-springai", + "args": "", + "envFile": "${workspaceFolder}/.env" } ] } \ No newline at end of file diff --git a/chatbot/chatbot-ollama-springai/docker/docker-compose.yml b/chatbot/chatbot-ollama-springai/docker/docker-compose.yml index 52217cd..aa7f4f8 100644 --- a/chatbot/chatbot-ollama-springai/docker/docker-compose.yml +++ b/chatbot/chatbot-ollama-springai/docker/docker-compose.yml @@ -1,5 +1,11 @@ -version: '3.7' services: + + ollama: + container_name: ollama + image: ollama/ollama:latest + ports: + - '11434:11434' + postgresqldb: container_name: postgresqldb image: pgvector/pgvector:pg17 @@ -41,3 +47,15 @@ services: - "/bin/sh" - "-c" - "/bin/echo 'postgresqldb:5432:*:appuser:secret' > /tmp/pgpassfile && chmod 600 /tmp/pgpassfile && /entrypoint.sh" + + lgtm-stack: + image: grafana/otel-lgtm:0.8.1 + extra_hosts: [ 'host.docker.internal:host-gateway' ] + container_name: lgtm-stack + environment: + - OTEL_METRIC_EXPORT_INTERVAL=500 + ports: + - "3000:3000" + - "4317:4317" + - "4318:4318" + - "9090:9090" diff --git a/chatbot/chatbot-ollama-springai/pom.xml b/chatbot/chatbot-ollama-springai/pom.xml index d0fb050..c72a303 100644 --- a/chatbot/chatbot-ollama-springai/pom.xml +++ b/chatbot/chatbot-ollama-springai/pom.xml @@ -19,6 +19,7 @@ 21 2.43.0 1.0.0-M5 + 2.10.0-alpha @@ -51,6 +52,34 @@ true + + io.micrometer + micrometer-registry-prometheus + runtime + + + io.micrometer + micrometer-tracing-bridge-otel + + + io.opentelemetry + opentelemetry-exporter-otlp + + + io.micrometer + micrometer-registry-otlp + + + net.ttddyy.observation + datasource-micrometer-spring-boot + 1.0.6 + + + io.opentelemetry.instrumentation + opentelemetry-logback-appender-1.0 + runtime + + org.springframework.boot spring-boot-starter-test @@ -81,6 +110,11 @@ postgresql test + + org.testcontainers + grafana + test + @@ -92,6 +126,13 @@ pom import + + io.opentelemetry.instrumentation + opentelemetry-instrumentation-bom-alpha + ${otelInstrumentation.version} + pom + import + diff --git a/chatbot/chatbot-ollama-springai/src/main/java/com/example/chatbot/config/SwaggerConfig.java b/chatbot/chatbot-ollama-springai/src/main/java/com/example/chatbot/config/SwaggerConfig.java new file mode 100644 index 0000000..5bd07eb --- /dev/null +++ b/chatbot/chatbot-ollama-springai/src/main/java/com/example/chatbot/config/SwaggerConfig.java @@ -0,0 +1,10 @@ +package com.example.chatbot.config; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.servers.Server; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +@OpenAPIDefinition(info = @Info(title = "chatbot-ollama-springai", version = "v1.0.0"), servers = @Server(url = "/")) +class SwaggerConfig {} diff --git a/chatbot/chatbot-ollama-springai/src/main/resources/application.properties b/chatbot/chatbot-ollama-springai/src/main/resources/application.properties index 517690f..55bfc70 100644 --- a/chatbot/chatbot-ollama-springai/src/main/resources/application.properties +++ b/chatbot/chatbot-ollama-springai/src/main/resources/application.properties @@ -3,12 +3,29 @@ spring.application.name=chatbot-ollama spring.threads.virtual.enabled=true spring.mvc.problemdetails.enabled=true -spring.ai.ollama.init.pull-model-strategy=when_missing +spring.ai.ollama.init.pull-model-strategy=WHEN_MISSING spring.ai.ollama.chat.options.model=llama3.2 # default is mxbai-embed-large spring.ai.ollama.embedding.model=nomic-embed-text #PgVector spring.ai.vectorstore.pgvector.initialize-schema=true +spring.ai.vectorstore.pgvector.schema-validation=true + +##Observability +spring.ai.vectorstore.observations.include-query-response=true +spring.ai.chat.observations.include-completion=true +spring.ai.chat.observations.include-prompt=true +spring.ai.chat.client.observations.include-input=true + +management.endpoints.web.exposure.include=* +management.metrics.tags.service.name=${spring.application.name} +management.tracing.sampling.probability=1.0 +management.otlp.tracing.endpoint=http://localhost:4318/v1/traces +management.otlp.logging.endpoint=http://localhost:4318/v1/logs spring.testcontainers.beans.startup=parallel + +spring.datasource.url=jdbc:postgresql://localhost:5432/appdb +spring.datasource.username=appuser +spring.datasource.password=secret diff --git a/chatbot/chatbot-ollama-springai/src/main/resources/logback-spring.xml b/chatbot/chatbot-ollama-springai/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..1e2ef31 --- /dev/null +++ b/chatbot/chatbot-ollama-springai/src/main/resources/logback-spring.xml @@ -0,0 +1,16 @@ + + + + + + true + true + true + + + + + + +