@tambo-ai/react 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/__tests__/use-suggestions.test.d.ts +1 -0
- package/dist/hooks/__tests__/use-suggestions.test.d.ts.map +1 -0
- package/dist/hooks/react-query-hooks.d.ts +1 -0
- package/dist/hooks/react-query-hooks.d.ts.map +1 -0
- package/dist/hooks/use-component-state.d.ts +1 -0
- package/dist/hooks/use-component-state.d.ts.map +1 -0
- package/dist/hooks/use-current-message.d.ts +1 -0
- package/dist/hooks/use-current-message.d.ts.map +1 -0
- package/dist/hooks/use-suggestions.d.ts +1 -0
- package/dist/hooks/use-suggestions.d.ts.map +1 -0
- package/dist/hooks/use-suggestions.js +2 -2
- package/dist/hooks/use-suggestions.js.map +1 -1
- package/dist/hooks/use-tambo-threads.d.ts +1 -0
- package/dist/hooks/use-tambo-threads.d.ts.map +1 -0
- package/dist/hooks/use-thread-input.d.ts +3 -0
- package/dist/hooks/use-thread-input.d.ts.map +1 -0
- package/dist/hooks/use-thread-input.js +2 -1
- package/dist/hooks/use-thread-input.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/model/component-metadata.d.ts +1 -0
- package/dist/model/component-metadata.d.ts.map +1 -0
- package/dist/model/generate-component-response.d.ts +1 -0
- package/dist/model/generate-component-response.d.ts.map +1 -0
- package/dist/model/tambo-thread.d.ts +1 -0
- package/dist/model/tambo-thread.d.ts.map +1 -0
- package/dist/model/thread-input-error.d.ts +1 -0
- package/dist/model/thread-input-error.d.ts.map +1 -0
- package/dist/model/validate-input.d.ts +1 -0
- package/dist/model/validate-input.d.ts.map +1 -0
- package/dist/providers/index.d.ts +2 -1
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/providers/tambo-client-provider.d.ts +3 -1
- package/dist/providers/tambo-client-provider.d.ts.map +1 -0
- package/dist/providers/tambo-client-provider.js +9 -2
- package/dist/providers/tambo-client-provider.js.map +1 -1
- package/dist/providers/tambo-component-provider.d.ts +1 -7
- package/dist/providers/tambo-component-provider.d.ts.map +1 -0
- package/dist/providers/tambo-component-provider.js +1 -66
- package/dist/providers/tambo-component-provider.js.map +1 -1
- package/dist/providers/tambo-provider.d.ts +1 -0
- package/dist/providers/tambo-provider.d.ts.map +1 -0
- package/dist/providers/tambo-registry-provider.d.ts +1 -0
- package/dist/providers/tambo-registry-provider.d.ts.map +1 -0
- package/dist/providers/tambo-thread-provider.d.ts +4 -0
- package/dist/providers/tambo-thread-provider.d.ts.map +1 -0
- package/dist/providers/tambo-thread-provider.js +42 -30
- package/dist/providers/tambo-thread-provider.js.map +1 -1
- package/dist/util/generate-component.d.ts +3 -3
- package/dist/util/generate-component.d.ts.map +1 -0
- package/dist/util/generate-component.js +0 -174
- package/dist/util/generate-component.js.map +1 -1
- package/dist/util/messages.d.ts +1 -0
- package/dist/util/messages.d.ts.map +1 -0
- package/dist/util/query-utils.d.ts +1 -0
- package/dist/util/query-utils.d.ts.map +1 -0
- package/dist/util/registry.d.ts +1 -0
- package/dist/util/registry.d.ts.map +1 -0
- package/dist/util/tool-caller.d.ts +1 -0
- package/dist/util/tool-caller.d.ts.map +1 -0
- package/dist/util/tool-caller.js +1 -1
- package/dist/util/tool-caller.js.map +1 -1
- package/esm/hooks/__tests__/use-suggestions.test.d.ts +1 -0
- package/esm/hooks/__tests__/use-suggestions.test.d.ts.map +1 -0
- package/esm/hooks/react-query-hooks.d.ts +1 -0
- package/esm/hooks/react-query-hooks.d.ts.map +1 -0
- package/esm/hooks/use-component-state.d.ts +1 -0
- package/esm/hooks/use-component-state.d.ts.map +1 -0
- package/esm/hooks/use-current-message.d.ts +1 -0
- package/esm/hooks/use-current-message.d.ts.map +1 -0
- package/esm/hooks/use-suggestions.d.ts +1 -0
- package/esm/hooks/use-suggestions.d.ts.map +1 -0
- package/esm/hooks/use-suggestions.js +2 -2
- package/esm/hooks/use-suggestions.js.map +1 -1
- package/esm/hooks/use-tambo-threads.d.ts +1 -0
- package/esm/hooks/use-tambo-threads.d.ts.map +1 -0
- package/esm/hooks/use-thread-input.d.ts +3 -0
- package/esm/hooks/use-thread-input.d.ts.map +1 -0
- package/esm/hooks/use-thread-input.js +2 -1
- package/esm/hooks/use-thread-input.js.map +1 -1
- package/esm/index.d.ts +4 -3
- package/esm/index.d.ts.map +1 -0
- package/esm/index.js.map +1 -1
- package/esm/model/component-metadata.d.ts +1 -0
- package/esm/model/component-metadata.d.ts.map +1 -0
- package/esm/model/generate-component-response.d.ts +1 -0
- package/esm/model/generate-component-response.d.ts.map +1 -0
- package/esm/model/tambo-thread.d.ts +1 -0
- package/esm/model/tambo-thread.d.ts.map +1 -0
- package/esm/model/thread-input-error.d.ts +1 -0
- package/esm/model/thread-input-error.d.ts.map +1 -0
- package/esm/model/validate-input.d.ts +1 -0
- package/esm/model/validate-input.d.ts.map +1 -0
- package/esm/providers/index.d.ts +2 -1
- package/esm/providers/index.d.ts.map +1 -0
- package/esm/providers/index.js.map +1 -1
- package/esm/providers/tambo-client-provider.d.ts +3 -1
- package/esm/providers/tambo-client-provider.d.ts.map +1 -0
- package/esm/providers/tambo-client-provider.js +9 -2
- package/esm/providers/tambo-client-provider.js.map +1 -1
- package/esm/providers/tambo-component-provider.d.ts +1 -7
- package/esm/providers/tambo-component-provider.d.ts.map +1 -0
- package/esm/providers/tambo-component-provider.js +2 -67
- package/esm/providers/tambo-component-provider.js.map +1 -1
- package/esm/providers/tambo-provider.d.ts +1 -0
- package/esm/providers/tambo-provider.d.ts.map +1 -0
- package/esm/providers/tambo-registry-provider.d.ts +1 -0
- package/esm/providers/tambo-registry-provider.d.ts.map +1 -0
- package/esm/providers/tambo-thread-provider.d.ts +4 -0
- package/esm/providers/tambo-thread-provider.d.ts.map +1 -0
- package/esm/providers/tambo-thread-provider.js +43 -31
- package/esm/providers/tambo-thread-provider.js.map +1 -1
- package/esm/util/generate-component.d.ts +3 -3
- package/esm/util/generate-component.d.ts.map +1 -0
- package/esm/util/generate-component.js +1 -174
- package/esm/util/generate-component.js.map +1 -1
- package/esm/util/messages.d.ts +1 -0
- package/esm/util/messages.d.ts.map +1 -0
- package/esm/util/query-utils.d.ts +1 -0
- package/esm/util/query-utils.d.ts.map +1 -0
- package/esm/util/registry.d.ts +1 -0
- package/esm/util/registry.d.ts.map +1 -0
- package/esm/util/tool-caller.d.ts +1 -0
- package/esm/util/tool-caller.d.ts.map +1 -0
- package/esm/util/tool-caller.js +1 -1
- package/esm/util/tool-caller.js.map +1 -1
- package/package.json +8 -6
- package/dist/hooks/use-query-client.d.ts +0 -0
- package/dist/hooks/use-query-client.js +0 -2
- package/dist/hooks/use-query-client.js.map +0 -1
- package/dist/setupTests.d.ts +0 -1
- package/dist/setupTests.js +0 -20
- package/dist/setupTests.js.map +0 -1
- package/esm/hooks/use-query-client.d.ts +0 -0
- package/esm/hooks/use-query-client.js +0 -2
- package/esm/hooks/use-query-client.js.map +0 -1
- package/esm/setupTests.d.ts +0 -1
- package/esm/setupTests.js +0 -18
- package/esm/setupTests.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-suggestions.test.d.ts","sourceRoot":"","sources":["../../../src/hooks/__tests__/use-suggestions.test.tsx"],"names":[],"mappings":""}
|
|
@@ -19,3 +19,4 @@ export type UseTamboMutationResult<TData = unknown, TError = Error, TVariables =
|
|
|
19
19
|
* Hook for creating a mutation with the tambo query client.
|
|
20
20
|
*/
|
|
21
21
|
export declare function useTamboMutationResult<TData = unknown, TError = Error, TVariables = void, TContext = unknown>(options: UseMutationOptions<TData, TError, TVariables, TContext>): UseMutationResult<TData, TError, TVariables, TContext>;
|
|
22
|
+
//# sourceMappingURL=react-query-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-query-hooks.d.ts","sourceRoot":"","sources":["../../src/hooks/react-query-hooks.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAER,kBAAkB,EAElB,eAAe,EACf,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAG/B;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,KAAK,EACd,KAAK,GAAG,YAAY,EACpB,SAAS,SAAS,QAAQ,GAAG,QAAQ,EACrC,OAAO,EAAE,eAAe,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,iEAGjE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,KAAK,EACd,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,OAAO,EAClB,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,0DAGjE;AAED;;GAEG;AACH,MAAM,MAAM,sBAAsB,CAChC,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,KAAK,EACd,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,OAAO,IAChB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;AAE3D;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,KAAK,EACd,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,OAAO,EAClB,OAAO,EAAE,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,CAAC,0DAEjE"}
|
|
@@ -6,3 +6,4 @@ type StateUpdateResult<T> = [currentState: T, setState: (newState: T) => void];
|
|
|
6
6
|
export declare function useTamboComponentState<S = undefined>(keyName: string): StateUpdateResult<S | undefined>;
|
|
7
7
|
export declare function useTamboComponentState<S>(keyName: string, initialValue?: S): StateUpdateResult<S>;
|
|
8
8
|
export {};
|
|
9
|
+
//# sourceMappingURL=use-component-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-component-state.d.ts","sourceRoot":"","sources":["../../src/hooks/use-component-state.tsx"],"names":[],"mappings":"AAOA,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,IAAI,CAAC,CAAC;AAE/E;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,SAAS,EAClD,OAAO,EAAE,MAAM,GACd,iBAAiB,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AACpC,wBAAgB,sBAAsB,CAAC,CAAC,EACtC,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,CAAC,GACf,iBAAiB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -16,3 +16,4 @@ export declare const useTamboMessageContext: () => {
|
|
|
16
16
|
/** Hook used inside a component wrapped with ComponentMessageProvider, to get
|
|
17
17
|
* the current message */
|
|
18
18
|
export declare const useTamboCurrentMessage: () => import("..").TamboThreadMessage | undefined;
|
|
19
|
+
//# sourceMappingURL=use-current-message.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-current-message.d.ts","sourceRoot":"","sources":["../../src/hooks/use-current-message.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAQ5E,sFAAsF;AACtF,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CACzC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAO3D,CAAC;AAEF;sCACsC;AACtC,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,qBAOlB;AACD;gCACgC;AAEhC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AAsB,CAAC,GAAG,EAAE,KAAK,CAAC,GACjE,iCAAiC,CAAC;AAEpC;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,yBAAyB,CAkI3B"}
|
|
@@ -42,7 +42,7 @@ function useTamboSuggestions(options = {}) {
|
|
|
42
42
|
}
|
|
43
43
|
// Get registered components from the registry
|
|
44
44
|
const components = (0, registry_1.getAvailableComponents)(componentList, toolRegistry, componentToolAssociations);
|
|
45
|
-
return tamboClient.beta.threads.suggestions.generate(thread.id, latestMessageId, {
|
|
45
|
+
return await tamboClient.beta.threads.suggestions.generate(thread.id, latestMessageId, {
|
|
46
46
|
maxSuggestions,
|
|
47
47
|
// The API expects an array of arrays for availableComponents
|
|
48
48
|
availableComponents: [components],
|
|
@@ -85,7 +85,7 @@ function useTamboSuggestions(options = {}) {
|
|
|
85
85
|
}
|
|
86
86
|
// Get registered components from the registry
|
|
87
87
|
const components = (0, registry_1.getAvailableComponents)(componentList, toolRegistry, componentToolAssociations);
|
|
88
|
-
return tamboClient.beta.threads.suggestions.generate(thread.id, latestMessageId, {
|
|
88
|
+
return await tamboClient.beta.threads.suggestions.generate(thread.id, latestMessageId, {
|
|
89
89
|
maxSuggestions,
|
|
90
90
|
// The API expects an array of arrays for availableComponents
|
|
91
91
|
availableComponents: [components],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-suggestions.js","sourceRoot":"","sources":["../../src/hooks/use-suggestions.ts"],"names":[],"mappings":";;AAqEA,kDAoIC;AAxMD,iCAA4C;AAC5C,4DAAwD;AACxD,8EAAoE;AACpE,gEAAuD;AACvD,kFAAwE;AACxE,8EAAoE;AACpE,qDAG6B;AAC7B,+CAA0D;AAC1D,2DAI6B;AAC7B,yDAA+E;AA8C/E;;;;;GAKG;AACH,SAAgB,mBAAmB,CACjC,UAAsC,EAAE;IAExC,MAAM,EAAE,cAAc,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC;IACvC,MA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IAAI,CAAC,eAAe,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC3C,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,8CAA8C;YAC9C,MAAM,UAAU,GAAG,IAAA,iCAAsB,EACvC,aAAa,EACb,YAAY,EACZ,yBAAyB,CAC1B,CAAC;YAEF,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAClD,MAAM,CAAC,EAAE,EACT,eAAe,EACf;gBACE,cAAc;gBACd,6DAA6D;gBAC7D,mBAAmB,EAAE,CAAC,UAAU,CAAC;aAClC,EACD,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAE,CACnC,CAAC;QACJ,CAAC;QACD,yBAAyB;QACzB,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,mEAAmE;IACnE,8DAA8D;IAC9D,MAAM,WAAW,GAAG,iBAAiB;QACnC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,IAAI,qBAAqB,CAAC,IAAI,IAAI,EAAE,CAAC;QAC7D,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,WAAW;QACX,MAAM,EAAE,mBAAmB,CAAC,WAAW;QACvC,oBAAoB;QACpB,YAAY,EAAE,mBAAmB;QACjC,cAAc,EAAE,qBAAqB;QACrC,GAAG,IAAA,oCAAsB,EAAC,mBAAmB,EAAE,qBAAqB,CAAC;KACtE,CAAC;AACJ,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { useEffect, useState } from \"react\";\nimport { validateInput } from \"../model/validate-input\";\nimport { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTambo } from \"../providers/tambo-provider\";\nimport { useTamboRegistry } from \"../providers/tambo-registry-provider\";\nimport { useTamboThread } from \"../providers/tambo-thread-provider\";\nimport {\n CombinedMutationResult,\n combineMutationResults,\n} from \"../util/query-utils\";\nimport { getAvailableComponents } from \"../util/registry\";\nimport {\n UseTamboMutationResult,\n useTamboMutationResult,\n useTamboQuery,\n} from \"./react-query-hooks\";\nimport { INPUT_ERROR_MESSAGES, useTamboThreadInput } from \"./use-thread-input\";\n\n/**\n * Configuration options for the useTamboSuggestions hook\n */\nexport interface useTamboSuggestionsOptions {\n /** Maximum number of suggestions to generate (1-10, default 3) */\n maxSuggestions?: number;\n}\n\n/**\n * Return value interface for useTamboSuggestions hook\n */\nexport interface useTamboSuggestionsResultInternal {\n /** List of available suggestions (also available in generateResult.data) */\n suggestions: TamboAI.Beta.Threads.Suggestion[];\n /** ID of the currently selected suggestion */\n selectedSuggestionId: string | null;\n /**\n * Accept and apply a suggestion (also available in acceptResult.mutateAsync)\n * @param suggestion - The suggestion to accept\n * @param shouldSubmit - Whether to automatically submit after accepting (default: false)\n */\n accept: (acceptOptions: {\n suggestion: TamboAI.Beta.Threads.Suggestion;\n shouldSubmit?: boolean;\n }) => Promise<void>;\n\n /** Result and network state for accepting a suggestion */\n acceptResult: UseTamboMutationResult<\n void,\n Error,\n { suggestion: TamboAI.Beta.Threads.Suggestion; shouldSubmit?: boolean }\n >;\n\n /** Result and network state for generating suggestions */\n generateResult: UseTamboMutationResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error,\n AbortController\n >;\n}\n\ntype useTamboSuggestionsResult = CombinedMutationResult<any, Error> &\n useTamboSuggestionsResultInternal;\n\n/**\n * Hook for managing Tambo AI suggestions in a thread\n *\n * @param options - Configuration options for suggestion generation\n * @returns Object containing suggestions state and control functions\n */\nexport function useTamboSuggestions(\n options: useTamboSuggestionsOptions = {},\n): useTamboSuggestionsResult {\n const { maxSuggestions = 3 } = options;\n const { thread } = useTamboThread();\n const { sendThreadMessage } = useTambo();\n const tamboClient = useTamboClient();\n const { componentList, toolRegistry, componentToolAssociations } =\n useTamboRegistry();\n\n const [selectedSuggestionId, setSelectedSuggestionId] = useState<\n string | null\n >(null);\n const { setValue: setInputValue } = useTamboThreadInput();\n\n const latestMessage = thread.messages[thread.messages.length - 1];\n const isLatestFromTambo = latestMessage?.role === \"hydra\"; // TODO: change to tambo\n const latestMessageId = latestMessage?.id;\n\n // Reset selected suggestion when the message changes\n useEffect(() => {\n setSelectedSuggestionId(null);\n }, [latestMessageId]);\n\n // Use React Query to fetch suggestions when a new hydra message is received\n const suggestionsQuery = useTamboQuery({\n // Only include latestMessageId in the queryKey if the message is from hydra\n queryKey: [\"suggestions\", isLatestFromTambo ? latestMessageId : null],\n queryFn: async () => {\n if (!latestMessageId || !isLatestFromTambo) {\n return [];\n }\n\n // Get registered components from the registry\n const components = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n\n return tamboClient.beta.threads.suggestions.generate(\n thread.id,\n latestMessageId,\n {\n maxSuggestions,\n // The API expects an array of arrays for availableComponents\n availableComponents: [components],\n },\n );\n },\n // Only run the query if we have a valid message from hydra\n enabled: Boolean(latestMessageId && isLatestFromTambo),\n // Don't refetch on window focus or reconnect\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n // Don't retry on failure\n retry: false,\n });\n\n // Accept suggestion mutation\n const acceptMutationState = useTamboMutationResult<\n void,\n Error,\n { suggestion: TamboAI.Beta.Threads.Suggestion; shouldSubmit?: boolean }\n >({\n mutationFn: async ({ suggestion, shouldSubmit = false }) => {\n const validation = validateInput(suggestion.detailedSuggestion);\n if (!validation.isValid) {\n if (validation.error) {\n throw validation.error;\n }\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n if (shouldSubmit) {\n await sendThreadMessage(validation.sanitizedInput, {\n threadId: thread.id,\n });\n } else {\n setInputValue(validation.sanitizedInput);\n }\n setSelectedSuggestionId(suggestion.id);\n },\n });\n\n // Generate suggestions mutation\n const generateMutationState = useTamboMutationResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error,\n AbortController\n >({\n mutationFn: async (abortController: AbortController) => {\n if (!latestMessageId || !isLatestFromTambo) {\n return undefined;\n }\n\n // Get registered components from the registry\n const components = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n\n return tamboClient.beta.threads.suggestions.generate(\n thread.id,\n latestMessageId,\n {\n maxSuggestions,\n // The API expects an array of arrays for availableComponents\n availableComponents: [components],\n },\n { signal: abortController.signal },\n );\n },\n // Don't retry on failure\n retry: false,\n });\n\n // Use the query data if available, otherwise use the mutation data\n // Only return suggestions if the latest message is from hydra\n const suggestions = isLatestFromTambo\n ? (suggestionsQuery.data ?? generateMutationState.data ?? [])\n : [];\n\n return {\n suggestions,\n accept: acceptMutationState.mutateAsync,\n selectedSuggestionId,\n acceptResult: acceptMutationState,\n generateResult: generateMutationState,\n ...combineMutationResults(acceptMutationState, generateMutationState),\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-suggestions.js","sourceRoot":"","sources":["../../src/hooks/use-suggestions.ts"],"names":[],"mappings":";;AAqEA,kDAoIC;AAxMD,iCAA4C;AAC5C,4DAAwD;AACxD,8EAAoE;AACpE,gEAAuD;AACvD,kFAAwE;AACxE,8EAAoE;AACpE,qDAG6B;AAC7B,+CAA0D;AAC1D,2DAI6B;AAC7B,yDAA+E;AA8C/E;;;;;GAKG;AACH,SAAgB,mBAAmB,CACjC,UAAsC,EAAE;IAExC,MAAM,EAAE,cAAc,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAA,sCAAc,GAAE,CAAC;IACpC,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAA,yBAAQ,GAAE,CAAC;IACzC,MAAM,WAAW,GAAG,IAAA,sCAAc,GAAE,CAAC;IACrC,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,yBAAyB,EAAE,GAC9D,IAAA,0CAAgB,GAAE,CAAC;IAErB,MAAM,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,GAAG,IAAA,gBAAQ,EAE9D,IAAI,CAAC,CAAC;IACR,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAA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AAE,eAAe,CAAC,MAAM,EAAE,CACnC,CAAC;QACJ,CAAC;QACD,yBAAyB;QACzB,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,mEAAmE;IACnE,8DAA8D;IAC9D,MAAM,WAAW,GAAG,iBAAiB;QACnC,CAAC,CAAC,CAAC,gBAAgB,CAAC,IAAI,IAAI,qBAAqB,CAAC,IAAI,IAAI,EAAE,CAAC;QAC7D,CAAC,CAAC,EAAE,CAAC;IAEP,OAAO;QACL,WAAW;QACX,MAAM,EAAE,mBAAmB,CAAC,WAAW;QACvC,oBAAoB;QACpB,YAAY,EAAE,mBAAmB;QACjC,cAAc,EAAE,qBAAqB;QACrC,GAAG,IAAA,oCAAsB,EAAC,mBAAmB,EAAE,qBAAqB,CAAC;KACtE,CAAC;AACJ,CAAC","sourcesContent":["import TamboAI from \"@tambo-ai/typescript-sdk\";\nimport { useEffect, useState } from \"react\";\nimport { validateInput } from \"../model/validate-input\";\nimport { useTamboClient } from \"../providers/tambo-client-provider\";\nimport { useTambo } from \"../providers/tambo-provider\";\nimport { useTamboRegistry } from \"../providers/tambo-registry-provider\";\nimport { useTamboThread } from \"../providers/tambo-thread-provider\";\nimport {\n CombinedMutationResult,\n combineMutationResults,\n} from \"../util/query-utils\";\nimport { getAvailableComponents } from \"../util/registry\";\nimport {\n UseTamboMutationResult,\n useTamboMutationResult,\n useTamboQuery,\n} from \"./react-query-hooks\";\nimport { INPUT_ERROR_MESSAGES, useTamboThreadInput } from \"./use-thread-input\";\n\n/**\n * Configuration options for the useTamboSuggestions hook\n */\nexport interface useTamboSuggestionsOptions {\n /** Maximum number of suggestions to generate (1-10, default 3) */\n maxSuggestions?: number;\n}\n\n/**\n * Return value interface for useTamboSuggestions hook\n */\nexport interface useTamboSuggestionsResultInternal {\n /** List of available suggestions (also available in generateResult.data) */\n suggestions: TamboAI.Beta.Threads.Suggestion[];\n /** ID of the currently selected suggestion */\n selectedSuggestionId: string | null;\n /**\n * Accept and apply a suggestion (also available in acceptResult.mutateAsync)\n * @param suggestion - The suggestion to accept\n * @param shouldSubmit - Whether to automatically submit after accepting (default: false)\n */\n accept: (acceptOptions: {\n suggestion: TamboAI.Beta.Threads.Suggestion;\n shouldSubmit?: boolean;\n }) => Promise<void>;\n\n /** Result and network state for accepting a suggestion */\n acceptResult: UseTamboMutationResult<\n void,\n Error,\n { suggestion: TamboAI.Beta.Threads.Suggestion; shouldSubmit?: boolean }\n >;\n\n /** Result and network state for generating suggestions */\n generateResult: UseTamboMutationResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error,\n AbortController\n >;\n}\n\ntype useTamboSuggestionsResult = CombinedMutationResult<any, Error> &\n useTamboSuggestionsResultInternal;\n\n/**\n * Hook for managing Tambo AI suggestions in a thread\n *\n * @param options - Configuration options for suggestion generation\n * @returns Object containing suggestions state and control functions\n */\nexport function useTamboSuggestions(\n options: useTamboSuggestionsOptions = {},\n): useTamboSuggestionsResult {\n const { maxSuggestions = 3 } = options;\n const { thread } = useTamboThread();\n const { sendThreadMessage } = useTambo();\n const tamboClient = useTamboClient();\n const { componentList, toolRegistry, componentToolAssociations } =\n useTamboRegistry();\n\n const [selectedSuggestionId, setSelectedSuggestionId] = useState<\n string | null\n >(null);\n const { setValue: setInputValue } = useTamboThreadInput();\n\n const latestMessage = thread.messages[thread.messages.length - 1];\n const isLatestFromTambo = latestMessage?.role === \"hydra\"; // TODO: change to tambo\n const latestMessageId = latestMessage?.id;\n\n // Reset selected suggestion when the message changes\n useEffect(() => {\n setSelectedSuggestionId(null);\n }, [latestMessageId]);\n\n // Use React Query to fetch suggestions when a new hydra message is received\n const suggestionsQuery = useTamboQuery({\n // Only include latestMessageId in the queryKey if the message is from hydra\n queryKey: [\"suggestions\", isLatestFromTambo ? latestMessageId : null],\n queryFn: async () => {\n if (!latestMessageId || !isLatestFromTambo) {\n return [];\n }\n\n // Get registered components from the registry\n const components = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n\n return await tamboClient.beta.threads.suggestions.generate(\n thread.id,\n latestMessageId,\n {\n maxSuggestions,\n // The API expects an array of arrays for availableComponents\n availableComponents: [components],\n },\n );\n },\n // Only run the query if we have a valid message from hydra\n enabled: Boolean(latestMessageId && isLatestFromTambo),\n // Don't refetch on window focus or reconnect\n refetchOnWindowFocus: false,\n refetchOnReconnect: false,\n // Don't retry on failure\n retry: false,\n });\n\n // Accept suggestion mutation\n const acceptMutationState = useTamboMutationResult<\n void,\n Error,\n { suggestion: TamboAI.Beta.Threads.Suggestion; shouldSubmit?: boolean }\n >({\n mutationFn: async ({ suggestion, shouldSubmit = false }) => {\n const validation = validateInput(suggestion.detailedSuggestion);\n if (!validation.isValid) {\n if (validation.error) {\n throw validation.error;\n }\n throw new Error(INPUT_ERROR_MESSAGES.VALIDATION);\n }\n\n if (shouldSubmit) {\n await sendThreadMessage(validation.sanitizedInput, {\n threadId: thread.id,\n });\n } else {\n setInputValue(validation.sanitizedInput);\n }\n setSelectedSuggestionId(suggestion.id);\n },\n });\n\n // Generate suggestions mutation\n const generateMutationState = useTamboMutationResult<\n TamboAI.Beta.Threads.Suggestions.SuggestionGenerateResponse | undefined,\n Error,\n AbortController\n >({\n mutationFn: async (abortController: AbortController) => {\n if (!latestMessageId || !isLatestFromTambo) {\n return undefined;\n }\n\n // Get registered components from the registry\n const components = getAvailableComponents(\n componentList,\n toolRegistry,\n componentToolAssociations,\n );\n\n return await tamboClient.beta.threads.suggestions.generate(\n thread.id,\n latestMessageId,\n {\n maxSuggestions,\n // The API expects an array of arrays for availableComponents\n availableComponents: [components],\n },\n { signal: abortController.signal },\n );\n },\n // Don't retry on failure\n retry: false,\n });\n\n // Use the query data if available, otherwise use the mutation data\n // Only return suggestions if the latest message is from hydra\n const suggestions = isLatestFromTambo\n ? (suggestionsQuery.data ?? generateMutationState.data ?? [])\n : [];\n\n return {\n suggestions,\n accept: acceptMutationState.mutateAsync,\n selectedSuggestionId,\n acceptResult: acceptMutationState,\n generateResult: generateMutationState,\n ...combineMutationResults(acceptMutationState, generateMutationState),\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-tambo-threads.d.ts","sourceRoot":"","sources":["../../src/hooks/use-tambo-threads.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,UAAU,GACX,GAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBL"}
|
|
@@ -34,10 +34,12 @@ interface UseThreadInputInternal {
|
|
|
34
34
|
*/
|
|
35
35
|
submit: (options?: {
|
|
36
36
|
contextKey?: string;
|
|
37
|
+
streamResponse?: boolean;
|
|
37
38
|
}) => Promise<void>;
|
|
38
39
|
}
|
|
39
40
|
export type UseThreadInput = UseThreadInputInternal & UseMutationResult<void, Error, {
|
|
40
41
|
contextKey?: string;
|
|
42
|
+
streamResponse?: boolean;
|
|
41
43
|
}>;
|
|
42
44
|
/**
|
|
43
45
|
* Hook for managing thread message input state and submission
|
|
@@ -46,3 +48,4 @@ export type UseThreadInput = UseThreadInputInternal & UseMutationResult<void, Er
|
|
|
46
48
|
*/
|
|
47
49
|
export declare function useTamboThreadInput(contextKey?: string): UseThreadInput;
|
|
48
50
|
export {};
|
|
51
|
+
//# sourceMappingURL=use-thread-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-thread-input.d.ts","sourceRoot":"","sources":["../../src/hooks/use-thread-input.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO1D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;IAC/B,kDAAkD;;IAElD,0CAA0C;;IAE1C,qDAAqD;;IAErD,yCAAyC;;CAEjC,CAAC;AAEX;;;GAGG;AACH,UAAU,sBAAsB;IAC9B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;;;OAKG;IACH,MAAM,EAAE,CAAC,OAAO,CAAC,EAAE;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrB;AACD,MAAM,MAAM,cAAc,GAAG,sBAAsB,GACjD,iBAAiB,CACf,IAAI,EACJ,KAAK,EACL;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAClD,CAAC;AAEJ;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,cAAc,CAwCvE"}
|
|
@@ -29,7 +29,7 @@ exports.INPUT_ERROR_MESSAGES = {
|
|
|
29
29
|
*/
|
|
30
30
|
function useTamboThreadInput(contextKey) {
|
|
31
31
|
const { thread, inputValue, setInputValue, sendThreadMessage } = (0, tambo_thread_provider_1.useTamboThread)();
|
|
32
|
-
const submit = (0, react_1.useCallback)(async ({ contextKey: submitContextKey } = {}) => {
|
|
32
|
+
const submit = (0, react_1.useCallback)(async ({ contextKey: submitContextKey, streamResponse, } = {}) => {
|
|
33
33
|
const validation = (0, validate_input_1.validateInput)(inputValue);
|
|
34
34
|
if (!validation.isValid) {
|
|
35
35
|
throw new thread_input_error_1.ThreadInputError(`Cannot submit message: ${validation.error ?? exports.INPUT_ERROR_MESSAGES.VALIDATION}`, { cause: validation.error });
|
|
@@ -37,6 +37,7 @@ function useTamboThreadInput(contextKey) {
|
|
|
37
37
|
await sendThreadMessage(validation.sanitizedInput, {
|
|
38
38
|
threadId: thread.id,
|
|
39
39
|
contextKey: submitContextKey ?? contextKey ?? undefined,
|
|
40
|
+
streamResponse: streamResponse,
|
|
40
41
|
});
|
|
41
42
|
setInputValue("");
|
|
42
43
|
}, [inputValue, sendThreadMessage, thread.id, contextKey, setInputValue]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-thread-input.js","sourceRoot":"","sources":["../../src/hooks/use-thread-input.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"use-thread-input.js","sourceRoot":"","sources":["../../src/hooks/use-thread-input.ts"],"names":[],"mappings":";;;AA0DA,kDAwCC;AAjGD,iCAAoC;AACpC,oEAA+D;AAC/D,4DAAwD;AACxD,8EAAoE;AACpE,2DAAuD;AAEvD;;;;GAIG;AACU,QAAA,oBAAoB,GAAG;IAClC,kDAAkD;IAClD,KAAK,EAAE,yBAAyB;IAChC,0CAA0C;IAC1C,OAAO,EAAE,6CAA6C;IACtD,qDAAqD;IACrD,MAAM,EAAE,gCAAgC;IACxC,yCAAyC;IACzC,UAAU,EAAE,wBAAwB;CAC5B,CAAC;AAgCX;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,UAAmB;IACrD,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAC5D,IAAA,sCAAc,GAAE,CAAC;IAEnB,MAAM,MAAM,GAAG,IAAA,mBAAW,EACxB,KAAK,EAAE,EACL,UAAU,EAAE,gBAAgB,EAC5B,cAAc,MACuC,EAAE,EAAE,EAAE;QAC3D,MAAM,UAAU,GAAG,IAAA,8BAAa,EAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,IAAI,qCAAgB,CACxB,0BAA0B,UAAU,CAAC,KAAK,IAAI,4BAAoB,CAAC,UAAU,EAAE,EAC/E,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAC5B,CAAC;QACJ,CAAC;QAED,MAAM,iBAAiB,CAAC,UAAU,CAAC,cAAc,EAAE;YACjD,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,UAAU,EAAE,gBAAgB,IAAI,UAAU,IAAI,SAAS;YACvD,cAAc,EAAE,cAAc;SAC/B,CAAC,CAAC;QACH,aAAa,CAAC,EAAE,CAAC,CAAC;IACpB,CAAC,EACD,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,aAAa,CAAC,CACtE,CAAC;IACF,MAAM,EACJ,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,aAAa,EACrB,GAAG,aAAa,EACjB,GAAG,IAAA,oCAAgB,EAAC;QACnB,UAAU,EAAE,MAAM;KACnB,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,aAAa;QAChB,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,aAAa;QACvB,MAAM,EAAE,WAAW;KACF,CAAC;AACtB,CAAC","sourcesContent":["import { UseMutationResult } from \"@tanstack/react-query\";\nimport { useCallback } from \"react\";\nimport { ThreadInputError } from \"../model/thread-input-error\";\nimport { validateInput } from \"../model/validate-input\";\nimport { useTamboThread } from \"../providers/tambo-thread-provider\";\nimport { useTamboMutation } from \"./react-query-hooks\";\n\n/**\n * Error messages for various input-related error scenarios\n * These messages are used to provide user-friendly error feedback\n * @readonly\n */\nexport const INPUT_ERROR_MESSAGES = {\n /** Error when attempting to submit empty input */\n EMPTY: \"Message cannot be empty\",\n /** Error when network connection fails */\n NETWORK: \"Network error. Please check your connection\",\n /** Error when server fails to process the request */\n SERVER: \"Server error. Please try again\",\n /** Error when input format is invalid */\n VALIDATION: \"Invalid message format\",\n} as const;\n\n/**\n * Interface for the thread input hook return value\n * Provides all necessary functions and state for managing thread input\n */\ninterface UseThreadInputInternal {\n /** Current value of the input field */\n value: string;\n /**\n * Function to update the input value\n * @param value - New value for the input field\n */\n setValue: (value: string) => void;\n /**\n * Function to submit the current input value\n * Validates input, handles errors, and cleans up state after submission\n * @throws {ThreadInputError} If submission fails\n * @returns Promise that resolves when submission is complete\n */\n submit: (options?: {\n contextKey?: string;\n streamResponse?: boolean;\n }) => Promise<void>;\n}\nexport type UseThreadInput = UseThreadInputInternal &\n UseMutationResult<\n void,\n Error,\n { contextKey?: string; streamResponse?: boolean }\n >;\n\n/**\n * Hook for managing thread message input state and submission\n *\n * @returns Interface for managing thread input state and submission\n */\nexport function useTamboThreadInput(contextKey?: string): UseThreadInput {\n const { thread, inputValue, setInputValue, sendThreadMessage } =\n useTamboThread();\n\n const submit = useCallback(\n async ({\n contextKey: submitContextKey,\n streamResponse,\n }: { contextKey?: string; streamResponse?: boolean } = {}) => {\n const validation = validateInput(inputValue);\n if (!validation.isValid) {\n throw new ThreadInputError(\n `Cannot submit message: ${validation.error ?? INPUT_ERROR_MESSAGES.VALIDATION}`,\n { cause: validation.error },\n );\n }\n\n await sendThreadMessage(validation.sanitizedInput, {\n threadId: thread.id,\n contextKey: submitContextKey ?? contextKey ?? undefined,\n streamResponse: streamResponse,\n });\n setInputValue(\"\");\n },\n [inputValue, sendThreadMessage, thread.id, contextKey, setInputValue],\n );\n const {\n mutateAsync: submitAsync,\n mutate: _unusedSubmit,\n ...mutationState\n } = useTamboMutation({\n mutationFn: submit,\n });\n\n return {\n ...mutationState,\n value: inputValue,\n setValue: setInputValue,\n submit: submitAsync,\n } as UseThreadInput;\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./providers";
|
|
|
7
7
|
export type { APIError, RateLimitError, TamboAIError, } from "@tambo-ai/typescript-sdk";
|
|
8
8
|
export type { Suggestion, SuggestionGenerateParams, SuggestionGenerateResponse, SuggestionListResponse, } from "@tambo-ai/typescript-sdk/resources/beta/threads/suggestions";
|
|
9
9
|
export { useTamboThreads } from "./hooks/use-tambo-threads";
|
|
10
|
-
export { ComponentContextToolMetadata, ComponentRegistry, ParameterSpec, RegisteredComponent, TamboTool, } from "./model/component-metadata";
|
|
11
|
-
export { GenerationStage, TamboThreadMessage, } from "./model/generate-component-response";
|
|
12
|
-
export { TamboThread } from "./model/tambo-thread";
|
|
10
|
+
export { type ComponentContextToolMetadata, type ComponentRegistry, type ParameterSpec, type RegisteredComponent, type TamboTool, } from "./model/component-metadata";
|
|
11
|
+
export { GenerationStage, type TamboThreadMessage, } from "./model/generate-component-response";
|
|
12
|
+
export { type TamboThread } from "./model/tambo-thread";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wKAAwK;AACxK,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAG/D,cAAc,aAAa,CAAC;AAG5B,YAAY,EACV,QAAQ,EACR,cAAc,EACd,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,UAAU,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,SAAS,GACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,eAAe,EACf,KAAK,kBAAkB,GACxB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wKAAwK;AACxK,mEAAqE;AAA5D,6HAAA,sBAAsB,OAAA;AAC/B,mEAIqC;AAHnC,2HAAA,oBAAoB,OAAA;AACpB,6HAAA,sBAAsB,OAAA;AACtB,6HAAA,sBAAsB,OAAA;AAExB,0DAAwC;AACxC,6DAA+D;AAAtD,uHAAA,mBAAmB,OAAA;AAE5B,gCAAgC;AAChC,8CAA4B;AAc5B,+DAA4D;AAAnD,oHAAA,eAAe,OAAA;AAQxB,mFAG6C;AAF3C,8HAAA,eAAe,OAAA","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n useTamboMessageContext,\n} from \"./hooks/use-current-message\";\nexport * from \"./hooks/use-suggestions\";\nexport { useTamboThreadInput } from \"./hooks/use-thread-input\";\n\n// Re-export provider components\nexport * from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport { useTamboThreads } from \"./hooks/use-tambo-threads\";\nexport {\n ComponentContextToolMetadata,\n ComponentRegistry,\n ParameterSpec,\n RegisteredComponent,\n TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport { TamboThread } from \"./model/tambo-thread\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,wKAAwK;AACxK,mEAAqE;AAA5D,6HAAA,sBAAsB,OAAA;AAC/B,mEAIqC;AAHnC,2HAAA,oBAAoB,OAAA;AACpB,6HAAA,sBAAsB,OAAA;AACtB,6HAAA,sBAAsB,OAAA;AAExB,0DAAwC;AACxC,6DAA+D;AAAtD,uHAAA,mBAAmB,OAAA;AAE5B,gCAAgC;AAChC,8CAA4B;AAc5B,+DAA4D;AAAnD,oHAAA,eAAe,OAAA;AAQxB,mFAG6C;AAF3C,8HAAA,eAAe,OAAA","sourcesContent":["/** Exports for the library. Only publically available exports are re-exported here. Anything not exported here is not supported and may change or break at any time. */\nexport { useTamboComponentState } from \"./hooks/use-component-state\";\nexport {\n TamboMessageProvider,\n useTamboCurrentMessage,\n useTamboMessageContext,\n} from \"./hooks/use-current-message\";\nexport * from \"./hooks/use-suggestions\";\nexport { useTamboThreadInput } from \"./hooks/use-thread-input\";\n\n// Re-export provider components\nexport * from \"./providers\";\n\n// Re-export types from Tambo Node SDK\nexport type {\n APIError,\n RateLimitError,\n TamboAIError,\n} from \"@tambo-ai/typescript-sdk\";\nexport type {\n Suggestion,\n SuggestionGenerateParams,\n SuggestionGenerateResponse,\n SuggestionListResponse,\n} from \"@tambo-ai/typescript-sdk/resources/beta/threads/suggestions\";\nexport { useTamboThreads } from \"./hooks/use-tambo-threads\";\nexport {\n type ComponentContextToolMetadata,\n type ComponentRegistry,\n type ParameterSpec,\n type RegisteredComponent,\n type TamboTool,\n} from \"./model/component-metadata\";\nexport {\n GenerationStage,\n type TamboThreadMessage,\n} from \"./model/generate-component-response\";\nexport { type TamboThread } from \"./model/tambo-thread\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-metadata.d.ts","sourceRoot":"","sources":["../../src/model/component-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,KAAK,eAAe,MAAM,oBAAoB,CAAC;AACtD,+FAA+F;AAC/F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AE,MAAM,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-component-response.d.ts","sourceRoot":"","sources":["../../src/model/generate-component-response.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAErC;uBACuB;AACvB,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa;IAC5E,iBAAiB,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;CACzC;AAED,oBAAY,eAAe;IACzB,IAAI,SAAS;IACb,kBAAkB,uBAAuB;IACzC,gBAAgB,qBAAqB;IACrC,mBAAmB,wBAAwB;IAC3C,kBAAkB,uBAAuB;IACzC,QAAQ,aAAa;IACrB,KAAK,UAAU;CAChB;AACD,wBAAgB,WAAW,CAAC,eAAe,EAAE,eAAe,WAM3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-thread.d.ts","sourceRoot":"","sources":["../../src/model/tambo-thread.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE;qCACqC;AACrC,MAAM,WAAW,WAAY,SAAQ,OAAO,CAAC,IAAI,CAAC,MAAM;IACtD,QAAQ,EAAE,kBAAkB,EAAE,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread-input-error.d.ts","sourceRoot":"","sources":["../../src/model/thread-input-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD,qBAAa,gBAAiB,SAAQ,YAAY;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-input.d.ts","sourceRoot":"","sources":["../../src/model/validate-input.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;CACxB;AAGD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,CAwB7D"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { TamboClientProvider, useTamboClient } from "./tambo-client-provider";
|
|
2
2
|
export { TamboComponentProvider, useTamboComponent, } from "./tambo-component-provider";
|
|
3
3
|
export { TamboContext, TamboProvider, useTambo } from "./tambo-provider";
|
|
4
|
-
export {
|
|
4
|
+
export { TamboRegistryProvider, useTamboRegistry, type RegisterComponentOptions, type TamboRegistryContext, } from "./tambo-registry-provider";
|
|
5
5
|
export { TamboThreadContext, TamboThreadProvider, useTamboThread, } from "./tambo-thread-provider";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EACL,sBAAsB,EACtB,iBAAiB,GAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,GAC1B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,GACf,MAAM,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAArE,4HAAA,mBAAmB,OAAA;AAAE,uHAAA,cAAc,OAAA;AAC5C,uEAGoC;AAFlC,kIAAA,sBAAsB,OAAA;AACtB,6HAAA,iBAAiB,OAAA;AAEnB,mDAAyE;AAAhE,8GAAA,YAAY,OAAA;AAAE,+GAAA,aAAa,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAC9C,qEAKmC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/providers/index.ts"],"names":[],"mappings":";;;AAAA,iEAA8E;AAArE,4HAAA,mBAAmB,OAAA;AAAE,uHAAA,cAAc,OAAA;AAC5C,uEAGoC;AAFlC,kIAAA,sBAAsB,OAAA;AACtB,6HAAA,iBAAiB,OAAA;AAEnB,mDAAyE;AAAhE,8GAAA,YAAY,OAAA;AAAE,+GAAA,aAAa,OAAA;AAAE,0GAAA,QAAQ,OAAA;AAC9C,qEAKmC;AAJjC,gIAAA,qBAAqB,OAAA;AACrB,2HAAA,gBAAgB,OAAA;AAIlB,iEAIiC;AAH/B,2HAAA,kBAAkB,OAAA;AAClB,4HAAA,mBAAmB,OAAA;AACnB,uHAAA,cAAc,OAAA","sourcesContent":["export { TamboClientProvider, useTamboClient } from \"./tambo-client-provider\";\nexport {\n TamboComponentProvider,\n useTamboComponent,\n} from \"./tambo-component-provider\";\nexport { TamboContext, TamboProvider, useTambo } from \"./tambo-provider\";\nexport {\n TamboRegistryProvider,\n useTamboRegistry,\n type RegisterComponentOptions,\n type TamboRegistryContext,\n} from \"./tambo-registry-provider\";\nexport {\n TamboThreadContext,\n TamboThreadProvider,\n useTamboThread,\n} from \"./tambo-thread-provider\";\n"]}
|
|
@@ -2,8 +2,9 @@ import TamboAI from "@tambo-ai/typescript-sdk";
|
|
|
2
2
|
import { QueryClient } from "@tanstack/react-query";
|
|
3
3
|
import React, { PropsWithChildren } from "react";
|
|
4
4
|
export interface TamboClientProviderProps {
|
|
5
|
-
tamboUrl
|
|
5
|
+
tamboUrl?: string;
|
|
6
6
|
apiKey: string;
|
|
7
|
+
environment?: "production" | "staging";
|
|
7
8
|
}
|
|
8
9
|
export interface TamboClientContextProps {
|
|
9
10
|
client: TamboAI;
|
|
@@ -13,3 +14,4 @@ export interface TamboClientContextProps {
|
|
|
13
14
|
export declare const TamboClientProvider: React.FC<PropsWithChildren<TamboClientProviderProps>>;
|
|
14
15
|
export declare const useTamboClient: () => TamboAI;
|
|
15
16
|
export declare const useTamboQueryClient: () => QueryClient;
|
|
17
|
+
//# sourceMappingURL=tambo-client-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-client-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAY,MAAM,OAAO,CAAC;AAE1E,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACxC;AACD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,OAAO,CAAC;IAChB,sCAAsC;IACtC,WAAW,EAAE,WAAW,CAAC;CAC1B;AAMD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CACxC,iBAAiB,CAAC,wBAAwB,CAAC,CAgB5C,CAAC;AAEF,eAAO,MAAM,cAAc,eAM1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,mBAQ/B,CAAC"}
|
|
@@ -41,8 +41,15 @@ const typescript_sdk_1 = __importDefault(require("@tambo-ai/typescript-sdk"));
|
|
|
41
41
|
const react_query_1 = require("@tanstack/react-query");
|
|
42
42
|
const react_1 = __importStar(require("react"));
|
|
43
43
|
const TamboClientContext = (0, react_1.createContext)(undefined);
|
|
44
|
-
const TamboClientProvider = ({ children, tamboUrl, apiKey }) => {
|
|
45
|
-
const
|
|
44
|
+
const TamboClientProvider = ({ children, tamboUrl, apiKey, environment }) => {
|
|
45
|
+
const tamboConfig = { apiKey };
|
|
46
|
+
if (tamboUrl) {
|
|
47
|
+
tamboConfig.baseURL = tamboUrl;
|
|
48
|
+
}
|
|
49
|
+
if (environment) {
|
|
50
|
+
tamboConfig.environment = environment;
|
|
51
|
+
}
|
|
52
|
+
const [client] = (0, react_1.useState)(() => new typescript_sdk_1.default(tamboConfig));
|
|
46
53
|
const [queryClient] = (0, react_1.useState)(() => new react_query_1.QueryClient());
|
|
47
54
|
return (react_1.default.createElement(TamboClientContext.Provider, { value: { client, queryClient } }, children));
|
|
48
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-client-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"tambo-client-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-client-provider.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8EAAkE;AAClE,uDAAoD;AACpD,+CAA0E;AAa1E,MAAM,kBAAkB,GAAG,IAAA,qBAAa,EACtC,SAAS,CACV,CAAC;AAEK,MAAM,mBAAmB,GAE5B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,EAAE,EAAE;IAClD,MAAM,WAAW,GAAkB,EAAE,MAAM,EAAE,CAAC;IAC9C,IAAI,QAAQ,EAAE,CAAC;QACb,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IACjC,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,WAAW,CAAC,WAAW,GAAG,WAAW,CAAC;IACxC,CAAC;IACD,MAAM,CAAC,MAAM,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,IAAI,wBAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,GAAG,EAAE,CAAC,IAAI,yBAAW,EAAE,CAAC,CAAC;IACxD,OAAO,CACL,8BAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,IACxD,QAAQ,CACmB,CAC/B,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,mBAAmB,uBAiB9B;AAEK,MAAM,cAAc,GAAG,GAAG,EAAE;IACjC,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,OAAO,CAAC,MAAM,CAAC;AACxB,CAAC,CAAC;AANW,QAAA,cAAc,kBAMzB;AAEK,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,OAAO,GAAG,eAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CACb,+DAA+D,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC,WAAW,CAAC;AAC7B,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B","sourcesContent":["import TamboAI, { ClientOptions } from \"@tambo-ai/typescript-sdk\";\nimport { QueryClient } from \"@tanstack/react-query\";\nimport React, { createContext, PropsWithChildren, useState } from \"react\";\n\nexport interface TamboClientProviderProps {\n tamboUrl?: string;\n apiKey: string;\n environment?: \"production\" | \"staging\";\n}\nexport interface TamboClientContextProps {\n client: TamboAI;\n /** The tambo-specific query client */\n queryClient: QueryClient;\n}\n\nconst TamboClientContext = createContext<TamboClientContextProps | undefined>(\n undefined,\n);\n\nexport const TamboClientProvider: React.FC<\n PropsWithChildren<TamboClientProviderProps>\n> = ({ children, tamboUrl, apiKey, environment }) => {\n const tamboConfig: ClientOptions = { apiKey };\n if (tamboUrl) {\n tamboConfig.baseURL = tamboUrl;\n }\n if (environment) {\n tamboConfig.environment = environment;\n }\n const [client] = useState(() => new TamboAI(tamboConfig));\n const [queryClient] = useState(() => new QueryClient());\n return (\n <TamboClientContext.Provider value={{ client, queryClient }}>\n {children}\n </TamboClientContext.Provider>\n );\n};\n\nexport const useTamboClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\"useTamboClient must be used within a TamboClientProvider\");\n }\n return context.client;\n};\n\nexport const useTamboQueryClient = () => {\n const context = React.useContext(TamboClientContext);\n if (context === undefined) {\n throw new Error(\n \"useTamboQueryClient must be used within a TamboClientProvider\",\n );\n }\n return context.queryClient;\n};\n"]}
|
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
import TamboAI from "@tambo-ai/typescript-sdk";
|
|
2
1
|
import React, { PropsWithChildren } from "react";
|
|
3
2
|
import { TamboTool } from "../model/component-metadata";
|
|
4
|
-
import { GenerationStage, TamboThreadMessage } from "../model/generate-component-response";
|
|
5
3
|
import { RegisterComponentOptions } from "./tambo-registry-provider";
|
|
6
4
|
export interface TamboComponentContextProps {
|
|
7
5
|
registerComponent: (options: RegisterComponentOptions) => void;
|
|
8
|
-
generateComponent: (params: TamboAI.Beta.Components.ComponentGenerateParams & {
|
|
9
|
-
stream?: boolean;
|
|
10
|
-
}, options?: TamboAI.RequestOptions) => Promise<TamboThreadMessage>;
|
|
11
|
-
generationStage: GenerationStage;
|
|
12
|
-
isIdle: boolean;
|
|
13
6
|
registerTool: (tool: TamboTool) => void;
|
|
14
7
|
registerTools: (tools: TamboTool[]) => void;
|
|
15
8
|
addToolAssociation: (componentName: string, tool: TamboTool) => void;
|
|
16
9
|
}
|
|
17
10
|
export declare const TamboComponentProvider: React.FC<PropsWithChildren>;
|
|
18
11
|
export declare const useTamboComponent: () => TamboComponentContextProps;
|
|
12
|
+
//# sourceMappingURL=tambo-component-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-component-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-component-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAiB,iBAAiB,EAAc,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EACL,wBAAwB,EAEzB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC/D,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC5C,kBAAkB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACtE;AASD,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAoB9D,CAAC;AAEF,eAAO,MAAM,iBAAiB,kCAE7B,CAAC"}
|
|
@@ -36,15 +36,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
37
|
exports.useTamboComponent = exports.TamboComponentProvider = void 0;
|
|
38
38
|
const react_1 = __importStar(require("react"));
|
|
39
|
-
const generate_component_response_1 = require("../model/generate-component-response");
|
|
40
|
-
const generate_component_1 = require("../util/generate-component");
|
|
41
39
|
const tambo_client_provider_1 = require("./tambo-client-provider");
|
|
42
40
|
const tambo_registry_provider_1 = require("./tambo-registry-provider");
|
|
43
|
-
const tambo_thread_provider_1 = require("./tambo-thread-provider");
|
|
44
41
|
const TamboComponentContext = (0, react_1.createContext)({
|
|
45
|
-
generateComponent: () => Promise.resolve({}),
|
|
46
|
-
generationStage: generate_component_response_1.GenerationStage.IDLE,
|
|
47
|
-
isIdle: true,
|
|
48
42
|
registerComponent: () => { },
|
|
49
43
|
registerTool: () => { },
|
|
50
44
|
registerTools: () => { },
|
|
@@ -52,69 +46,10 @@ const TamboComponentContext = (0, react_1.createContext)({
|
|
|
52
46
|
});
|
|
53
47
|
const TamboComponentProvider = ({ children, }) => {
|
|
54
48
|
const client = (0, tambo_client_provider_1.useTamboClient)();
|
|
55
|
-
const {
|
|
56
|
-
const { componentList, registerComponent, addToolAssociation, registerTool, componentToolAssociations, registerTools, toolRegistry, } = (0, tambo_registry_provider_1.useTamboRegistry)();
|
|
57
|
-
const [generationStage, setGenerationStage] = (0, react_1.useState)(generate_component_response_1.GenerationStage.IDLE);
|
|
58
|
-
const isIdle = (0, generate_component_response_1.isIdleStage)(generationStage);
|
|
59
|
-
const generateComponent = (0, react_1.useCallback)(async (params, options) => {
|
|
60
|
-
if (!(0, generate_component_response_1.isIdleStage)(generationStage)) {
|
|
61
|
-
throw new Error(`Generation already in progress: ${generationStage}`);
|
|
62
|
-
}
|
|
63
|
-
if (params.threadId && params.threadId !== currentThread.id) {
|
|
64
|
-
switchCurrentThread(params.threadId);
|
|
65
|
-
}
|
|
66
|
-
const componentMessage = await (0, generate_component_1.generateAndHydrate)(client, componentList, toolRegistry, componentToolAssociations, currentThread.id === tambo_thread_provider_1.PLACEHOLDER_THREAD.id
|
|
67
|
-
? undefined
|
|
68
|
-
: currentThread.id, params.content, params, (state) => setGenerationStage(state), params.stream, options);
|
|
69
|
-
if (params.stream) {
|
|
70
|
-
let finalResponse;
|
|
71
|
-
const generationResponse = componentMessage;
|
|
72
|
-
for await (const chunk of generationResponse) {
|
|
73
|
-
if (chunk.threadId && chunk.threadId !== currentThread?.id) {
|
|
74
|
-
switchCurrentThread(chunk.threadId);
|
|
75
|
-
}
|
|
76
|
-
if (!finalResponse) {
|
|
77
|
-
finalResponse = chunk;
|
|
78
|
-
addThreadMessage(finalResponse, false);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
// use previous chunk's id for update, in case new chunk has a different id (from tambotion response)
|
|
82
|
-
updateThreadMessage(finalResponse.id, chunk, false);
|
|
83
|
-
finalResponse = chunk;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (!finalResponse) {
|
|
87
|
-
throw new Error("No response from generation");
|
|
88
|
-
}
|
|
89
|
-
return finalResponse;
|
|
90
|
-
}
|
|
91
|
-
const generationResponse = componentMessage;
|
|
92
|
-
if (generationResponse.threadId &&
|
|
93
|
-
generationResponse.threadId !== currentThread?.id) {
|
|
94
|
-
switchCurrentThread(generationResponse.threadId);
|
|
95
|
-
}
|
|
96
|
-
if (generationResponse) {
|
|
97
|
-
// we do not need to send this to the server, as it is already in the thread
|
|
98
|
-
addThreadMessage(generationResponse, false);
|
|
99
|
-
}
|
|
100
|
-
return generationResponse;
|
|
101
|
-
}, [
|
|
102
|
-
generationStage,
|
|
103
|
-
switchCurrentThread,
|
|
104
|
-
currentThread,
|
|
105
|
-
client,
|
|
106
|
-
componentList,
|
|
107
|
-
addThreadMessage,
|
|
108
|
-
updateThreadMessage,
|
|
109
|
-
componentToolAssociations,
|
|
110
|
-
toolRegistry,
|
|
111
|
-
]);
|
|
49
|
+
const { registerComponent, addToolAssociation, registerTool, registerTools } = (0, tambo_registry_provider_1.useTamboRegistry)();
|
|
112
50
|
const value = {
|
|
113
51
|
client,
|
|
114
|
-
generateComponent,
|
|
115
52
|
registerComponent,
|
|
116
|
-
generationStage,
|
|
117
|
-
isIdle,
|
|
118
53
|
registerTool,
|
|
119
54
|
registerTools,
|
|
120
55
|
addToolAssociation,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-component-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-component-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"tambo-component-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-component-provider.tsx"],"names":[],"mappings":";AAAA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACb,+CAA4E;AAE5E,mEAAyD;AACzD,uEAGmC;AASnC,MAAM,qBAAqB,GAAG,IAAA,qBAAa,EAA6B;IACtE,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC3B,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC;IACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC;IACvB,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;CAC7B,CAAC,CAAC;AAEI,MAAM,sBAAsB,GAAgC,CAAC,EAClE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,MAAM,GAAG,IAAA,sCAAc,GAAE,CAAC;IAChC,MAAM,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,YAAY,EAAE,aAAa,EAAE,GAC1E,IAAA,0CAAgB,GAAE,CAAC;IAErB,MAAM,KAAK,GAAG;QACZ,MAAM;QACN,iBAAiB;QACjB,YAAY;QACZ,aAAa;QACb,kBAAkB;KACnB,CAAC;IAEF,OAAO,CACL,8BAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACzC,QAAQ,CACsB,CAClC,CAAC;AACJ,CAAC,CAAC;AApBW,QAAA,sBAAsB,0BAoBjC;AAEK,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,OAAO,IAAA,kBAAU,EAAC,qBAAqB,CAAC,CAAC;AAC3C,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B","sourcesContent":["\"use client\";\nimport React, { createContext, PropsWithChildren, useContext } from \"react\";\nimport { TamboTool } from \"../model/component-metadata\";\nimport { useTamboClient } from \"./tambo-client-provider\";\nimport {\n RegisterComponentOptions,\n useTamboRegistry,\n} from \"./tambo-registry-provider\";\n\nexport interface TamboComponentContextProps {\n registerComponent: (options: RegisterComponentOptions) => void;\n registerTool: (tool: TamboTool) => void;\n registerTools: (tools: TamboTool[]) => void;\n addToolAssociation: (componentName: string, tool: TamboTool) => void;\n}\n\nconst TamboComponentContext = createContext<TamboComponentContextProps>({\n registerComponent: () => {},\n registerTool: () => {},\n registerTools: () => {},\n addToolAssociation: () => {},\n});\n\nexport const TamboComponentProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const client = useTamboClient();\n const { registerComponent, addToolAssociation, registerTool, registerTools } =\n useTamboRegistry();\n\n const value = {\n client,\n registerComponent,\n registerTool,\n registerTools,\n addToolAssociation,\n };\n\n return (\n <TamboComponentContext.Provider value={value}>\n {children}\n </TamboComponentContext.Provider>\n );\n};\n\nexport const useTamboComponent = () => {\n return useContext(TamboComponentContext);\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,iBAAiB,EAA6B,MAAM,OAAO,CAAC;AAC5E,OAAO,EACL,uBAAuB,EAEvB,wBAAwB,EAGzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,0BAA0B,EAG3B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,uBAAuB,EAGxB,MAAM,yBAAyB,CAAC;AAEjC,mFAAmF;AAEnF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC,iBAAiB,CAAC,wBAAwB,CAAC,CAa5C,CAAC;AACF,KAAK,iBAAiB,GAAG,uBAAuB,GAC9C,uBAAuB,GACvB,0BAA0B,CAAC;AAE7B,eAAO,MAAM,YAAY,kCAExB,CAAC;AAuBF,eAAO,MAAM,QAAQ,yBAEpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-registry-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-registry-provider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,iBAAiB,EAIlB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE3E,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IAC9B,eAAe,CAAC,EAAE,GAAG,CAAC;IACtB,gBAAgB,CAAC,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC;IACtC,eAAe,CAAC,EAAE,SAAS,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,iBAAiB,CAAC;IACjC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACxC,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACpD,iBAAiB,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAC/D,YAAY,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IACxC,aAAa,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,IAAI,CAAC;IAC5C,kBAAkB,EAAE,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;CACtE;AAYD,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAgG7D,CAAC;AAEF,eAAO,MAAM,gBAAgB,4BAE5B,CAAC"}
|
|
@@ -15,6 +15,9 @@ export interface TamboThreadContextProps {
|
|
|
15
15
|
streamResponse?: boolean;
|
|
16
16
|
contextKey?: string;
|
|
17
17
|
}) => Promise<TamboThreadMessage>;
|
|
18
|
+
generationStage: GenerationStage;
|
|
19
|
+
generationStatusMessage: string;
|
|
20
|
+
isIdle: boolean;
|
|
18
21
|
}
|
|
19
22
|
/** This is a stub entry for when the thread is not yet created, the first time
|
|
20
23
|
* the user sends a message
|
|
@@ -26,3 +29,4 @@ export declare const PLACEHOLDER_THREAD: TamboThread;
|
|
|
26
29
|
export declare const TamboThreadContext: React.Context<TamboThreadContextProps>;
|
|
27
30
|
export declare const TamboThreadProvider: React.FC<PropsWithChildren>;
|
|
28
31
|
export declare const useTamboThread: () => TamboThreadContextProps;
|
|
32
|
+
//# sourceMappingURL=tambo-thread-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tambo-thread-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-thread-provider.tsx"],"names":[],"mappings":"AACA,OAAO,OAA0B,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAMlB,MAAM,OAAO,CAAC;AACf,OAAO,EACL,eAAe,EAEf,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAOpD,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,WAAW,CAAC;IACpB,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAChD,gBAAgB,EAAE,CAChB,OAAO,EAAE,kBAAkB,EAC3B,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IACnD,mBAAmB,EAAE,CACnB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,kBAAkB,EAC3B,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,mBAAmB,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,iBAAiB,EAAE,CAC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