Skip to content

feat: Added support for Foundry-Local#649

Open
rajiknows wants to merge 8 commits into
0xPlaygrounds:mainfrom
rajiknows:foundry
Open

feat: Added support for Foundry-Local#649
rajiknows wants to merge 8 commits into
0xPlaygrounds:mainfrom
rajiknows:foundry

Conversation

@rajiknows

Copy link
Copy Markdown
Contributor

closes #630

@joshua-mo-143 joshua-mo-143 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mainly spelling mistakes and minor nits. The only major thing that needs fixing is that Foundry Local does support tool use (and tool results), otherwise they wouldn't allow you to add tools in the first place.

EDIT: Pasting the link here so it doesn't get lost in the review stuff: https://learn.microsoft.com/en-us/azure/ai-foundry/foundry-models/how-to/use-chat-completions?pivots=programming-language-python#use-tools

Comment thread rig-core/src/providers/foundry.rs Outdated
/// # Panics
/// - If the reqwest client cannot be built (if the TLS backend cannot be initialized).
pub fn new() -> Self {
Self::builder().build().expect("Ollama client should build")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ollama -> Foundry Local

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.

yeahh i basically took a lot of code from ollama and forgot to rename lol

Comment thread rig-core/src/providers/foundry.rs Outdated
where
Self: Sized,
{
let api_base = std::env::var("OLLAMA_API_BASE_URL").expect("OLLAMA_API_BASE_URL not set");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ollama -> Foundry Local

Comment thread rig-core/src/providers/foundry.rs Outdated
}
}

// these i took from gemini ( review needed josh)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can find the Azure AI Foundry model catalog here: https://ai.azure.com/catalog/models

I would suggest having a look as there are quite a few of these where the capital letter casing is not quite correct.

Comment thread rig-core/src/providers/foundry.rs Outdated
impl TryFrom<CompletionResponse> for completion::CompletionResponse<CompletionResponse> {
type Error = CompletionError;
fn try_from(resp: CompletionResponse) -> Result<Self, Self::Error> {
let mut assitant_contents = Vec::new();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

assitant -> assistant

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.

ahhh :(

Comment thread rig-core/src/providers/foundry.rs Outdated
// foundry only responds with an array of choices which have
// role and content (role is always "assistant" for responses)
for choice in resp.choices.clone() {
assitant_contents.push(completion::AssistantContent::text(&choice.message.content));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

assitant -> assistant

Comment thread rig-core/src/providers/foundry.rs Outdated
.text()
.await
.map_err(|e| CompletionError::ProviderError(e.to_string()))?;
tracing::debug!(target: "rig", "Foundry chat response: {}", text);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Foundry -> Foundry Local (I know this is a bit pedantic, but as Azure AI Foundry itself is already a known service, if we end up adding support for it then it will be a much more obvious differentiation to make)

Comment thread rig-core/src/providers/foundry.rs Outdated

let data_line = if let Some(data) = line.strip_prefix("data: "){
data
}else{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

very small nit: } else {

Comment thread rig-core/src/providers/foundry.rs Outdated
}

#[derive(Debug, Serialize, Deserialize)]
pub enum Role {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can use #[serde(rename_all = "lowercase")] here rather than manually renaming each one

Comment thread rig-core/src/providers/foundry.rs Outdated
use crate::message::Message as InternalMessage;
match internal_msg {
InternalMessage::User { content, .. } => {
// Foundry doesn't support tool results in messages, so we skip them

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

i was looking at their rest api docs ... shouldve digged deeper

Comment thread rig-core/src/providers/mod.rs Outdated
pub mod azure;
pub mod cohere;
pub mod deepseek;
pub mod foundry;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please rename to foundry_local (removes ambiguity in case we decide to add Azure AI Foundry officially later on)

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.

alrightt

@joshua-mo-143 joshua-mo-143 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just needs an example (as well as pending changes) then should be good for another review

streaming::{self, RawStreamingChoice},
};

const FOUNDRY_API_BASE_URL: &str = "http://localhost:42069";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please use a different port number (yes, I know 42069 is funny)

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.

alright alright :(

@joshua-mo-143 joshua-mo-143 added the blocked Blocked by one or more issues that the maintainers are unable to directly fix label Aug 31, 2025
@joshua-mo-143

joshua-mo-143 commented Aug 31, 2025

Copy link
Copy Markdown
Contributor

Marked blocked because there is no support for Linux which means I can't test it (pending support from another team member).

@0xMochan 0xMochan self-requested a review October 2, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blocked Blocked by one or more issues that the maintainers are unable to directly fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add support for Foundry-Local

2 participants