mirror of
https://github.com/SigNoz/signoz.git
synced 2026-05-17 23:50:27 +01:00
* feat: add AI Assistant with interactive blocks for data visualization * feat: add AI Assistant with interactive blocks for data visualization * chore: format taglines for better readability in AIAssistantIconPreview * feat: add AI Assistant action block and speech recognition capabilities * feat: enhance voice input functionality and integrate streaming chat * feat: implement message feedback component and enhance message bubble styling * feat: enhance AI Assistant SSE event handling and markdown rendering Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * feat: implement thread management and feedback submission in AI Assistant * feat: refactor AI Assistant state management to support per-conversation streaming * chore: remove unused icons and page * feat: introduce thinking step and message block structure in AI Assistant * refactor: update Tooltip imports to use @signozhq/ui across components * refactor: migrate button components to @signozhq/ui and update styles for consistency * feat: enhance home header layout with new HeaderRightSection component and updated styles * refactor: improve code readability and consistency * feat: integrate AI assistant feature with conditional routing and environment configuration * feat: update openapi.yml and improve ui * feat: add character limit warning to ChatInput component * feat: enhance AI Assistant button with pending user input badge and styles * feat: implement conversation archiving and restoration functionality in AI Assistant * feat: streamline AI Assistant UI components and improve styles * feat: add MessageContext interface and enhance message sending functionality in AI Assistant * feat: update AI Assistant styles and components to use new icon library and improve layout * feat: move to css modules * feat: enhance AI Assistant with new API integration and UI components * refactor: update AIAssistant components to use Button from Signoz UI and enhance styling * refactor: simplify action handling and enhance streaming message indicators * refactor: improve loading indicators in HistorySidebar component * refactor: enhance ConversationView loading state and improve action key stability * refactor: implement AIAssistant axios instance and enhance SSE authentication handling * refactor: support auto-derived contexts and enhance diff display functionality * refactor: enhance ChatInput component with improved overflow handling and context fetching logic * refactor: enhance AIAssistantModal and ConversationItem components with improved key handling and UI * refactor: streamline Spinner component and update ChatInput styles for improved UI consistency * feat: implement push-to-talk functionality in ChatInput for improved voice interaction * feat: add edit and resend functionality to user messages in ConversationView and ChatInput * feat: implement AI Assistant UI components for enhanced user interaction * feat: improve tool call instance rendering * feat: add accessibility attributes and feedback buttons to HeaderRightSection * chore: update openapi.yaml with improved formatting and structure for API documentation * feat: enhance AI Assistant components with new enums, improved clarification handling, code block * refactor: remove edit and resend functionality, streamline message handling * refactor: remove AI backend URL from environment variables * refactor: update styles and structure for MessageBubble, ThinkingStep, and ToolCallStep components * feat: enhance conversation item and history sidebar with search functionality and dropdown actions * feat: update AI Assistant UI components with new icons * feat: add displayText property to ToolCallBlock * feat: implement message regeneration functionality in AI Assistant * feat: pass comment for negative feedback * fix(frontend): position chat support around AI assistant * feat: add SigNoz URL header to AI Assistant requests for multi-tenant support * feat: add header actions to TraceDetailV2 for sharing and feedback * chore: remove hardcoded url * fix: skip custom AI block markers in language validation script * feat: implement AI API instance with request/response interceptors * feat: enhance AI Assistant conversation handling with hydration state * feat: implement SSE backoff strategy and error handling in AI Assistant * refactor: update color variables in AI Assistant styles for consistency and improved theming * chore: increase margin for title in Block component for improved spacing * chore: fmt * feat: use default domain url for X-SigNoz-URL * refactor: simplify AIAssistant enabled state management across components * refactor: replace HistorySidebar with ConversationsList component in AIAssistant * feat: improve css * feat: enhance voice input functionality with microphone permission handling * feat: add rule to enforce subpath imports for @signozhq/ui components * fix: renameConversation requires reload to render * refactor: update imports for @signozhq/ui components to use subpath imports * refactor: adjust imports for @signozhq/ui components to use specific subpath imports * chore: remove temp files * chore: remove temp files * chore: move types to ai assistant folder * chore: remove unused chart blocks from AI assistant Removes BarChart, LineChart, PieChart, and Timeseries block components along with the shared chartSetup and Chart.module.scss. These rendered hex-color literals outside the design-token system and weren't being emitted by any current response flow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * feat: update header button color to use accent primary * chore: remove the rule files * chore: remove react chartjs * refactor: replace hardcoded radius values with CSS variables * chore: use css variable --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: makeavish <makeavish786@gmail.com>
81 lines
2.8 KiB
TypeScript
81 lines
2.8 KiB
TypeScript
import axios, { InternalAxiosRequestConfig } from 'axios';
|
|
|
|
import {
|
|
interceptorRejected,
|
|
interceptorsRequestBasePath,
|
|
interceptorsRequestResponse,
|
|
interceptorsResponse,
|
|
} from 'api';
|
|
import { getSigNozInstanceUrl } from 'utils/signozInstanceUrl';
|
|
|
|
/** Path-only base for the AI Assistant API. */
|
|
export const AI_API_PATH = '/api/v1/assistant';
|
|
|
|
/** Header that tells the AI backend which SigNoz instance to query against. */
|
|
export const SIGNOZ_URL_HEADER = 'X-SigNoz-URL';
|
|
|
|
/**
|
|
* Sets `X-SigNoz-URL` on every outgoing AI Assistant request. The backend
|
|
* needs the originating SigNoz instance URL for multi-tenant deployments;
|
|
* when omitted it falls back to its `SIGNOZ_API_URL` env var.
|
|
*/
|
|
export const interceptorsRequestSigNozUrl = (
|
|
value: InternalAxiosRequestConfig,
|
|
): InternalAxiosRequestConfig => {
|
|
if (value.headers) {
|
|
value.headers[SIGNOZ_URL_HEADER] = getSigNozInstanceUrl();
|
|
}
|
|
return value;
|
|
};
|
|
|
|
/**
|
|
* AI backend URL — sourced from the global config's `ai_assistant_url` field
|
|
* at runtime. `useIsAIAssistantEnabled` keeps this in sync via `setAIBackendUrl`
|
|
* whenever the config response changes; consumers (the axios instance and the
|
|
* SSE fetch path) read it lazily so they always see the current value.
|
|
*/
|
|
let aiBackendUrl: string | null = null;
|
|
|
|
export function setAIBackendUrl(url: string | null): void {
|
|
if (aiBackendUrl === url) {
|
|
return;
|
|
}
|
|
aiBackendUrl = url;
|
|
AIAssistantInstance.defaults.baseURL = url ? `${url}${AI_API_PATH}` : '';
|
|
}
|
|
|
|
/**
|
|
* Full base URL for the AI Assistant API (host + path). Throws when the
|
|
* config hasn't yet provided a URL — should never happen in practice
|
|
* because `useIsAIAssistantEnabled` gates every consumer surface.
|
|
*/
|
|
export function getAIBaseUrl(): string {
|
|
if (!aiBackendUrl) {
|
|
throw new Error('AI assistant URL is not configured.');
|
|
}
|
|
return `${aiBackendUrl}${AI_API_PATH}`;
|
|
}
|
|
|
|
/**
|
|
* Dedicated axios instance for the AI Assistant.
|
|
*
|
|
* Mirrors the request/response interceptor stack of the main SigNoz axios
|
|
* instance — most importantly `interceptorRejected`, which transparently
|
|
* rotates the access token via `/sessions/rotate` on a 401 and replays the
|
|
* original request. That's why we don't need any AI-specific 401 handling
|
|
* for REST calls: this instance inherits the same flow as the rest of the
|
|
* app for free.
|
|
*
|
|
* Only the SSE stream (`streamEvents`) still needs raw fetch since axios
|
|
* doesn't expose `ReadableStream` — that path keeps its own auth wrapper.
|
|
*/
|
|
export const AIAssistantInstance = axios.create({});
|
|
|
|
AIAssistantInstance.interceptors.request.use(interceptorsRequestResponse);
|
|
AIAssistantInstance.interceptors.request.use(interceptorsRequestBasePath);
|
|
AIAssistantInstance.interceptors.request.use(interceptorsRequestSigNozUrl);
|
|
AIAssistantInstance.interceptors.response.use(
|
|
interceptorsResponse,
|
|
interceptorRejected,
|
|
);
|