Skip to content

Commit 1db07a5

Browse files
samuel100Copilot
andcommitted
Migrate Python samples to new SDK (foundry_local_sdk)
- audio-transcription: foundry_local -> foundry_local_sdk, use model.get_audio_client() - langchain-integration: foundry_local -> foundry_local_sdk, use start_web_service() - web-server: foundry_local -> foundry_local_sdk, use start_web_service() - Remove hello-foundry-local (legacy), add native-chat-completions (new SDK) - Remove functioncalling (Jupyter), add tool-calling (new SDK, how-to style) - Use qwen2.5-0.5b model alias across all samples - Use common app_name 'foundry_local_samples' for shared model cache - Update all 4 tutorials to use qwen2.5-0.5b and foundry_local_samples Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ad0184c commit 1db07a5

File tree

15 files changed

+314
-505
lines changed

15 files changed

+314
-505
lines changed
Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
11
# <complete_code>
22
# <imports>
3-
from foundry_local import FoundryLocalManager
3+
import sys
4+
from foundry_local_sdk import Configuration, FoundryLocalManager
45
# </imports>
56

7+
68
# <init>
7-
# Initialize with a whisper model alias
8-
alias = "whisper"
9-
manager = FoundryLocalManager(alias)
9+
# Initialize the Foundry Local SDK
10+
config = Configuration(app_name="foundry_local_samples")
11+
FoundryLocalManager.initialize(config)
12+
manager = FoundryLocalManager.instance
13+
14+
# Load the whisper model for speech-to-text
15+
model = manager.catalog.get_model("whisper")
16+
model.download(
17+
lambda progress: print(
18+
f"\rDownloading model: {progress:.2f}%",
19+
end="",
20+
flush=True,
21+
)
22+
)
23+
print()
24+
model.load()
25+
print("Model loaded.")
1026
# </init>
1127

1228
# <transcription>
13-
# Get the audio client
14-
audio_client = manager.get_audio_client(alias)
15-
16-
# Transcribe an audio file
17-
import sys
29+
# Get the audio client and transcribe
30+
audio_client = model.get_audio_client()
1831
audio_file = sys.argv[1] if len(sys.argv) > 1 else "audio.wav"
1932
result = audio_client.transcribe(audio_file)
2033
print("Transcription:")
2134
print(result.text)
2235
# </transcription>
36+
37+
# Clean up
38+
model.unload()
2339
# </complete_code>

samples/python/functioncalling/README.md

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)