Skip to content

Commit 710e89c

Browse files
feat: Grafana UI Button (#357)
* feat: grafana ui button --------- Signed-off-by: samuyang <samuyang@cisco.com> Signed-off-by: shanchunyang0919 <71080192+shanchunyang0919@users.noreply.github.com> Co-authored-by: Darren Lau <darrelau@cisco.com>
1 parent 2d21213 commit 710e89c

16 files changed

Lines changed: 709 additions & 642 deletions

File tree

‎coffeeAGNTCY/coffee_agents/corto/exchange/main.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ async def handle_prompt(request: PromptRequest):
5555
HTTPException: 400 for invalid input, 500 for server-side errors.
5656
"""
5757
try:
58-
session_start() # Start a new tracing session
59-
# Process the prompt using the exchange graph
60-
result = await exchange_agent.execute_agent_with_llm(request.prompt)
61-
logger.info(f"Final result from exchange agent: {result}")
62-
return {"response": result}
58+
with session_start() as session_id:
59+
# Process the prompt using the exchange graph
60+
result = await exchange_agent.execute_agent_with_llm(request.prompt)
61+
logger.info(f"Final result from exchange agent: {result}")
62+
return {"response": result, "session_id": session_id["executionID"]}
6363
except ValueError as ve:
6464
logger.exception(f"ValueError occurred: {str(ve)}")
6565
raise HTTPException(status_code=400, detail=str(ve))

‎coffeeAGNTCY/coffee_agents/lungo/agents/supervisors/auction/graph/graph.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ def _general_response_node(self, state: GraphState) -> dict:
483483
"messages": [AIMessage(content="I'm not sure how to handle that. Could you please clarify?")],
484484
}
485485

486-
async def serve(self, prompt: str):
486+
async def serve(self, prompt: str) -> str:
487487
"""
488488
Processes the input prompt and returns a complete response from the graph execution.
489489
@@ -515,7 +515,7 @@ async def serve(self, prompt: str):
515515
"messages": [
516516
{
517517
"role": "user",
518-
"content": prompt
518+
"content": prompt,
519519
}
520520
],
521521
}, {"configurable": {"thread_id": uuid.uuid4()}})

‎coffeeAGNTCY/coffee_agents/lungo/agents/supervisors/auction/main.py‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,12 @@ async def handle_prompt(request: PromptRequest):
100100
HTTPException: 400 for invalid input, 500 for server-side errors.
101101
"""
102102
try:
103-
session_start() # Start a new tracing session for observability
103+
with session_start() as session_id:
104104

105105
# Execute the graph synchronously - blocks until completion
106-
result = await exchange_graph.serve(request.prompt)
107-
logger.info(f"Final result from LangGraph: {result}")
108-
return {"response": result}
106+
result = await exchange_graph.serve(request.prompt)
107+
logger.info(f"Final result from LangGraph: {result}")
108+
return {"response": result, "session_id": session_id["executionID"]}
109109
except ValueError as ve:
110110
raise HTTPException(status_code=400, detail=str(ve))
111111
except Exception as e:
@@ -131,29 +131,29 @@ async def handle_stream_prompt(request: PromptRequest):
131131
HTTPException: 400 for invalid input, 500 for server-side errors.
132132
"""
133133
try:
134-
session_start() # Start a new tracing session for observability
135-
136-
async def stream_generator():
137-
"""
138-
Generator that yields JSON chunks as they arrive from the graph.
139-
Uses newline-delimited JSON (NDJSON) format for streaming.
140-
"""
141-
try:
142-
# Stream chunks from the graph as nodes complete execution
143-
async for chunk in exchange_graph.streaming_serve(request.prompt):
144-
yield json.dumps({"response": chunk}) + "\n"
145-
except Exception as e:
146-
logger.error(f"Error in stream: {e}")
147-
yield json.dumps({"response": f"Error: {str(e)}"}) + "\n"
148-
149-
return StreamingResponse(
150-
stream_generator(),
151-
media_type="application/x-ndjson", # Newline-delimited JSON for streaming
152-
headers={
153-
"Cache-Control": "no-cache", # Prevent caching of streaming responses
154-
"Connection": "keep-alive", # Keep connection open for streaming
155-
}
156-
)
134+
with session_start() as session_id: # Start a new tracing session for observability
135+
136+
async def stream_generator():
137+
"""
138+
Generator that yields JSON chunks as they arrive from the graph.
139+
Uses newline-delimited JSON (NDJSON) format for streaming.
140+
"""
141+
try:
142+
# Stream chunks from the graph as nodes complete execution
143+
async for chunk in exchange_graph.streaming_serve(request.prompt):
144+
yield json.dumps({"response": chunk, "session_id": session_id["executionID"]}) + "\n"
145+
except Exception as e:
146+
logger.error(f"Error in stream: {e}")
147+
yield json.dumps({"response": f"Error: {str(e)}"}) + "\n"
148+
149+
return StreamingResponse(
150+
stream_generator(),
151+
media_type="application/x-ndjson", # Newline-delimited JSON for streaming
152+
headers={
153+
"Cache-Control": "no-cache", # Prevent caching of streaming responses
154+
"Connection": "keep-alive", # Keep connection open for streaming
155+
}
156+
)
157157
except ValueError as ve:
158158
raise HTTPException(status_code=400, detail=str(ve))
159159
except Exception as e:

‎coffeeAGNTCY/coffee_agents/lungo/agents/supervisors/logistics/main.py‎

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ class PromptRequest(BaseModel):
4848
@app.post("/agent/prompt")
4949
async def handle_prompt(request: PromptRequest):
5050
try:
51-
session_start()
52-
timeout_val = int(os.getenv("LOGISTIC_TIMEOUT", "200"))
53-
result = await asyncio.wait_for(
54-
logistic_graph.serve(request.prompt),
55-
timeout=timeout_val
56-
)
57-
logger.info(f"Final result from LangGraph: {result}")
58-
return {"response": result}
51+
with session_start() as session_id:
52+
timeout_val = int(os.getenv("LOGISTIC_TIMEOUT", "200"))
53+
result = await asyncio.wait_for(
54+
logistic_graph.serve(request.prompt),
55+
timeout=timeout_val
56+
)
57+
logger.info(f"Final result from LangGraph: {result}")
58+
return {"response": result, "session_id": session_id["executionID"]}
5959
except asyncio.TimeoutError:
6060
logger.error("Request timed out after %s seconds", timeout_val)
6161
raise HTTPException(status_code=504, detail=f"Request timed out after {timeout_val} seconds")
@@ -129,24 +129,24 @@ async def handle_stream_prompt(request: PromptRequest):
129129
HTTPException: 400 for invalid input, 500 for server-side errors.
130130
"""
131131
try:
132-
session_start()
133-
134-
async def stream_generator():
135-
try:
136-
async for chunk in logistic_graph.streaming_serve(request.prompt):
137-
yield json.dumps({"response": chunk}) + "\n"
138-
except Exception as e:
139-
logger.error(f"Error in stream: {e}")
140-
yield json.dumps({"response": f"Error: {str(e)}"}) + "\n"
141-
142-
return StreamingResponse(
143-
stream_generator(),
144-
media_type="application/x-ndjson",
145-
headers={
146-
"Cache-Control": "no-cache",
147-
"Connection": "keep-alive",
148-
}
149-
)
132+
with session_start() as session_id: # Start a new tracing session for observability
133+
134+
async def stream_generator():
135+
try:
136+
async for chunk in logistic_graph.streaming_serve(request.prompt):
137+
yield json.dumps({"response": chunk, "session_id": session_id["executionID"]}) + "\n"
138+
except Exception as e:
139+
logger.error(f"Error in stream: {e}")
140+
yield json.dumps({"response": f"Error: {str(e)}"}) + "\n"
141+
142+
return StreamingResponse(
143+
stream_generator(),
144+
media_type="application/x-ndjson",
145+
headers={
146+
"Cache-Control": "no-cache",
147+
"Connection": "keep-alive",
148+
}
149+
)
150150
except ValueError as ve:
151151
raise HTTPException(status_code=400, detail=str(ve))
152152
except Exception as e:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v1
2-
appVersion: "0.0.6"
2+
appVersion: "0.0.7"
33
description: A Helm chart for Lungo UI
44
name: lungo-ui
5-
version: 0.0.6
5+
version: 0.0.7

‎coffeeAGNTCY/coffee_agents/lungo/deployment/helm/ui/templates/configmap.tpl.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ metadata:
66
data:
77
VITE_EXCHANGE_APP_API_URL: "{{ .Values.config.exchangeAppApiUrl }}"
88
VITE_LOGISTICS_APP_API_URL: "{{ .Values.config.logisticsAppApiUrl }}"
9+
VITE_GRAFANA_URL: "{{ .Values.config.grafanaUrl }}"
910

‎coffeeAGNTCY/coffee_agents/lungo/deployment/helm/ui/values.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ service:
1919
config:
2020
exchangeAppApiUrl: ""
2121
logisticsAppApiUrl: ""
22+
grafanaUrl: ""
2223

2324
# You can use your own config here for service account
2425
serviceaccount:

‎coffeeAGNTCY/coffee_agents/lungo/docker-compose.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ services:
1313
- DEFAULT_MESSAGE_TRANSPORT=${DEFAULT_MESSAGE_TRANSPORT:-NATS}
1414
- TRANSPORT_SERVER_ENDPOINT=${TRANSPORT_SERVER_ENDPOINT:-nats://nats:4222}
1515
- OTLP_HTTP_ENDPOINT=${OTLP_HTTP_ENDPOINT:-http://otel-collector:4318}
16+
- IDENTITY_AUTH_ENABLED=disabled
1617
- ENABLE_HTTP=true
1718
ports:
1819
- "9999:9999"
@@ -109,6 +110,7 @@ services:
109110
environment:
110111
- VITE_EXCHANGE_APP_API_URL=http://127.0.0.1:8000
111112
- VITE_LOGISTICS_APP_API_URL=http://127.0.0.1:9090
113+
- VITE_GRAFANA_URL=http://127.0.0.1:3001
112114
depends_on:
113115
- auction-supervisor
114116
ports:

0 commit comments

Comments
 (0)