4c642a0bb8
Added: - An "Ask AI" command to the command menu. - A simple GraphQL resolver that converts the user's question into a relevant SQL query using an LLM, runs the query, and returns the result. <img width="428" alt="Screenshot 2024-06-09 at 20 53 09" src="https://github.com/twentyhq/twenty/assets/171685816/57127f37-d4a6-498d-b253-733ffa0d209f"> No security concerns have been addressed, this is only a proof-of-concept and not intended to be enabled in production. All changes are behind a feature flag called `IS_ASK_AI_ENABLED`. --------- Co-authored-by: Félix Malfait <felix.malfait@gmail.com>
27 lines
789 B
TypeScript
27 lines
789 B
TypeScript
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
import CallbackHandler from 'langfuse-langchain';
|
|
|
|
import { LLMTracingDriver } from 'src/engine/integrations/llm-tracing/drivers/interfaces/llm-tracing-driver.interface';
|
|
|
|
export interface LangfuseDriverOptions {
|
|
secretKey: string;
|
|
publicKey: string;
|
|
}
|
|
|
|
export class LangfuseDriver implements LLMTracingDriver {
|
|
private options: LangfuseDriverOptions;
|
|
|
|
constructor(options: LangfuseDriverOptions) {
|
|
this.options = options;
|
|
}
|
|
|
|
getCallbackHandler(metadata: Record<string, unknown>): BaseCallbackHandler {
|
|
return new CallbackHandler({
|
|
secretKey: this.options.secretKey,
|
|
publicKey: this.options.publicKey,
|
|
baseUrl: 'https://cloud.langfuse.com',
|
|
metadata: metadata,
|
|
});
|
|
}
|
|
}
|