Skip to content

Add interactive chat with multi-provider LLM support (Ollama, llama.cpp, Ramalama, vLLM), powered by rig#87

Draft
mashraf8 wants to merge 1 commit intopgmoneta:mainfrom
mashraf8:pgmoneta-llm-chat
Draft

Add interactive chat with multi-provider LLM support (Ollama, llama.cpp, Ramalama, vLLM), powered by rig#87
mashraf8 wants to merge 1 commit intopgmoneta:mainfrom
mashraf8:pgmoneta-llm-chat

Conversation

@mashraf8
Copy link
Copy Markdown
Contributor

@mashraf8 mashraf8 commented Mar 30, 2026

@jesperpedersen @Jubilee101 Recently, I studied rig and how to integrate it. It is interesting, as it can indeed significantly simplify our work by removing the need to build a custom MCP client, now it already supports more than 20 providers. It also provides a hooks system that allows us to track events such as completion call, tool call, and more.

However, I have encountered some challenges, which will be mentioned as comments in the code.

Currently, implemented a CLI interactive chat that provides a smooth user experience and a clean user interface, with hooks helping achieve that, while also allowing users to change configuration directly within the chat.
it now supports providers such as Ollama, llama.cpp, and Ramalama, and we can easily add any provider supported by rig, for unsupported providers, rig also offers a solution.

The demo

asciicast

Work is still ongoing on the documentation and improving the chat interface if needed.
Closes #80

Comment thread src/chat_client/mod.rs Outdated
AnyAgent::Ollama(builder.build())
}

"ramalama" | "llama.cpp" => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As you can see, they should be separated. However, the issue is that rig does not currently support Ramalama.

Rig provides an official solution for unsupported providers by exposing a trait that allows us to create a wrapper for new providers, making them compatible with rig.
See: link

What I found is that Ramalama (link) uses an OpenAI-compatible API, similar to llama.cpp (link).
Most local providers follow approximately the same approach.

Therefore, I used the llama client with Ramalama without needing to build a custom wrapper.

Comment thread src/chat_client/mcp_bridge.rs Outdated
Copy link
Copy Markdown
Contributor Author

@mashraf8 mashraf8 Mar 30, 2026

Choose a reason for hiding this comment

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

The mcp_bridge.rs file was created specifically to solve an important issue: rig still uses an older version of rmcp (v0.16) for MCP communication, which caused a version conflict with pgmoneta_mcp.

To solve this issue, we will have to use the same version of rmcp as rig and rely on their version.

What was implemented is an Adapter that enables direct communication between the MCP server and rig without relying on rig’s rmcp.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, but we don't want this in our project. It need to be fixed upstream such that we don't have to do hacks like this

@mashraf8 mashraf8 force-pushed the pgmoneta-llm-chat branch from b75b2cb to e2bcc1b Compare April 2, 2026 06:06
@mashraf8 mashraf8 changed the title Add interactive chat with multi-provider LLM support (Ollama, llama.cpp, Ramalama), powered by rig Add interactive chat with multi-provider LLM support (Ollama, llama.cpp, Ramalama, vLLM), powered by rig Apr 2, 2026
@mashraf8
Copy link
Copy Markdown
Contributor Author

mashraf8 commented Apr 2, 2026

@jesperpedersen, should I remove the src/llm folder and src/agent.rs file since we will rely on rig? In openai.rs, I used the OpenAI-compatible API provided by rig. We only need to keep the local LLM documentation.
I have also added a new local LLM: vLLM.

@jesperpedersen
Copy link
Copy Markdown
Member

@mashraf8 We have vLLM already. Yes, we need to refactor and remove the code provided by rig. Also, it is pgmoneta-mcp-client - not chat-client

@jesperpedersen
Copy link
Copy Markdown
Member

@mashraf8 Also, we need a rig.rs release that use rmcp 1.3+ so I'm converting this to draft

@jesperpedersen jesperpedersen marked this pull request as draft April 3, 2026 14:29
@jesperpedersen jesperpedersen assigned mashraf8 and unassigned mashraf8 Apr 3, 2026
@jesperpedersen jesperpedersen added feature A new feature labels Apr 3, 2026
@jesperpedersen
Copy link
Copy Markdown
Member

0xPlaygrounds/rig#1595

@mashraf8
Copy link
Copy Markdown
Contributor Author

mashraf8 commented Apr 3, 2026

@jesperpedersen I have already resolved the conflict issue by implementing a bridge in mcp_bridge.rs.

I think it would be better to keep this approach for now so we can keep up with the rapid updates and changes that occur continuously.

At the same time, it would be better to focus on agents features such as RAG, multi-agent support, improving the interface, and other enhancements that directly impact the end user.

@mashraf8
Copy link
Copy Markdown
Contributor Author

mashraf8 commented Apr 3, 2026

@jesperpedersen Okay, I will proceed with adding the hook system and addressing any missing parts, and then open a new PR.

@mashraf8 mashraf8 force-pushed the pgmoneta-llm-chat branch from e2bcc1b to b473eab Compare April 9, 2026 19:46
@mashraf8
Copy link
Copy Markdown
Contributor Author

mashraf8 commented Apr 9, 2026

It will remain in draft status as is, as the update is not yet officially available on crates.io:
https://crates.io/crates/rig-core/versions

I have temporarily used the latest version of rig-core from the rig repository, which includes the expected changes from the upcoming release, to continue working on the PR.

@jesperpedersen
Copy link
Copy Markdown
Member

@mashraf8 Yeah, we will wait a bit. You can try the client in main and read the documentation

@mashraf8
Copy link
Copy Markdown
Contributor Author

@jesperpedersen a new version has been released with updates to rmcp. I will also apply the necessary changes and make some additional adjustments

@jesperpedersen
Copy link
Copy Markdown
Member

@mashraf8 I updated to rmcp 1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate rig

2 participants