New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dashboard: Auto-generate panel title and description using AI #74284
Dashboard: Auto-generate panel title and description using AI #74284
Conversation
…d placeholder generate buttons to panel title + description
…generation button
…that is passed to wrapping components
@@ -0,0 +1,30 @@ | |||
import { css } from '@emotion/css'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Naming is hard... wasnt sure to keep with DashGPT
or just try to make it more general to generative AI - i dont feel strongly either way so please feel free to modify any and all naming 😅
import { getDashboardSrv } from '../../services/DashboardSrv'; | ||
|
||
// TODO: Replace this approach with more stable approach | ||
export const SPECIAL_DONE_TOKEN = '~'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file definitely needs some work - we should move away from hacky special done token in favor of receiving done result from llm plugin API directly
Also we should consider a better way to share this code betwen title / description generation + potentially more use cases (at the very least use an enum
instead of passing around "title" and "description" everywhere
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not concentrate all possible "Generative AI calls" in a single place. Instead, every component will contain the prompt to be sent. Then this service will become just a simplification of the llm librarly API, which it creates a signal of: Are we duplicating with no reason? Can we just modify the llm library if we find it hard to use?
IMO, we just should use llm directly with no services in between.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should be able to move the odd logic around detecting if streams are done into the grafana/experimental package so that we don't have to do this oddball logic with it.
…tle-and-description-generation
public/app/features/dashboard/components/PanelEditor/getPanelFrameOptions.tsx
Show resolved
Hide resolved
public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx
Show resolved
Hide resolved
Taking a look to the implementation, do you think we can create a component to group all the functionalities for the generation? Something like: <AutoGenerateWithAI messages={} onGenerateOutput={(result) => setState(result)} onClick={trackUsage} /> |
…el-title-and-description-generation
…o GenAI button to ensure consistency
I did a big refactor to simplify the implementation
|
…n' of https://github.com/grafana/grafana into dashgpt-implement-panel-title-and-description-generation
I pushed a bunch of changes, the PR should be ready to be reviewed 😄
About the usage of the character to detect the end of the stream, it should be fixed in |
@nmarrs since I changed quite a lot of code, I'd like to get your review, before merging, because you opened the PR 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code wise this is looking great IMO for initial POC 👍 I'm not able to approve this as I created PR but consider this APPROVED 💯✅
public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx
Show resolved
Hide resolved
*/ | ||
export function cleanupResponse(response: string) { | ||
return response.replace(SPECIAL_DONE_TOKEN, '').replace(/"/g, ''); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love all of the included doc strings here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved by @nmarrs
const input = document.getElementById('PanelFrameTitle'); | ||
if (input instanceof HTMLInputElement) { | ||
input.value = title; | ||
onPanelConfigChange('title', title); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nmarrs
why the getElementById here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, pinged wrong person, was supposed to ping @ivanortegaalba
* Add "addon" prop to options panel item descriptor; add placeholder generate buttons to panel title + description * Add basic `ai` icon; add separate wrapping component for panel title generation button * Add basic panel title generation * Add basic panel description generation * Add configuration error state for GenAI button * Add GenAI button generic component --------- Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com> Co-authored-by: Adela Almasan <adela.almasan@grafana.com>
What is this feature?
Implements basic panel title and description generation.
Roughly based on the DashGPT hackathon PR but with some cleaned up patterns / refactors to make this functionality more maintainable moving forward :)
TODO
~
system and doing something more robust from the actual API call for gettingdone
statusWhich issue(s) does this PR fix?:
Fixes #74241
Fixes #74242
Special notes for your reviewer:
Please check that: