Skip to content

Commit 0d03324

Browse files
author
Runhui Wang
committed
Code cleaning
1 parent da7bff1 commit 0d03324

17 files changed

Lines changed: 71 additions & 437 deletions

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
## Overview
44

5-
The `gsr-bench` repository provides a benchmarking and retrieval system with utilities for executing bash commands, interacting with models, and web searching. This repository is organized into several Python scripts that serve various functions, such as data retrieval, bash utilities, and model execution.
5+
The `csr-bench` repository provides a benchmarking and retrieval system with utilities for executing bash commands, interacting with models, and web searching. This repository is organized into several Python scripts that serve various functions, such as data retrieval, bash utilities, and model execution.
66

77
## Repository Structure
88

99
- **`main.py`**: The entry point of the repository where the core functionality is implemented.
1010
- **`docker_setup.sh`**: A shell script to set up the environment and conduct experiments using Docker.
1111
- **`requirements.txt`**: A list of Python dependencies required to run the project.
12-
- **`gsr/`**: The main module directory containing various Python utilities:
12+
- **`csr/`**: The main module directory containing various Python utilities:
1313
- `bash_utils.py`: Functions related to executing and handling bash commands.
1414
- `retriever.py`: Handles data and information retrieval from Github Issues.
1515
- `model.py`: Manages machine learning model-related operations.
@@ -58,19 +58,19 @@ python main.py
5858

5959
### Bash Utilities
6060

61-
The `gsr/bash_utils.py` module provides a set of utilities to execute and interact with bash commands programmatically. To use this, import the necessary functions into your script:
61+
The `csr/bash_utils.py` module provides a set of utilities to execute and interact with bash commands programmatically. To use this, import the necessary functions into your script:
6262

6363
```python
64-
from gsr.bash_utils import your_function_here
64+
from csr.bash_utils import your_function_here
6565
```
6666

6767

6868
### Model Operations
6969

70-
The `gsr/model.py` provides functions for loading, evaluating, or interacting with machine learning models. Example:
70+
The `csr/model.py` provides functions for loading, evaluating, or interacting with machine learning models. Example:
7171

7272
```python
73-
from gsr.model import run_model
73+
from csr.model import run_model
7474

7575
model_results = run_model(model_input)
7676
```
Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ def call_claude3(inputs, start, workload_size, model_id='anthropic.claude-3-haik
1818
region_name='us-west-2', config=config)
1919
results = []
2020
for i in range(start, min(start+workload_size, len(inputs))):
21-
# input_prompt = inputs[i]
2221
input_prompt = inputs[i]['input']
2322
if input_prompt == 'missing':
2423
results.append((i, 'score: 0\n'))
2524
continue
2625

27-
# print(input_prompt)
28-
2926
user_message = {"role": "user", "content": f"{input_prompt}"}
3027
messages = [user_message]
3128
max_tokens = 4096
@@ -39,7 +36,6 @@ def call_claude3(inputs, start, workload_size, model_id='anthropic.claude-3-haik
3936
}
4037
)
4138

42-
#response = brt.invoke_model(body=body, modelId=model_id)
4339
while True:
4440
try:
4541
response = brt.invoke_model(body=body, modelId=model_id)
@@ -50,7 +46,6 @@ def call_claude3(inputs, start, workload_size, model_id='anthropic.claude-3-haik
5046
continue
5147

5248
response_body = json.loads(response.get('body').read())
53-
# results.append((i, response_body['content'][0]['text']))
5449
inputs[i]['command'] = response_body['content'][0]['text']
5550
inputs[i]['idx'] = i
5651
results.append(
@@ -67,13 +62,8 @@ def inference(input):
6762
class LLMAgent:
6863
def __init__(self, name='Agent', model_name='lmsys/vicuna-7b-v1.5'):
6964
self.name = name
70-
# self.tokenizer = AutoTokenizer.from_pretrained(model_name)
71-
# self.model = AutoModelForCausalLM.from_pretrained(model_name)
7265

7366
def query(self, prompt):
74-
# inputs = self.tokenizer(prompt, return_tensors='pt')
75-
# outputs = self.model.generate(**inputs, max_length=150)
76-
# response = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
7767
response = inference(prompt)
7868
return response
7969

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from botocore.exceptions import ClientError
55
from botocore.config import Config
66

7-
from gsr.perplexity import pplx
7+
from csr.perplexity import pplx
88

99

1010
class ToolAgent:
@@ -22,12 +22,6 @@ def __init__(self, model_id, tool_config, region_name='us-west-2', max_attempts=
2222
# self.tools = dict()
2323
logging.basicConfig(level=logging.INFO)
2424

25-
# def get_top_song(self, call_sign):
26-
# """Returns the most popular song for the requested station."""
27-
# if call_sign == 'WZPZ':
28-
# return "Elemental Hotel", "8 Storey Hike"
29-
# else:
30-
# raise StationNotFoundError(f"Station {call_sign} not found.")
3125

3226
def pplx(self, message):
3327
return pplx(message)
@@ -45,18 +39,14 @@ def generate_text(self, input_text):
4539
output_message = response['output']['message']
4640
messages.append(output_message)
4741
stop_reason = response['stopReason']
48-
# print(response)
4942

5043
if stop_reason == 'tool_use':
5144
tool_requests = output_message['content']
52-
# print('## Tool Requests ##', tool_requests)
5345
for tool_request in tool_requests:
5446
if 'toolUse' in tool_request:
5547
tool = tool_request['toolUse']
5648
self.logger.info("Requesting tool %s. Request: %s", tool['name'], tool['toolUseId'])
5749
try:
58-
# song, artist = self.get_top_song(tool['input']['sign'])
59-
# tool_result = {"toolUseId": tool['toolUseId'], "content": [{"json": {"song": song, "artist": artist}}]}
6050
analysis = self.pplx(tool['input']['log_msg'])
6151
tool_result = {"toolUseId": tool['toolUseId'], "content": [{"text": analysis}]}
6252
except Exception as err:
@@ -71,24 +61,9 @@ def generate_text(self, input_text):
7161
)
7262
output_message = response['output']['message']
7363

74-
# for content in output_message['content']:
75-
# print(json.dumps(content, indent=4))
7664
print(output_message['content'][0]['text'])
7765

78-
# def main(self):
79-
# input_text = """Traceback (most recent call last):
80-
# File "<stdin>", line 1, in <module>
81-
# ModuleNotFoundError: No module named 'esm'"""
82-
83-
# print(f"Question: {input_text}")
84-
# try:
85-
# self.generate_text(input_text)
86-
# except ClientError as err:
87-
# message = err.response['Error']['Message']
88-
# self.logger.error("A client error occurred: %s", message)
89-
# print(f"A client error occurred: {message}")
90-
# else:
91-
# print(f"Finished generating text with model {self.model_id}")
66+
9267
def query(self, msg):
9368
try:
9469
self.generate_text(msg)
File renamed without changes.
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pexpect
22
import re
3-
from gsr.model import CoreAgent
3+
from csr.model import CoreAgent
44

55

66
sys_prompt = """Given the execution output, decide if the command is successful or not.
@@ -176,21 +176,21 @@ def close(self):
176176
executor = CommandExecutor(timeout=30)
177177

178178
# Assuming you need to activate an environment
179-
execution_ret = executor.execute_cmd('python -m venv venv', directory='/home/yijia/git-bench/data/gsr_data/Repo/')
179+
execution_ret = executor.execute_cmd('python -m venv venv', directory='./data/csr_data/Repo/')
180180
# print(execution_ret)
181181

182182
# Execute commands in the activated environment
183-
execution_ret = executor.execute_cmd('source venv/bin/activate', directory='/home/yijia/git-bench/data/gsr_data/Repo/')
183+
execution_ret = executor.execute_cmd('source venv/bin/activate', directory='./data/csr_data/Repo/')
184184
# print(execution_ret)
185185

186186
# Optionally execute a command in a specific directory
187-
execution_ret = executor.execute_cmd('pip install -r requirements.txt', directory='/home/yijia/git-bench/data/gsr_data/Repo/')
187+
execution_ret = executor.execute_cmd('pip install -r requirements.txt', directory='./data/csr_data/Repo/')
188188
# print(execution_ret)
189189

190-
execution_ret = executor.execute_cmd('which pip', directory='/home/yijia/git-bench/data/gsr_data/Repo/')
190+
execution_ret = executor.execute_cmd('which pip', directory='./data/csr_data/Repo/')
191191
# print(execution_ret)
192192

193-
execution_ret = executor.execute_cmd('ABCBACBAC', directory='/home/yijia/git-bench/data/gsr_data/Repo/')
193+
execution_ret = executor.execute_cmd('ABCBACBAC', directory='./data/csr_data/Repo/')
194194
# print(execution_ret)
195195

196196

gsr/const.py renamed to csr/const.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050

5151
"Llama_3.1_8b_Instruct": "meta.llama3-1-8b-instruct-v1:0",
5252
"Llama_3.1_70b_Instruct": "meta.llama3-1-70b-instruct-v1:0",
53-
# "Llama_3.1_405B_Instruct": "meta.llama3-1-405b-instruct-v1:0",
53+
"Llama_3.1_405B_Instruct": "meta.llama3-1-405b-instruct-v1:0",
5454

55-
# "Mistral_7B_Instruct": "mistral.mistral-7b-instruct-v0:2",
56-
# "Mixtral_8X7B_Instruct": "mistral.mixtral-8x7b-instruct-v0:1",
55+
"Mistral_7B_Instruct": "mistral.mistral-7b-instruct-v0:2",
56+
"Mixtral_8X7B_Instruct": "mistral.mixtral-8x7b-instruct-v0:1",
5757
"Mistral_Large": "mistral.mistral-large-2402-v1:0",
5858
"Mistral_Large_2": "mistral.mistral-large-2407-v1:0",
59-
# "Mistral_Small": "mistral.mistral-small-2402-v1:0",
59+
"Mistral_Small": "mistral.mistral-small-2402-v1:0",
6060
# gpt-4o gpt-4o-mini gpt-4-turbo
6161
"GPT_4o": "gpt-4o",
6262
"GPT_4o_Mini": "gpt-4o-mini",
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)