Skip to content

fix: get os from context tool #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 17 additions & 32 deletions tool.gpt
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
tools: service, port, get-operating-system, open-file, open, start-file, start

!!Important!! - A file can be local or remote.

Do all of the following in order and do not skip a step.
1. Run the service.
2. Get the port for the running service.
3. Get the operating system.
4. For the provided file, do one of the following two options:
- If it is remote or starts with github.com, do not edit it.
- If it is local, trim the directory from the file and remove the '.gpt' suffix.
5. Do one of the following options.
- If the operating system is Windows:
- If a file or URL is provided, use the start file tool.
- If no file or URL is provided, use the start tool.
- If the operating system is not Windows:
- If a file or URL is provided, use the open-file tool.
- If a file or URL is not provided, use the open tool.
context: github.com/gptscript-ai/context/os
tools: service, port, open-file-nix, open-nix, open-file-windows, open-windows
params: file: (optional) A reference to a tool file. Can refer to either a local or remote file.

Never run steps in parallel.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was having a problem with steps 1 and 2 running in parallel. This corrects for that.


Perform the following steps in the order they appear:
1. Run the service
2. Get the port for the running service
3. If no {file} was provided AND the local operating system is windows, use the open-windows tool then skip the remaining steps
4. If no {file} was provided use the open-nix tool then skip the remaining steps
5. If the operating system is windows, use the open-file-windows tool then skip the remaining steps
6. Use the open-file-nix tool
Comment on lines +10 to +13
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's probably a more clever way to select the right tools based on OS via contexts, but ATM this was the most straightforward way I could come up with.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little surprised that the LLM does the right thing and doesn't try to do something for each listed step.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some basic testing to make sure it works for remote and local paths, but I didn't try every combination here (e.g. on windows). I'll check on windows and take a look at the events to see exactly what the LLM does here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked and remote URLs are working properly on windows


---
name: service
Expand All @@ -32,17 +27,7 @@ description: Get the port for the running service

---

name: get-operating-system

#!/usr/bin/env python3

import platform

print(platform.system())

---

name: open-file
name: open-file-nix
arg: port: The port the service is listening on
arg: file: The file to open

Expand All @@ -52,7 +37,7 @@ open http://localhost:${PORT}/run?file=${FILE}

---

name: open
name: open-nix
arg: port: The port the service is listening on

#!/usr/bin/env sh
Expand All @@ -61,7 +46,7 @@ open http://localhost:${PORT}

---

name: start-file
name: open-file-windows
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to make it more obvious that these toosl are just the "windows variants" of the others.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eh, OK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I can switch it back if we're feeling "meh" about it. Lmk

arg: port: The port the service is listening on
arg: file: The file to open

Expand All @@ -71,7 +56,7 @@ start http://localhost:$env:PORT/run?file=$env:FILE

---

name: start
name: open-windows
arg: port: The port the service is listening on

#!/usr/bin/env sh
Expand Down