Skip to content

Commit

Permalink
feat: add config
Browse files Browse the repository at this point in the history
  • Loading branch information
paulclindo committed Dec 12, 2024
1 parent 932ed6b commit 90a9b5d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ReloadIcon } from '@radix-ui/react-icons';
import { FormProps } from '@rjsf/core';
import { RJSFSchema } from '@rjsf/utils';
import validator from '@rjsf/validator-ajv8';
import { useTranslation } from '@shinkai_network/shinkai-i18n';
import {
Expand Down Expand Up @@ -149,7 +148,7 @@ function PlaygroundToolEditor({
});

const handleRunCode: FormProps['onSubmit'] = async (data) => {
const params = data.formData;
const { configs, params } = data.formData;
const updatedCodeWithoutSave = codeEditorRef.current?.value ?? '';
await executeToolCodeQuery.mutateAsync({
code: isDirtyCodeEditor ? updatedCodeWithoutSave : toolCode,
Expand All @@ -159,6 +158,7 @@ function PlaygroundToolEditor({
llmProviderId: form.getValues('llmProviderId'),
tools: form.getValues('tools'),
language: form.getValues('language'),
configs,
});
};

Expand Down Expand Up @@ -629,11 +629,41 @@ function PlaygroundToolEditor({
noHtml5Validate={true}
onChange={(e) => setFormData(e.formData)}
onSubmit={handleRunCode}
schema={
metadataGenerationData?.parameters as RJSFSchema
}
schema={{
type: 'object',
properties: {
...(metadataGenerationData?.configurations
?.properties &&
Object.keys(
metadataGenerationData.configurations
.properties,
).length > 0
? {
configs:
metadataGenerationData.configurations,
}
: {}),
...(metadataGenerationData?.parameters
?.properties &&
Object.keys(
metadataGenerationData.parameters
.properties,
).length > 0
? {
params:
metadataGenerationData.parameters,
}
: {}),
},
}}
uiSchema={{
'ui:submitButtonOptions': { norender: true },
configs: {
'ui:title': 'Config',
},
params: {
'ui:title': 'Inputs',
},
}}
validator={validator}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,6 @@ export const useToolCode = ({
}, 0);
};

console.log({ toolHistory, toolCode });

return {
chatInboxId,
toolCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const executeToolCode = async ({
return await executeToolCodeApi(nodeAddress, token, {
tool_type: toolTypeLanguageMap[language],
code,
parameters: params,
parameters: params ?? {},
llm_provider: llmProviderId,
tools,
extra_config: configs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function FieldTemplate<
style={style}
uiSchema={uiSchema}
>
<div className="mb-4 block">
<div className="mb-3 block">
{displayLabel && (
<label
className={cn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ export default function TitleField<

return (
<div id={id}>
<h5
className={cn(
'text-gray-80 mb-2 inline-block text-xs uppercase tracking-[2px]',
)}
>
<h5 className={cn('mb-2 inline-block text-xs uppercase text-gray-50')}>
{uiOptions.title || title}
</h5>
{/*<hr className="my-1 border-t border-gray-200" />*/}
Expand Down

0 comments on commit 90a9b5d

Please sign in to comment.