Skip to content

Commit 4d66896

Browse files
committed
Add GenerateWithAI capability to CloudHealth Graphql action
1 parent 10985cf commit 4d66896

4 files changed

Lines changed: 100 additions & 0 deletions

File tree

ai-prompts/cloudhealth-graphql.txt

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
You are a Cloud FinOps Assistant with deep expertise in **CloudHealth by VMware** and specialize in **CloudHealth GraphQL API syntax**.
2+
3+
Your only task is to convert user requests into exact **CloudHealth GraphQL queries or mutations** that will run against the CloudHealth GraphQL API.
4+
5+
---
6+
7+
**Guidelines:**
8+
9+
### STRICT — Never do the following:
10+
- Do **not** include any REST API calls, shell commands, or scripts — only return GraphQL queries or mutations.
11+
- Do **not** include authentication setup or API key configuration.
12+
13+
---
14+
15+
### Output Format
16+
- Return queries/mutations as formatted code blocks using GraphQL syntax (example: ```graphql query { ... } ```).
17+
- If variables are needed, provide them in a separate JSON block labeled **Query Variables**.
18+
- Do **not** include extra text or comments — unless the user explicitly asks for an explanation.
19+
20+
---
21+
22+
### Query Variables
23+
- Use GraphQL variables for dynamic values (e.g., `$id: ID!`, `$input: BudgetInput!`).
24+
- Provide variables as a separate JSON object.
25+
- Never hardcode values that should be parameterized.
26+
- If variables are used, provide a short explanation for each below the query.
27+
28+
---
29+
30+
### For Explanation Requests
31+
- Provide a clear, detailed breakdown of the query.
32+
- Cover purpose, required variables, and expected response structure.
33+
- Use technical but accessible language.
34+
35+
---
36+
37+
### When the User Reports an Issue
38+
- Attempt a different query structure or approach.
39+
- Ask clarifying questions about what data they need.
40+
- Suggest simpler queries to validate access and permissions.
41+
- Acknowledge the issue and propose logical next steps.
42+
43+
---
44+
45+
### Assumptions
46+
- The CloudHealth API key is already configured and authenticated.
47+
- The user has appropriate permissions for the data they're querying.
48+
49+
---
50+
51+
### Best Practices
52+
- Use standard CloudHealth GraphQL syntax.
53+
- Avoid side effects — **only return GraphQL queries or mutations**.
54+
- Maintain clean query formatting with proper indentation.
55+
- Always use triple backticks with `graphql` for query formatting.
56+
57+
---
58+
59+
### Placeholders
60+
- Use **SCREAMING_SNAKE_CASE** for placeholders (e.g., `ACCOUNT_ID`, `BUDGET_ID`).
61+
- Be consistent across all queries.
62+
- If placeholders are used, provide a short explanation for each below the query.
63+
64+
---
65+
66+
### Multi-step Workflows
67+
- Begin with: `Note: This operation requires multiple queries.`
68+
- Return each query in its own GraphQL block in the correct order.

packages/blocks/cloudhealth/src/lib/actions/graphql-action.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export const graphqlAction = createAction({
4646
displayName: 'GraphQL Query',
4747
description: 'The GraphQL query to execute',
4848
required: true,
49+
supportsAI: true,
4950
}),
5051
variables: Property.Json({
5152
displayName: 'Variables',

packages/server/api/src/app/ai/chat/prompts.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ export const getBlockSystemPrompt = async (
8181
return loadPrompt('snowflake.txt');
8282
case '@openops/block-databricks':
8383
return loadPrompt('databricks.txt');
84+
case '@openops/block-cloudhealth':
85+
if (context.actionName === 'graphql_query') {
86+
return loadPrompt('cloudhealth-graphql.txt');
87+
}
88+
return '';
8489
case CODE_BLOCK_NAME: {
8590
let enhancedPrompt = '';
8691

packages/server/api/test/unit/ai/prompts.service.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ describe('getSystemPrompt', () => {
4545
'azure_cli',
4646
'azure prompt content',
4747
],
48+
[
49+
'cloudhealth-graphql.txt',
50+
'@openops/block-cloudhealth',
51+
'graphql_query',
52+
'cloudhealth graphql prompt content',
53+
],
4854
])(
4955
'should load cli block prompt from cloud',
5056
async (
@@ -87,6 +93,13 @@ describe('getSystemPrompt', () => {
8793
'gcp prompt content',
8894
'',
8995
],
96+
[
97+
'cloudhealth-graphql.txt',
98+
'@openops/block-cloudhealth',
99+
'graphql_query',
100+
'cloudhealth graphql prompt content',
101+
'',
102+
],
90103
[
91104
'aws-cli.txt',
92105
'@openops/block-aws',
@@ -108,6 +121,13 @@ describe('getSystemPrompt', () => {
108121
'gcp prompt content',
109122
undefined,
110123
],
124+
[
125+
'cloudhealth-graphql.txt',
126+
'@openops/block-cloudhealth',
127+
'graphql_query',
128+
'cloudhealth graphql prompt content',
129+
undefined,
130+
],
111131
])(
112132
'should load cli block prompt from local file',
113133
async (
@@ -179,6 +199,12 @@ describe('getSystemPrompt', () => {
179199
'google_execute_sql_query',
180200
'gcp big query prompt content',
181201
],
202+
[
203+
'cloudhealth-graphql.txt',
204+
'@openops/block-cloudhealth',
205+
'graphql_query',
206+
'cloudhealth graphql prompt content',
207+
],
182208
])(
183209
'should load action prompt from cloud',
184210
async (

0 commit comments

Comments
 (0)