-
Notifications
You must be signed in to change notification settings - Fork 147
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
feat: add local model support and examples #147
Conversation
Hey @vacekj thank you for your contribution and interest in Rig, this is seriously awesome to see! We'll review this ASAP! In the meantime, I've enabled CI on this PR so if you could address the couple linting/styling issues that might pop up that would be awesome. Cheers! |
I belive my last commit should address the singular lint issue. Please feel free to re-run the CI to see if everything's alright. |
FYI @vacekj the currently failing tests are known to fail when a PR is made from an outside contributor, so no need to worry about those |
@vacekj @cvauclair instead of local.rs in providers we can have ollama.rs, lm_studio.rs, as there are other servers too which run locally like llama.cpp, LLMedge, ? |
@akashicMarga All of the projects you mentioned use the standard OpenAI API. I don't think it's necessary to duplicate the client., as it would be the same interface for LM Studio, ollama and LLMEdge. |
thought so, I was just thinking let's say in future if any local server that follows some other format where it will be integrated. so local_opena_ai_compatible.rs, or something on this line? |
@akashicMarga @vacekj I think it's fine to have a |
@vacekj are there differences between your |
Yea, the use rig::{completion::Prompt, providers};
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
// Create an Ollama client using the OpenAI compatibility layer
let client = providers::openai::Client::from_url("ollama", "http://localhost:11434");
// Create agent with a single context prompt
let comedian_agent = client
.agent("llama3.2:latest")
.preamble("You are a comedian here to entertain the user using humour and jokes.")
.build();
// Prompt the agent and print the response
let response = comedian_agent.prompt("Entertain me!").await?;
println!("{}", response);
Ok(())
} There is the normal Ollama endpoint that would be worth to create an |
Great, then I will implement the API ollama lists here: https://github.com/ollama/ollama/blob/main/docs/api.md#generate-a-chat-completion That could unlock some cool new capabilities, like an agent pulling a new model and spawning it on demand. Agents spawning other agents, like recruiting for an army hehe. |
@vacekj I'll close the PR for now to reduce clutter and because we're talking about a new whole new client implementation here. We can re-open this one later or create a new one once the new integration will be ready for review. As always, thanks for contributing :) |
this PR adds a
client
impl for calling local models, such as ollama and lm studio. it also duplicates some examples, such as simple chat, embeddings and tools calls. it also adds a collab example with local models, that demonstrates models working together to find a good prompt for themselves.I have verified all of the examples work for me, on an M1 Max w/ ollama latest.