Skip to content
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

use 127.0.0.1 instead of localhost that is invalid URL by validator. #53

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ User need to choose either of them is used by `ros2ai` as following configuratio
| :----------------------| :-------------------------- | :--------------------- |
| OPENAI_API_KEY | None. | Required for OpenAI |
| OPENAI_MODEL_NAME | 'gpt-4o' | AI model to be used. e.g) llama3.1 (Ollama) |
| OPENAI_ENDPOINT | 'https://api.openai.com/v1' | API endpoint URL. e.g) http://localhost:11434/v1 (Ollama) |
| OPENAI_ENDPOINT | 'https://api.openai.com/v1' | API endpoint URL. e.g) http://127.0.0.1:11434/v1 (Ollama) |
| OPENAI_TEMPERATURE | 0.5 | [OpenAI temperature](https://platform.openai.com/docs/guides/text-generation/how-should-i-set-the-temperature-parameter) |

> [!NOTE]
Expand All @@ -136,7 +136,7 @@ User need to choose either of them is used by `ros2ai` as following configuratio
### Ollama
unset OPENAI_API_KEY
export OPENAI_MODEL_NAME=llama3.1
export OPENAI_ENDPOINT=http://localhost:11434/v1
export OPENAI_ENDPOINT=http://127.0.0.1:11434/v1
```

- `status` to check OpenAI API key is valid.
Expand Down
2 changes: 1 addition & 1 deletion ros2ai/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def curl_get_request(url, headers=None) -> Tuple[bool, Optional[List[str]]]:
return False, None


# curl http://localhost:11434/api/tags
# curl http://127.0.0.1:11434/api/tags
def ollama_get_models(url, headers=None) -> Tuple[bool, Optional[List[str]]]:
# only supports basic curl subprocess command
curl_cmd = ["curl", url]
Expand Down
1 change: 1 addition & 0 deletions ros2ai/api/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def get_endpoint_url() -> str:
url = os.environ.get(constants.ROS_OPENAI_ENDPOINT_ENV_VAR)
url_valid = False
try:
# this returns ValidationError with `http://localhost:11434/v1`
url_valid = validators.url(url)
except Exception as e:
print(f"Error validating URL: {e}")
Expand Down
2 changes: 1 addition & 1 deletion ros2ai/api/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ROS_OPENAI_MODEL_NAME_ENV_VAR = 'OPENAI_MODEL_NAME'

ROS_OPENAI_DEFAULT_ENDPOINT = 'https://api.openai.com/v1'
ROS_OLLAMA_DEFAULT_ENDPOINT = 'http://localhost:11434/v1'
ROS_OLLAMA_DEFAULT_ENDPOINT = 'http://127.0.0.1:11434/v1'

ROS_OPENAI_ENDPOINT_ENV_VAR = 'OPENAI_ENDPOINT'

Expand Down
7 changes: 4 additions & 3 deletions scripts/verification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# User Setting #
################

# ROS setting should be done before calling this scripts, fallking back to defaults.
# ROS setting should be done before calling this scripts, falling back to defaults.
ROS_VERSION="${ROS_VERSION:-2}"
ROS_PYTHON_VERSION="${ROS_PYTHON_VERSION:-3}"
ROS_AUTOMATIC_DISCOVERY_RANGE="${ROS_AUTOMATIC_DISCOVERY_RANGE:-SUBNET}"
Expand All @@ -29,8 +29,9 @@ command_list=(
"ros2 ai query -h"
"ros2 ai query \"say hello\""
"ros2 ai query \"say hello\" -nv"
"ros2 ai query \"say hello\" -m gpt-4 -u https://api.openai.com/v1 -t 100"
#"ros2 ai query \"say hello\" -m llama3.1 -u http://localhost:11434/v1 -t 100"
# TODO(@fujitatomoya): use environmental variable instead.
#"ros2 ai query \"say hello\" -m gpt-4 -u https://api.openai.com/v1 -t 100"
"ros2 ai query \"say hello\" -m llama3.1 -u http://127.0.0.1:11434/v1 -t 100"
"ros2 ai exec \"give me all topics\""
"ros2 ai exec \"give me all topics\" --dry-run"
"ros2 ai exec \"give me all topics\" -d"
Expand Down
Loading