Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/cs/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ItemGroup>
<PackageVersion Include="Microsoft.AI.Foundry.Local" Version="*-*" />
<PackageVersion Include="Microsoft.AI.Foundry.Local.WinML" Version="*-*" />
<PackageVersion Include="Betalgo.Ranul.OpenAI" Version="9.2.0" />
<PackageVersion Include="Betalgo.Ranul.OpenAI" Version="9.1.0" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.15" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.15" />
<PackageVersion Include="NAudio" Version="2.2.1" />
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion samples/js/chat-and-audio-foundry-local/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { FoundryLocalManager } from "foundry-local-sdk";
import path from "path";

// Model aliases
const CHAT_MODEL = "phi-3.5-mini";
const CHAT_MODEL = "qwen2.5-0.5b";
const WHISPER_MODEL = "whisper-tiny";

async function main() {
Expand Down
10 changes: 9 additions & 1 deletion samples/js/tutorial-chat-assistant/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ const rl = readline.createInterface({
output: process.stdout
});

const askQuestion = (prompt) => new Promise((resolve) => rl.question(prompt, resolve));
const askQuestion = (prompt) => new Promise((resolve) => {
if (rl.closed) return resolve('quit');
const onClose = () => resolve('quit');
rl.once('close', onClose);
rl.question(prompt, (answer) => {
rl.off('close', onClose);
resolve(answer);
});
});
Comment thread
samuel100 marked this conversation as resolved.

console.log('\nChat assistant ready! Type \'quit\' to exit.\n');

Expand Down
14 changes: 11 additions & 3 deletions samples/js/tutorial-tool-calling/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async function processToolCalls(messages, response, chatClient) {
}

response = await chatClient.completeChat(
messages, { tools }
messages, tools
);
choice = response.choices[0]?.message;
}
Expand Down Expand Up @@ -162,7 +162,15 @@ const rl = readline.createInterface({
});

const askQuestion = (prompt) =>
new Promise((resolve) => rl.question(prompt, resolve));
new Promise((resolve) => {
if (rl.closed) return resolve('quit');
const onClose = () => resolve('quit');
rl.once('close', onClose);
rl.question(prompt, (answer) => {
Comment thread
samuel100 marked this conversation as resolved.
Outdated
rl.off('close', onClose);
resolve(answer);
});
});

console.log(
'\nTool-calling assistant ready! Type \'quit\' to exit.\n'
Expand All @@ -180,7 +188,7 @@ while (true) {
messages.push({ role: 'user', content: userInput });

const response = await chatClient.completeChat(
messages, { tools }
messages, tools
);
const answer = await processToolCalls(
messages, response, chatClient
Expand Down
2 changes: 2 additions & 0 deletions samples/python/native-chat-completions/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def ep_progress(ep_name: str, percent: float):
# Stream the response token by token
print("Assistant: ", end="", flush=True)
for chunk in client.complete_streaming_chat(messages):
if not chunk.choices:
continue
content = chunk.choices[0].delta.content
if content:
print(content, end="", flush=True)
Expand Down
2 changes: 2 additions & 0 deletions samples/python/tutorial-chat-assistant/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def ep_progress(ep_name: str, percent: float):
print("Assistant: ", end="", flush=True)
full_response = ""
for chunk in client.complete_streaming_chat(messages):
if not chunk.choices:
continue
content = chunk.choices[0].delta.content
if content:
print(content, end="", flush=True)
Expand Down
2 changes: 1 addition & 1 deletion samples/python/web-server/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _ep_progress(ep_name: str, percent: float):
)

for chunk in response:
if chunk.choices[0].delta.content is not None:
if chunk.choices and chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="", flush=True)
print()
# </chat_completion>
Expand Down
2 changes: 1 addition & 1 deletion samples/rust/tutorial-chat-assistant/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio_stream::StreamExt;
async fn main() -> anyhow::Result<()> {
// <init>
// Initialize the Foundry Local SDK
let manager = FoundryLocalManager::create(FoundryLocalConfig::new("chat-assistant"))?;
let manager = FoundryLocalManager::create(FoundryLocalConfig::new("foundry_local_samples"))?;

// Download and register all execution providers.
manager
Expand Down
2 changes: 1 addition & 1 deletion samples/rust/tutorial-document-summarizer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async fn main() -> anyhow::Result<()> {
// <init>
// Initialize the Foundry Local SDK
let manager = FoundryLocalManager::create(
FoundryLocalConfig::new("doc-summarizer"),
FoundryLocalConfig::new("foundry_local_samples"),
)?;

// Download and register all execution providers.
Expand Down
2 changes: 1 addition & 1 deletion samples/rust/tutorial-tool-calling/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ async fn main() -> anyhow::Result<()> {
// <init>
// Initialize the Foundry Local SDK
let manager = FoundryLocalManager::create(
FoundryLocalConfig::new("tool-calling-app"),
FoundryLocalConfig::new("foundry_local_samples"),
)?;

// Download and register all execution providers.
Expand Down
2 changes: 1 addition & 1 deletion samples/rust/tutorial-voice-to-text/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async fn main() -> anyhow::Result<()> {
// <init>
// Initialize the Foundry Local SDK
let manager = FoundryLocalManager::create(
FoundryLocalConfig::new("note-taker"),
FoundryLocalConfig::new("foundry_local_samples"),
)?;
// </init>

Expand Down
Loading