-
Notifications
You must be signed in to change notification settings - Fork 234
Add ramalama chat command #1531
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
Conversation
For now we will just add the chat command, next PR will remove the external chat command and just use this internal one. Signed-off-by: Daniel J Walsh <[email protected]>
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
Reviewer's GuideThis PR adds an internal “chat” subcommand by wiring up a new parser and handler in the CLI and brings documentation in sync by creating a dedicated man page and adjusting existing docs to reference the new command and unify option descriptions. Sequence Diagram for 'ramalama chat' command executionsequenceDiagram
actor User
participant CLI as "ramalama CLI"
participant Parser as "chat_parser()"
participant Handler as "chat_cli(args)"
participant Shell as "RamaLamaShell"
participant OpenAI_API as "OpenAI REST API (via --url)"
User->>CLI: Executes `ramalama chat [ARGS]`
CLI->>Parser: Is called during subcommand configuration
Parser-->>CLI: Registers 'chat' command with chat_cli as handler
CLI->>Handler: Invokes chat_cli(args) with parsed arguments
Handler->>Shell: new RamaLamaShell(args)
Handler->>Shell: shell.handle_args()
alt ARGS provided (one-off mode)
Shell-->>Handler: true (request sent, output shown)
Handler-->>CLI: return
else No ARGS (interactive mode)
Shell-->>Handler: false
Handler->>Shell: shell.loop()
loop Interactive Chat
User->>Shell: Enters prompt
Shell->>OpenAI_API: Sends request with prompt
OpenAI_API-->>Shell: Returns response
Shell->>User: Displays response
end
Handler->>Shell: shell.kills() (cleanup)
Handler-->>CLI: return
end
Sequence Diagram for 'ramalama chat' command executionsequenceDiagram
actor User
participant CLI as "ramalama CLI"
participant Parser as "chat_parser()"
participant Handler as "chat_cli(args)"
participant Shell as "RamaLamaShell"
participant OpenAI_API as "OpenAI REST API (via --url)"
User->>CLI: Executes `ramalama chat [ARGS]`
CLI->>Parser: Is called during subcommand configuration
Parser-->>CLI: Registers 'chat' command with chat_cli as handler
CLI->>Handler: Invokes chat_cli(args) with parsed arguments
Handler->>Shell: new RamaLamaShell(args)
Handler->>Shell: shell.handle_args()
alt ARGS provided (one-off mode)
Shell-->>Handler: true (request sent, output shown)
Handler-->>CLI: return
else No ARGS (interactive mode)
Shell-->>Handler: false
Handler->>Shell: shell.loop()
loop Interactive Chat
User->>Shell: Enters prompt
Shell->>OpenAI_API: Sends request with prompt
OpenAI_API-->>Shell: Returns response
Shell->>User: Displays response
end
Handler->>Shell: shell.kills() (cleanup)
Handler-->>CLI: return
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @rhatdan - I've reviewed your changes - here's some feedback:
- The DESCRIPTION in docs/ramalama-chat.1.md still references model removal; please update it to accurately describe the chat functionality.
- Your examples treat the REST API URL as a positional argument, but --url is defined as an option; either make URL positional in the parser or update the docs to match.
- Consider having chat_cli return an explicit exit code (e.g. from shell.handle_args() or shell.kills()) so scripts can detect failures reliably.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The DESCRIPTION in docs/ramalama-chat.1.md still references model removal; please update it to accurately describe the chat functionality.
- Your examples treat the REST API URL as a positional argument, but --url is defined as an option; either make URL positional in the parser or update the docs to match.
- Consider having chat_cli return an explicit exit code (e.g. from shell.handle_args() or shell.kills()) so scripts can detect failures reliably.
## Individual Comments
### Comment 1
<location> `README.md:1044` </location>
<code_context>
| ------------------------------------------------------ | ---------------------------------------------------------- |
| [ramalama(1)](https://github.com/containers/ramalama/blob/main/docs/ramalama.1.md) | primary RamaLama man page |
| [ramalama-bench(1)](https://github.com/containers/ramalama/blob/main/docs/ramalama-bench.1.md)| benchmark specified AI Model |
+| [ramalama-chat(1)](https://github.com/containers/ramalama/blob/main/docs/ramalama-chat.1.md)| chat with specified OpenAI RESTAPI |
| [ramalama-containers(1)](https://github.com/containers/ramalama/blob/main/docs/ramalama-containers.1.md)| list all RamaLama containers |
| [ramalama-convert(1)](https://github.com/containers/ramalama/blob/main/docs/ramalama-convert.1.md) | convert AI Model from local storage to OCI Image |
</code_context>
<issue_to_address>
Consider using "REST API" instead of "RESTAPI".
This aligns with standard terminology and improves clarity.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
| [ramalama-chat(1)](https://github.com/containers/ramalama/blob/main/docs/ramalama-chat.1.md)| chat with specified OpenAI RESTAPI |
=======
| [ramalama-chat(1)](https://github.com/containers/ramalama/blob/main/docs/ramalama-chat.1.md)| chat with specified OpenAI REST API |
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `docs/ramalama-chat.1.md:4` </location>
<code_context>
+% ramalama-chat 1
+
+## NAME
+ramalama\-chat - OpenAI chat with the specified RESTAPI URL
+
+## SYNOPSIS
</code_context>
<issue_to_address>
Consider using "REST API" instead of "RESTAPI" in the NAME section.
This aligns with standard terminology.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
ramalama\-chat - OpenAI chat with the specified RESTAPI URL
=======
ramalama\-chat - OpenAI chat with the specified REST API URL
>>>>>>> REPLACE
</suggested_fix>
### Comment 3
<location> `docs/ramalama-chat.1.md:14` </location>
<code_context>
+ returned without entering the chatbot
+
+## DESCRIPTION
+Specify one or more AI Models to be removed from local storage
+
+## OPTIONS
</code_context>
<issue_to_address>
The DESCRIPTION section appears to be incorrect for `ramalama-chat`.
Update the DESCRIPTION to accurately reflect that `ramalama-chat` is for chatting via the OpenAI REST API.
</issue_to_address>
### Comment 4
<location> `docs/ramalama-chat.1.md:37` </location>
<code_context>
+$ ramalama chat
+🦭 >
+
+$ ramalama chat http://localhost:1234
+🐋 >
+```
+
</code_context>
<issue_to_address>
The example `ramalama chat http://localhost:1234` and its behavior are unclear.
Please clarify what `http://localhost:1234` represents and how it affects the prompt and chatbot behavior. Also, explain the change in prompt icon. Consider using `--url` in examples for clarity, and ensure the example aligns with the documented `ARGS` usage.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
docs/ramalama-chat.1.md
Outdated
returned without entering the chatbot | ||
|
||
## DESCRIPTION | ||
Specify one or more AI Models to be removed from local storage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: The DESCRIPTION section appears to be incorrect for ramalama-chat
.
Update the DESCRIPTION to accurately reflect that ramalama-chat
is for chatting via the OpenAI REST API.
docs/ramalama-chat.1.md
Outdated
$ ramalama chat http://localhost:1234 | ||
🐋 > |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: The example ramalama chat http://localhost:1234
and its behavior are unclear.
Please clarify what http://localhost:1234
represents and how it affects the prompt and chatbot behavior. Also, explain the change in prompt icon. Consider using --url
in examples for clarity, and ensure the example aligns with the documented ARGS
usage.
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
1 similar comment
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> Signed-off-by: Daniel J Walsh <[email protected]>
It's a good idea we changed to --url We probably want the positional arg to be model (maybe optionally) in future when we start supporting model swapping |
Be interesting if we can make --url work with: --url unix://somesocketfile |
Yes I agree. Next step is to remove libexec/ramalama-client-core. I did turn on gemini for the repo as well, will see how well it does. |
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
copilot suggested do something like this, that could be complete junk though, never tested, at least this solution uses urllib.request so one doesn't have to re-implement HTTP (even though the basics of http we need, wouldn't be that hard to re-implement if needs be):
|
We will want to delete "ramalama client" also with the libexec, this is a copy of that with a different name |
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
For now we will just add the chat command, next PR will remove the external chat command and just use this internal one.
Summary by Sourcery
Introduce a new internal "ramalama chat" CLI command to enable OpenAI chat over REST API and update documentation accordingly.
New Features:
Documentation: