Skip to content

Commit

Permalink
refactor: cleanup (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonom authored Jun 20, 2024
1 parent 36f3a1f commit 2ecfa5e
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 167 deletions.
1 change: 0 additions & 1 deletion packages/react-ai-sdk/src/core/VercelModelAdapter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class VercelModelAdapter implements ChatModelAdapter {
messages: messages.flatMap(convertToCoreMessage),
...(config.tools
? {
// biome-ignore lint/suspicious/noExplicitAny: TODO
tools: config.tools as Record<string, CoreTool<any>>,
}
: {}),
Expand Down
2 changes: 0 additions & 2 deletions packages/react-ai-sdk/src/core/convertToCoreMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ export const convertToCoreMessage = (message: ThreadMessage): CoreMessage[] => {
) {
expandedMessages.push({
role: content.type === "tool-result" ? "tool" : message.role,
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
content: [content] as any,
});
} else {
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
(lastMessage.content as Array<any>).push(content);
}
};
Expand Down
16 changes: 5 additions & 11 deletions packages/react-hook-form/src/useAssistantForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ export type UseAssistantFormProps<

export const useAssistantForm = <
TFieldValues extends FieldValues = FieldValues,
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
TContext = any,
TTransformedValues extends FieldValues | undefined = undefined,
>(
props?: UseAssistantFormProps<TFieldValues, TContext>,
): UseFormReturn<TFieldValues, TContext, TTransformedValues> => {
const form = useForm<TFieldValues, TContext, TTransformedValues>(props);
const { control, getValues, setValue } = form;

const { useModelConfig } = useAssistantContext();
const registerModelConfigProvider = useModelConfig(
Expand All @@ -55,22 +55,21 @@ export const useAssistantForm = <

useEffect(() => {
const value: ModelConfig = {
system: `Form State:\n${JSON.stringify(form.getValues())}`,
system: `Form State:\n${JSON.stringify(getValues())}`,

tools: {
set_form_field: {
...formTools.set_form_field,
execute: async (args) => {
// biome-ignore lint/suspicious/noExplicitAny: TODO
form.setValue(args.name as any, args.value as any);
setValue(args.name, args.value);

return { success: true };
},
},
submit_form: {
...formTools.submit_form,
execute: async () => {
const { _names, _fields } = form.control;
const { _names, _fields } = control;
for (const name of _names.mount) {
const field = _fields[name];
if (field?._f) {
Expand Down Expand Up @@ -99,12 +98,7 @@ export const useAssistantForm = <
},
};
return registerModelConfigProvider(() => value);
}, [
form.control,
form.setValue,
form.getValues,
registerModelConfigProvider,
]);
}, [control, setValue, getValues, registerModelConfigProvider]);

const renderFormFieldTool = props?.assistant?.tools?.set_form_field?.render;
useAssistantToolRenderer(
Expand Down
148 changes: 0 additions & 148 deletions packages/react-markdown/src/codeblock.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export type AssistantToolRendererProps<TArgs, TResult> = {
};

export const useAssistantToolRenderer = (
// biome-ignore lint/suspicious/noExplicitAny: intentional any
tool: AssistantToolRendererProps<any, any> | null,
) => {
const { useToolRenderers } = useAssistantContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@ export type UIContentPartProps = {
};
export type UIContentPartComponent = ComponentType<UIContentPartProps>;

// biome-ignore lint/suspicious/noExplicitAny: intentional any
export type ToolCallContentPartProps<TArgs = any, TResult = any> = {
part: ToolCallContentPart<TArgs, TResult>;
status: ContentPartStatus;
};

export type ToolCallContentPartComponent<
// biome-ignore lint/suspicious/noExplicitAny: intentional any
TArgs = any,
// biome-ignore lint/suspicious/noExplicitAny: intentional any
TResult = any,
> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
1 change: 0 additions & 1 deletion packages/react/src/utils/ModelConfigTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export type Tool<TArgs = unknown, TResult = unknown> = {
export type ModelConfig = {
priority?: number;
system?: string;
// biome-ignore lint/suspicious/noExplicitAny: intentional any
tools?: Record<string, Tool<any, any>>;
};

Expand Down

0 comments on commit 2ecfa5e

Please sign in to comment.