Skip to content

Commit

Permalink
update tooleval requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
luyaxi committed Aug 4, 2023
1 parent 9234173 commit 528f368
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ Install Package (python>=3.9)
```bash
pip install -r requirements.txt
```
or for ToolEval only
```bash
pip install -r toolbench/tooleval/requirements.txt
```

Prepare the data and tool environment:
```bash
Expand Down
4 changes: 4 additions & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ cd ToolBench
```bash
pip install -r requirements.txt
```
或者仅安装ToolEval需要的包
```bash
pip install -r toolbench/tooleval/requirements.txt
```

准备数据和工具环境:
```bash
Expand Down
5 changes: 5 additions & 0 deletions toolbench/tooleval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Our automatic evaluator, developed using ChatGPT, demonstrates a significant cor
We also obtain the agreement among different human annotators **83.54%**, and the agreement between humans and our evaluator **80.21%**.

## 🚀Usage
### Install
Install Package (python>=3.9)
```bash
pip install -r requirements.txt
```

### Reproduce our Results

Expand Down
6 changes: 6 additions & 0 deletions toolbench/tooleval/README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@

## 🚀用法

### 安装
安装包,要求(python>=3.9)
```bash
pip install -r requirements.txt
```

### 复现结果

要在测试集(如G1-Inst.)上评估模型,可以执行以下命令:
Expand Down
18 changes: 2 additions & 16 deletions toolbench/tooleval/evaluators/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,8 @@
import math
from typing import List,Union,Dict,Any
from copy import deepcopy
from tenacity import retry, wait_random_exponential, stop_after_attempt
import numpy as np
import os
from .utils import OpenaiPoolRequest

class OpenaiPoolRequest:
def __init__(self, pool_json_file):
self.api_key = os.environ.get('OPENAI_KEY')

@retry(wait=wait_random_exponential(multiplier=1, max=30), stop=stop_after_attempt(10),reraise=True)
def request(self,messages,**kwargs):
import openai
kwargs['api_key'] = self.api_key
return openai.ChatCompletion.create(messages=messages,**kwargs)

def __call__(self,messages,**kwargs):
return self.request(messages,**kwargs)

def process_answer(answer:Dict):
answer['final_answer'] = answer['final_answer'][:1000]
answer['answer_details'] = answer['answer_details'][:3000]
Expand All @@ -31,6 +16,7 @@ def process_tools(tools:List[Dict]):
tool.pop('description',None)
tool.pop('parameters',None)
return tools

class AutomaticEvaluator:
def __init__(self,eval_config,template):
self.eval_config = eval_config
Expand Down
17 changes: 17 additions & 0 deletions toolbench/tooleval/evaluators/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from tenacity import retry, wait_random_exponential, stop_after_attempt
import os


class OpenaiPoolRequest:
def __init__(self, pool_json_file):
self.api_key = os.environ.get('OPENAI_KEY')

@retry(wait=wait_random_exponential(multiplier=1, max=30), stop=stop_after_attempt(10),reraise=True)
def request(self,messages,**kwargs):
import openai
kwargs['api_key'] = self.api_key
return openai.ChatCompletion.create(messages=messages,**kwargs)

def __call__(self,messages,**kwargs):
return self.request(messages,**kwargs)

6 changes: 6 additions & 0 deletions toolbench/tooleval/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tqdm
numpy
pandas
pydantic
tenacity
openai

0 comments on commit 528f368

Please sign in to comment.