Skip to content

Commit

Permalink
now selfcorrect and co returns the unaltered initial response
Browse files Browse the repository at this point in the history
  • Loading branch information
al2na committed Jan 31, 2024
1 parent f6abdc7 commit cb4f842
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions R/runCodeInResponse.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ runCodeInResponse<-function(


# Clean the code backtick structure and install.packages calls
initial.response<-response
response<-clean_code_blocks(response)


Expand All @@ -69,9 +70,9 @@ runCodeInResponse<-function(

}

first.res<-list(init.response=response,
first.res<-list(init.response=initial.response,
init.blocks=blocks,
final.response=response,
final.response=initial.response,
final.blocks=blocks,
code.works=!(is.list(res) & ("error" %in% names(res) )),
exec.result=res,
Expand Down
12 changes: 9 additions & 3 deletions R/selfcorrect.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ selfcorrect<-function(agent,prompt,context=rbionfoExp,attempts=3,output.file=NUL

attmpt.st=1 # attempt counter starting point

if(is.null(output.file)){output="eval"}
if(is.null(output.file)){output="eval"} # this doesn't do anything yet

if(is.null(responseWithError)){

Expand All @@ -79,6 +79,7 @@ selfcorrect<-function(agent,prompt,context=rbionfoExp,attempts=3,output.file=NUL
response <- sendPrompt(agent,prompt,context,return.type="text",...)

# Clean the code backtick structure and install.packages calls
init.response <- response
response<-clean_code_blocks(response)

initial.response <- response
Expand Down Expand Up @@ -155,6 +156,8 @@ selfcorrect<-function(agent,prompt,context=rbionfoExp,attempts=3,output.file=NUL
msgs<-append(msgs,list(list("role" = "user","content" = new.prompt)))

# Clean the code backtick structure and install.packages calls
init.response <- response

response<-clean_code_blocks(response)

msgs<-append(msgs,list(list("role" = "assistant","content" = response)))
Expand Down Expand Up @@ -234,7 +237,7 @@ selfcorrect<-function(agent,prompt,context=rbionfoExp,attempts=3,output.file=NUL


# Return the latest code, initial prompt, and everything else
return(list(init.response=initial.response,
return(list(init.response=init.response,
init.blocks=initial.blocks,
final.response=response,
final.blocks=blocks,
Expand Down Expand Up @@ -325,6 +328,7 @@ sampleResponse<-function(agent,prompt,
response <- sendPrompt(agent,prompt,context,return.type="text",...)

# Clean the code backtick structure and install.packages calls
init.response <- response
response<-clean_code_blocks(response)

initial.response <- response
Expand Down Expand Up @@ -368,6 +372,8 @@ sampleResponse<-function(agent,prompt,


# Clean the code backtick structure and install.packages calls
init.response <- response

response<-clean_code_blocks(response)

initial.response <- response
Expand Down Expand Up @@ -428,7 +434,7 @@ sampleResponse<-function(agent,prompt,


# Return the latest code, initial prompt, and everything else
return(list(init.response=initial.response,
return(list(init.response=init.response,
init.blocks=initial.blocks,
final.response=response,
final.blocks=blocks,
Expand Down

0 comments on commit cb4f842

Please sign in to comment.