Skip to content

Commit

Permalink
fix: claude artifact path (#252)
Browse files Browse the repository at this point in the history
* revert workspace change

* show artifacts
  • Loading branch information
yzld2002 authored Oct 1, 2024
1 parent b00715d commit 511792b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion vision_agent/agent/vision_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def chat_with_code(
remote_artifacts_path = code_interpreter.upload_file(
self.local_artifacts_path
)
artifacts_loaded = artifacts.show()
artifacts_loaded = artifacts.show(code_interpreter.remote_path)
int_chat.append({"role": "observation", "content": artifacts_loaded})
orig_chat.append({"role": "observation", "content": artifacts_loaded})
self.streaming_message({"role": "observation", "content": artifacts_loaded})
Expand Down
11 changes: 7 additions & 4 deletions vision_agent/tools/meta_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,16 @@ def load(self, file_path: Union[str, Path]) -> None:
with open(self.remote_save_path.parent / k, mode) as f:
f.write(v)

def show(self) -> str:
def show(self, uploaded_file_path: Optional[Union[str, Path]] = None) -> str:
"""Shows the artifacts that have been loaded and their remote save paths."""
loaded_path = (
Path(uploaded_file_path)
if uploaded_file_path is not None
else self.remote_save_path
)
output_str = "[Artifacts loaded]\n"
for k in self.artifacts.keys():
output_str += (
f"Artifact {k} loaded to {str(self.remote_save_path.parent / k)}\n"
)
output_str += f"Artifact {k} loaded to {str(loaded_path / k)}\n"
output_str += "[End of artifacts]\n"
print(output_str)
return output_str
Expand Down
6 changes: 4 additions & 2 deletions vision_agent/utils/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ def __init__(
_LOGGER.info(
f"E2BCodeInterpreter (sandbox id: {self.interpreter.sandbox_id}) initialized:\n{sys_versions}"
)
self.remote_path = Path(remote_path if remote_path is not None else WORKSPACE)
self.remote_path = Path(
remote_path if remote_path is not None else "/home/user"
)

def close(self, *args: Any, **kwargs: Any) -> None:
try:
Expand Down Expand Up @@ -713,7 +715,7 @@ def _get_e2b_env() -> Union[Dict[str, str], None]:
openai_api_key = os.getenv("OPENAI_API_KEY", "")
anthropic_api_key = os.getenv("ANTHROPIC_API_KEY", "")
if openai_api_key or anthropic_api_key:
envs = {}
envs = {"WORKSPACE": os.getenv("WORKSPACE", "/home/user")}
if openai_api_key:
envs["OPENAI_API_KEY"] = openai_api_key
if anthropic_api_key:
Expand Down

0 comments on commit 511792b

Please sign in to comment.