Skip to content

Commit

Permalink
code exec feature fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
baozongbo committed Dec 2, 2023
1 parent 8172038 commit 9482786
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/run_tool.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
model="/home/baozongbo/model/gorilla-hf-final-v1"
model="gorilla-llm/gorilla-7b-hf-delta-v1"
python examples/tool_inference.py \
--model ${model} \
4 changes: 2 additions & 2 deletions src/lmflow/pipeline/inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,11 @@ def code_exec(self, code):

# 检查执行结果
if result.returncode == 0:
print("执行成功,输出如下:")
print("Successfully Executed, the result is:")
print(result.stdout)
return result.stdout
else:
print("执行失败,错误信息如下:")
print("Error:")
print(result.stderr)
return result

Expand Down
3 changes: 2 additions & 1 deletion tests/models/test_tool_inferencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
"""

class ToolInferencerTest(unittest.TestCase):
def setUp(self):
def set_up(self):
model_args = ModelArguments(model_name_or_path="codellama/CodeLlama-7b-instruct-hf")
model = hf_decoder_model.HFDecoderModel(model_args)
inferencer_args = InferencerArguments()
data_args = DatasetArguments()
self.toolinf = ToolInferencer(model_args, data_args, inferencer_args)

def test_code_exec_1(self,code=CODE_1, expected_output=RES_1):

toolinf_res = self.toolinf.code_exec(code)
self.assertEqual(toolinf_res, expected_output)

Expand Down

0 comments on commit 9482786

Please sign in to comment.