Open-source, secure environment with real-world tools for enterprise-grade agents.
Python agentaiai-agentai-agentscode-interpretercopilotdevelopmentdevtoolsgptgpt-4javascriptllmnextjsopenaipythonreactsoftwaretypescript
handle next action logs for autogpt
Vasek Mlejnsky315a21b46c30
diff --git a/components/AgentContextDetail.tsx b/components/AgentPromptLogDetail.tsxsimilarity index 74%rename from components/AgentContextDetail.tsxrename to components/AgentPromptLogDetail.tsxindex f28cf560f..975a7e677 100644--- a/components/AgentContextDetail.tsx+++ b/components/AgentPromptLogDetail.tsx@@ -7,30 +7,29 @@ import dynamic from 'next/dynamic'const ReactJson = dynamic(import('react-json-view'), { ssr: false })export interface Props {- context?: SystemPromptLog | UserPromptLog | AssistantPromptLog+ log?: SystemPromptLog | UserPromptLog | AssistantPromptLog}-function AgentContextDetail({- context,+function AgentPrompLogDetail({+ log,}: Props) {return (<div className="overflow-auto p-2 h-full bg-[#1F2437] rounded-md flex flex-col space-y-4 w-full border border-gray-800"><h2 className="font-medium text-sm text-gray-500">Context</h2>-- {context && (+ {log && (<><div className="flex flex-col space-y-1 w-full"><span className="text-sm font-medium text-gray-500">Role</span>- <span className="text-sm text-gray-200 w-full">{context.role}</span>+ <span className="text-sm text-gray-200 w-full">{log.role}</span></div><div className="flex flex-col space-y-1 w-full"><span className="text-sm font-medium text-gray-500">Content</span>- {(context as any).role !== 'assistant' ? (- <p className="text-sm text-gray-200 w-full prose whitespace-pre-wrap max-w-full">{context.content}</p>+ {log.role !== 'assistant' ? (+ <p className="text-sm text-gray-200 w-full prose whitespace-pre-wrap max-w-full">{log.content}</p>) : (<ReactJson- src={JSON.parse(context.content)}+ src={JSON.parse(log.content)}name={null}style={{background: 'transparent'@@ -45,13 +44,13 @@ function AgentContextDetail({)}</div>- {(context as any).role === 'assistant' && (+ {log.role === 'assistant' && log.function_call && (<><span className="text-sm font-medium text-gray-500">Function Call</span><ReactJsonsrc={{- ...(context as any).function_call,- 'arguments': JSON.parse((context as any).function_call.arguments),+ ...(log as any).function_call,+ 'arguments': JSON.parse(log.function_call.arguments),}}name={null}style={{@@ -67,11 +66,9 @@ function AgentContextDetail({</>)}</>- )- }-+ )}</div >)}-export default AgentContextDetail\ No newline at end of file+export default AgentPrompLogDetail\ No newline at end of filediff --git a/pages/log/[logFileID].tsx b/pages/log/[logFileID].tsxindex 4a709f175..efb7de516 100644--- a/pages/log/[logFileID].tsx+++ b/pages/log/[logFileID].tsx@@ -16,6 +16,7 @@ import {AssistantPromptLog,} from 'utils/agentLogs'import AgentPromptLogs from 'components/AgentPromptLogs'+import AgentPrompLogDetail from 'components/AgentPromptLogDetail'interface PathProps extends ParsedUrlQuery {logFileID: string@@ -124,7 +125,9 @@ export const getServerSideProps: GetServerSideProps<Props, PathProps> = async (cprops: {logFile: {name: file.filename,- content: JSON.parse(file.content),+ content: {+ logs: JSON.parse(file.content),+ },relativePath: file.metadata.relativePath,}}@@ -136,6 +139,7 @@ export interface Props {}function LogFile({ logFile }: Props) {+ console.log('logFile', logFile)const [isResizing, setIsResizing] = useState(false)const [sizes, setSizes] = useState([60, 40])const [selectedLog, setSelectedLog] = useState<SystemPromptLog | UserPromptLog | AssistantPromptLog>()@@ -170,16 +174,16 @@ function LogFile({ logFile }: Props) {}}initialSizes={sizes}>- {logFile.name.includes('full_message_history') ? (+ {logFile.name.includes('full_message_history') || logFile.name.includes('current_context') ? (<><AgentPromptLogslogs={logFile.content.logs}onSelected={setSelectedLog}/>- <div />+ <AgentPrompLogDetail+ log={selectedLog}+ /></>- ) : logFile.name.includes('current_context') ? (- <div />) : logFile.name.includes('next_action') ? (<div />) : (@@ -187,13 +191,6 @@ function LogFile({ logFile }: Props) {Unexpected JSON format. Please reach out to the e2b team.</div>)}- {/* <AgentContext- context={logFile.content.context}- onSelected={setSelectedContext}- />- <AgentContextDetail- context={selectedContext}- /> */}</Splitter></div></main >diff --git a/utils/agentLogs.ts b/utils/agentLogs.tsindex a6065dce1..ac8e5aaea 100644--- a/utils/agentLogs.ts+++ b/utils/agentLogs.ts@@ -23,6 +23,22 @@ export interface LogFile {relativePath: string}+// This is very specific to AutoGPT logs.+// We'll generalize later.+export interface AgentNextAction {+ thoughts: {+ text: string+ reasoning: string+ plan: string+ criticism: string+ speaker: string+ }+ command: {+ name: string+ args: { [key: string]: string }+ }+}+export interface AgentLogs {logs: (SystemPromptLog | UserPromptLog | AssistantPromptLog)[]functions?: AgentFunction[]@@ -45,10 +61,10 @@ export interface UserPromptLog {}export interface AssistantPromptLog {- role: 'user'+ role: 'assistant'content: string- function_call: {+ function_call?: {name: string- arguments: { [argName: string]: string }+ arguments: string}}