Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Cleanup

Tomas Valentaec2de87b2e4a
diff --git a/components/Editor/Sidebar/index.tsx b/components/Editor/Sidebar/index.tsx
index 880babb8d..f7b1ee491 100644
--- a/components/Editor/Sidebar/index.tsx
+++ b/components/Editor/Sidebar/index.tsx
@@ -22,7 +22,6 @@ export interface Props {
activeMenuSection?: MenuSection
}
-
interface PostGenerateBody {
projectID: string
modelConfig: ModelConfig
@@ -89,6 +88,18 @@ function Sidebar({
const [creds] = useModelProviderArgs()
+ const [isInitializingDeploy, setIsInitializingDeploy] = useState(false)
+
+ useEffect(function handleDeployState() {
+ if (!deployment) return
+ setIsInitializingDeploy(false)
+ }, [deployment])
+
+ useEffect(function handleDeployState() {
+ if (!isDeployRequestRunning) return
+ setIsInitializingDeploy(true)
+ }, [isDeployRequestRunning])
+
async function deploy() {
if (!modelConfig) {
console.error('Cannot get model config')
@@ -109,22 +120,10 @@ function Sidebar({
})
}
- async function cancelGenerate() {
+ function cancelGenerate() {
generateController.current?.abort()
}
- const [isInitializingDeploy, setIsInitializingDeploy] = useState(false)
-
- useEffect(function handleDeployState() {
- if (!deployment) return
- setIsInitializingDeploy(false)
- }, [deployment])
-
- useEffect(function handleDeployState() {
- if (!isDeployRequestRunning) return
- setIsInitializingDeploy(true)
- }, [isDeployRequestRunning])
-
return (
<div
className={clsx(`
diff --git a/state/instruction.ts b/state/instruction.ts
index 7bae731cd..346c2a2bc 100644
--- a/state/instruction.ts
+++ b/state/instruction.ts
@@ -27,20 +27,22 @@ export function transformInstructions(
) {
let newInstructions = JSON.parse(JSON.stringify(instructions))
- Object.entries(instructionsTransform).forEach(([jsonPath, transformType]) => {
- JSONPath({
- path: jsonPath,
- json: newInstructions,
- callback: (payload, payloadType, fullPayload) => {
- const newPayload = transform(payload, transformType?.type)
- if (fullPayload.parent) {
- fullPayload.parent[fullPayload.parentProperty] = newPayload
- } else if (fullPayload.parent === null) {
- newInstructions = newPayload
+ Object
+ .entries(instructionsTransform)
+ .forEach(([jsonPath, transformType]) => {
+ JSONPath({
+ path: jsonPath,
+ json: newInstructions,
+ callback: (payload, payloadType, fullPayload) => {
+ const newPayload = transform(payload, transformType?.type)
+ if (fullPayload.parent) {
+ fullPayload.parent[fullPayload.parentProperty] = newPayload
+ } else if (fullPayload.parent === null) {
+ newInstructions = newPayload
+ }
}
- }
+ })
})
- })
return newInstructions
}
diff --git a/state/model.ts b/state/model.ts
index fbec629bc..05a535d45 100644
--- a/state/model.ts
+++ b/state/model.ts
@@ -482,18 +482,22 @@ export function getModelArgs(
}
}
+export const defaultModelProvider = ModelProvider.OpenAI
+export const defaultModelName = providerTemplates[defaultModelProvider].models[0].name
+
export function getMissingCreds(provider: ModelProvider, creds: Creds) {
return Object
.entries(providerTemplates[provider]?.creds || {})
- .filter(([key,]) => creds[provider]?.creds?.[key] === undefined)
+ .filter(([key]) => creds[provider]?.creds?.[key] === undefined)
}
export function getDefaultModelConfig(templateID: TemplateID): ModelConfig {
const prompt = templates[templateID].prompt
+ console.log('def model')
return {
- provider: ModelProvider.OpenAI,
- name: providerTemplates[ModelProvider.OpenAI].models[0].name,
+ provider: defaultModelProvider,
+ name: defaultModelName,
args: {},
prompt,
}
diff --git a/state/prompt.ts b/state/prompt.ts
index 47e3d470e..a8505a05d 100644
--- a/state/prompt.ts
+++ b/state/prompt.ts
@@ -23,6 +23,9 @@ export function getPromptLabel(fragment: PromptFragment) {
export interface PromptFragment {
role: 'user' | 'system'
type: string
+ /**
+ * By default the content is in XML format and we have to transform it before sending it in a request to backend.
+ */
content: string
}