Skip to content

Conversation

@rajiknows
Copy link
Contributor

closes #630

Copy link
Contributor

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

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

/// # 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
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
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

where
Self: Sized,
{
let api_base = std::env::var("OLLAMA_API_BASE_URL").expect("OLLAMA_API_BASE_URL not set");
Copy link
Contributor

Choose a reason for hiding this comment

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

Ollama -> Foundry Local

}
}

// these i took from gemini ( review needed josh)
Copy link
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.

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
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
Contributor Author

Choose a reason for hiding this comment

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

ahhh :(

// 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
Contributor

Choose a reason for hiding this comment

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

assitant -> assistant

.text()
.await
.map_err(|e| CompletionError::ProviderError(e.to_string()))?;
tracing::debug!(target: "rig", "Foundry chat response: {}", text);
Copy link
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)


let data_line = if let Some(data) = line.strip_prefix("data: "){
data
}else{
Copy link
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 {

}

#[derive(Debug, Serialize, Deserialize)]
pub enum Role {
Copy link
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

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
Contributor

Choose a reason for hiding this comment

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

Copy link
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

pub mod azure;
pub mod cohere;
pub mod deepseek;
pub mod foundry;
Copy link
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
Contributor Author

Choose a reason for hiding this comment

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

alrightt

Copy link
Contributor

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

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
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
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
Copy link
Contributor

joshua-mo-143 commented Aug 31, 2025

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