Skip to content

Commit

Permalink
Merge pull request #147 from dbpunk-labs/142-bug-fail-to-start-og-com…
Browse files Browse the repository at this point in the history
…mand-in-gitpod

142 bug fail to start og command in gitpod
  • Loading branch information
imotai authored Oct 9, 2023
2 parents db26238 + f743e1a commit 03f964c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cli_ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
matrix:
#os: [ubuntu-latest, windows-latest, macos-latest]
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11"]
python-version: ["3.11"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
Expand Down
46 changes: 17 additions & 29 deletions agent/src/og_agent/openai_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,6 @@
"required": ["explanation", "code"],
},
},
{
"name": "python",
"description": "You must not call this function",
"parameters": {
"type": "object",
"properties": {
"explanation": {
"type": "string",
"description": "the explanation about the python code",
},
"code": {
"type": "string",
"description": "the python code to be executed",
},
"saved_filenames": {
"type": "array",
"items": {"type": "string"},
"description": "A list of filenames that were created by the code",
},
},
"required": ["explanation", "code"],
},
},
]


Expand Down Expand Up @@ -108,6 +85,9 @@ def _merge_delta_for_content(self, message, delta):
message["content"] = content + delta["content"]

def _get_function_call_argument_new_typing(self, message):
if message['function_call']['name'] == 'python':
return TypingState.CODE, "", message["function_call"].get("arguments", "")

arguments = message["function_call"].get("arguments", "")
state = TypingState.START
explanation_str = ""
Expand Down Expand Up @@ -240,11 +220,18 @@ async def handle_function(self, message, queue, context, task_context):
logging.debug("the client has cancelled the request")
return
function_name = message["function_call"]["name"]
arguments = json.loads(message["function_call"]["arguments"])
logger.debug(f"call function {function_name} with args {arguments}")
code = arguments["code"]
explanation = arguments["explanation"]
saved_filenames = arguments.get("saved_filenames", [])
code = ""
explanation = ""
saved_filenames = []
if function_name == 'python':
code = message["function_call"]["arguments"]
logger.debug(f"call function {function_name} with args {code}")
else:
arguments = json.loads(message["function_call"]["arguments"])
logger.debug(f"call function {function_name} with args {arguments}")
code = arguments["code"]
explanation = arguments["explanation"]
saved_filenames = arguments.get("saved_filenames", [])
tool_input = json.dumps({
"code": code,
"explanation": explanation,
Expand Down Expand Up @@ -299,7 +286,8 @@ async def arun(self, task, queue, context, max_iteration=5):
)
logger.debug(f"the response {chat_message}")
if "function_call" in chat_message:
chat_message["content"] = None
if 'content' not in chat_message:
chat_message["content"] = None
messages.append(chat_message)
function_name = chat_message["function_call"]["name"]
if function_name not in ["execute_python_code", "python"]:
Expand Down
5 changes: 3 additions & 2 deletions agent/src/og_agent/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
Secondly, Being an expert in programming, you must follow the rules
* To complete the goal, You must write a plan and execute it step by step, the followings are examples
* The data visualization plan involves previewing, cleaning, and processing the data to generate the chart.
* For each step, provide an **explanation** and the code block.
* Execute the python code using function `execute_python_code`
* Every step must include the explanation and the code block
* Execute the python code using function `execute_python_code`
* If the code creates any files, add them to the saved_filenames of function `execute_python_code`.
* If the code has any display data, save it as a file and add it to the saved_filenames of function `execute_python_code`
* You must try to correct your code when you get errors from the output
Expand Down Expand Up @@ -66,3 +66,4 @@
* language (string): The programming language used to execute the action.
* is_final_answer (boolean): Whether this is the final answer to the question. If it is, the value of this field should be true. Otherwise, the value should be false.
"""

14 changes: 7 additions & 7 deletions up/tests/up_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_start_azure_openai_smoketest():
kernel_key = random_str(32)
with Live(Group(*segments), console=console) as live:
generate_kernel_env(live, segments, install_dir, kernel_key)
code = load_docker_image("v0.4.27", "dbpunk/octogen", live, segments)
code = load_docker_image("v0.4.41", "dbpunk/octogen", live, segments)
assert code == 0, "bad result code of loading docker image"
result = start_octogen_for_azure_openai(
live,
Expand All @@ -175,7 +175,7 @@ def test_start_azure_openai_smoketest():
admin_key,
kernel_key,
"dbpunk/octogen",
"v0.4.27",
"v0.4.41",
"azure_open_api_key",
"test_deployment",
"https://azure_base",
Expand All @@ -193,7 +193,7 @@ def test_start_openai_smoketest():
kernel_key = random_str(32)
with Live(Group(*segments), console=console) as live:
generate_kernel_env(live, segments, install_dir, kernel_key)
code = load_docker_image("v0.4.27", "dbpunk/octogen", live, segments)
code = load_docker_image("v0.4.41", "dbpunk/octogen", live, segments)
assert code == 0, "bad result code of loading docker image"
result = start_octogen_for_openai(
live,
Expand All @@ -203,7 +203,7 @@ def test_start_openai_smoketest():
admin_key,
kernel_key,
"dbpunk/octogen",
"v0.4.27",
"v0.4.41",
"openai_api_key",
"gpt-3.5-turbo",
)
Expand All @@ -220,7 +220,7 @@ def test_start_codellama_smoketest():
kernel_key = random_str(32)
with Live(Group(*segments), console=console) as live:
generate_kernel_env(live, segments, install_dir, kernel_key)
code = load_docker_image("v0.4.27", "dbpunk/octogen", live, segments)
code = load_docker_image("v0.4.41", "dbpunk/octogen", live, segments)
assert code == 0, "bad result code of loading docker image"
result = start_octogen_for_codellama(
live,
Expand All @@ -232,7 +232,7 @@ def test_start_codellama_smoketest():
admin_key,
kernel_key,
"dbpunk/octogen",
"v0.4.27",
"v0.4.41",
)
assert result

Expand All @@ -251,5 +251,5 @@ def test_load_valid_docker_image():
console = Console()
segments = []
with Live(Group(*segments), console=console) as live:
code = load_docker_image("v0.4.26", "dbpunk/octogen", live, segments)
code = load_docker_image("v0.4.41", "dbpunk/octogen", live, segments)
assert code == 0, "loading image should be ok"

0 comments on commit 03f964c

Please sign in to comment.