From 19c37c32111125a15d9aff7f4e9b64d13adb96e2 Mon Sep 17 00:00:00 2001 From: tonaerospace Date: Wed, 28 Aug 2024 17:26:15 +0700 Subject: [PATCH] update --- src/interface.jl | 40 +++++++++++++++++++++------------------- src/llmfunction.jl | 3 +++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/interface.jl b/src/interface.jl index 846d94a..202d730 100644 --- a/src/interface.jl +++ b/src/interface.jl @@ -687,26 +687,27 @@ function evaluator(state::T1, text2textInstructLLM::Function; thoughthistory *= "$k: $v\n" end - usermsg = - """ - Context: None - Trajectories: $thoughthistory - """ - - _prompt = - [ - Dict(:name=> "system", :text=> systemmsg), - Dict(:name=> "user", :text=> usermsg) - ] - - # put in model format - prompt = GeneralUtils.formatLLMtext(_prompt; formatname="llama3instruct") - prompt *= - """ - <|start_header_id|>assistant<|end_header_id|> - """ - + noise = "" for attempt in 1:5 + usermsg = + """ + Trajectories: $thoughthistory + $noise + """ + + _prompt = + [ + Dict(:name=> "system", :text=> systemmsg), + Dict(:name=> "user", :text=> usermsg) + ] + + # put in model format + prompt = GeneralUtils.formatLLMtext(_prompt; formatname="llama3instruct") + prompt *= + """ + <|start_header_id|>assistant<|end_header_id|> + """ + try response = text2textInstructLLM(prompt) responsedict = GeneralUtils.textToDict(response, @@ -755,6 +756,7 @@ function evaluator(state::T1, text2textInstructLLM::Function; println("") println("Attempt $attempt. Error occurred: $errorMsg\n$st") println("") + noise = noises(3, 5) end end error("evaluator failed to generate an evaluation") diff --git a/src/llmfunction.jl b/src/llmfunction.jl index 202846c..951bb57 100644 --- a/src/llmfunction.jl +++ b/src/llmfunction.jl @@ -455,6 +455,7 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM: Let's begin! """ + noise = "" note_flag = "" for attempt in 1:10 usermsg = @@ -464,6 +465,7 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM: User intention: $(context[:userintention]) Code executed from the last round: $(state[:code]) Execution error: $(state[:errormsg]) + $noise $note_flag """ @@ -517,6 +519,7 @@ function getdata_decisionMaker(state::Dict, context::Dict, text2textInstructLLM: st = sprint((io, v) -> show(io, "text/plain", v), stacktrace(catch_backtrace())) print("Attempt $attempt. Error occurred: $errorMsg\n$st") println("") + noise = GeneralUtils.randstrings(3, 5) end end return (thought=nothing, code=nothing, success=false,