File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
sample-apps/python/genai_service Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 6767 working-directory : lambda-layer/sample-apps
6868 run : aws s3api put-object --bucket ${{ secrets.APP_SIGNALS_E2E_EC2_JAR }}-prod-${{ matrix.aws-region }} --body ./build/function.zip --key pyfunction.zip
6969
70+ - name : Build Gen AI Sample App Zip
71+ working-directory : sample-apps/python/genai_service
72+ run : zip -r python-gen-ai-sample-app.zip .
73+
74+ - name : Upload Gen AI Sample App to S3
75+ working-directory : sample-apps/python/genai_service
76+ run : aws s3api put-object --bucket ${{ secrets.APP_SIGNALS_E2E_EC2_JAR }}-prod-${{ matrix.aws-region }} --body ./python-gen-ai-sample-app.zip --key python-gen-ai-sample-app.zip
77+
Original file line number Diff line number Diff line change 66from langchain_aws import ChatBedrock
77from langchain .prompts import ChatPromptTemplate
88from langchain .chains import LLMChain
9- from opentelemetry import trace
9+ from opentelemetry import trace , metrics
1010from opentelemetry .sdk .trace import TracerProvider
1111from opentelemetry .sdk .trace .export import BatchSpanProcessor , ConsoleSpanExporter
1212from opentelemetry .exporter .otlp .proto .http .trace_exporter import OTLPSpanExporter
1313from openinference .instrumentation .langchain import LangChainInstrumentor
14+ import random
1415
1516# Load environment variables
1617load_dotenv ()
@@ -92,7 +93,15 @@ async def chat(request: ChatRequest):
9293 """
9394 Chat endpoint that processes a single user message through AWS Bedrock
9495 """
96+
9597 try :
98+ # Emit OTel Metrics
99+ meter = metrics .get_meter ("genesis-meter" , "1.0.0" )
100+ request_duration = meter .create_histogram (
101+ name = "Genesis_TestMetrics" , description = "Genesis request duration" , unit = "s"
102+ )
103+ request_duration .record (0.1 + (0.5 * random .random ()), {"method" : "GET" , "status" : "200" })
104+
96105 # Process the input through the chain
97106 result = await chain .ainvoke ({"input" : request .message })
98107 return ChatResponse (response = result ["text" ])
You can’t perform that action at this time.
0 commit comments