Skip to content

HaruniApp/Foundation-Models-Playgrounds

 
 

Repository files navigation

Foundation Models Playgrounds

This repository contains a collection of Swift playgrounds demonstrating how to interact with Apple's Foundation Models. Each playground showcases a small example or tool that highlights a specific generative capability.

Playground Catalog

Chat & Conversation

  1. Basic.swift – A minimal example of chatting with a helpful assistant.
  2. BasicChat.swift – Shows a simple back-and-forth chat session.
  3. ChatInstructions.swift – Sets instructions dynamically for each chat run.
  4. CharacterChat.swift – Role-plays as a medieval knight in conversation.
  5. ChainedPrompts.swift – Uses multiple model calls to build a story from a headline.
  6. ConversationMemory.swift – Shows how to retrieve the transcript of a session.
  7. StreamingTokens.swift – Streams individual tokens from the model.
  8. ShakespeareConversation.swift – Chats in the style of Shakespeare.
  9. ModelAvailability.swift – Checks the availability status of the system model.
  10. DynamicTranslateOrSummary.swift – Switches between translation and summarization tools.
  11. DynamicTriviaOrDarkMode.swift – Mixes a trivia score tool with the dark mode tool.

Summarization & Explanation

  1. ArticleSummary.swift – Summarizes article key points in bullet form.
  2. BookSeriesSummary.swift – Summarizes multiple books in a series.
  3. BugReportSummarizer.swift – Summarizes a set of software bug reports into key themes.
  4. CodeSummary.swift – Summarizes the purpose of a short code sample.
  5. ExplainConcept.swift – Explains a technical concept in simple terms.
  6. NewsSummary.swift – Summarizes news articles concisely.
  7. TranscriptSummarizer.swift – Summarizes a session transcript at the end.
  8. Summarize.swift – Summarizes a block of text in a few sentences.
  9. StructuredBookRecommendation.swift – Suggests a book using a structured format.
  10. ResumeGenerator.swift – Builds a simple resume with highlights.
  11. RecipeMaker.swift – Generates a recipe based on user ingredients.
  12. MedicalCase.swift – Simulates a multi-expert discussion of a patient case.
  13. MathProblemSolver.swift – Solves algebra problems step by step.
  14. TranscriptReview.swift – Demonstrates capturing and reviewing a transcript.
  15. ProductComparison.swift – Summarizes differences between two products in a table.

Code Assistance

  1. CodeCompletion.swift – Generates code completions given a snippet.
  2. CodeRefactor.swift – Refactors code to improve clarity.
  3. CodeReviewAssistant.swift – Offers feedback on Swift code to improve readability.
  4. CodingChallengeGenerator.swift – Supplies short programming puzzles with hints.
  5. DebuggingInstructions.swift – Guides the model to debug code step by step.
  6. TestCaseGenerator.swift – Produces unit test cases from requirements.
  7. JSONGenerator.swift – Produces structured JSON from a model response.
  8. SQLQueryAssistant.swift – Converts natural language into SQL queries.
  9. NestedGenerable.swift – Demonstrates nested generable types.

Language & Translation

  1. AutocompleteAssistant.swift – Produces text completions for short prompts.
  2. FrenchTranslation.swift – Translates phrases into French.
  3. EmojiTranslator.swift – Converts short sentences into strings of emojis.
  4. Translate.swift – Translates text between languages.
  5. LanguageFlashCard.swift – Generates flash cards for learning new words.
  6. LanguageIdiomTutor.swift – Explains idioms with usage examples.
  7. LanguageTriage.swift – Classifies user requests by topic.
  8. SynonymFinder.swift – Lists synonyms for a given word.
  9. VocabularyQuizMaker.swift – Generates multiple-choice vocabulary quizzes.

Tools & Automation

  1. CalendarEventTool.swift – Demonstrates a tool that adds events to a calendar.
  2. ContactLookupTool.swift – Implements a custom tool to search a contact list.
  3. DarkModeTool.swift – Example tool that toggles dark mode on a device.
  4. GameDifficultyTool.swift – Tool that sets a game difficulty value.
  5. HealthStepsTool.swift – Records a daily step count via a tool.
  6. SleepDataTool.swift – Example tool that logs sleep statistics.
  7. StockPriceTool.swift – Retrieves a stock price using a tool.
  8. TriviaScoreTool.swift – Maintains a trivia score via a tool.
  9. DynamicWeatherOrStock.swift – Uses weather or stock quote tools depending on request.
  10. DynamicSleepOrSteps.swift – Combines sleep and step tracking tools.
  11. DynamicContactOrCalendar.swift – Chooses between contact or calendar tools based on intent.
  12. DynamicRecipeOrWorkout.swift – Selects recipe or workout tools for each prompt.
  13. NumericConversion.swift – Converts numbers between formats.

Planning & Productivity

  1. ContentPlanner.swift – Outlines a weekly plan for social media posts based on a topic.
  2. DailyMotivation.swift – Provides a quick motivational quote.
  3. DailyQuote.swift – Creates an inspirational quote using a generable structure.
  4. EmailComposition.swift – Generates a short email from a prompt.
  5. EmailResponseDraft.swift – Drafts a concise reply to an email.
  6. FashionRecommendation.swift – Suggests outfit combinations for an occasion or season.
  7. FinancialStrategy.swift – Offers financial planning suggestions.
  8. MarketingTagline.swift – Suggests a catchy marketing tagline.
  9. GardenPlanner.swift – Plans a home garden with planting suggestions.
  10. RoadTripPackingList.swift – Generates a checklist for packing on a road trip.
  11. VacationPackingHelper.swift – Suggests items to pack for a vacation.
  12. WorkoutPlan.swift – Creates a workout plan for the week.
  13. WorkoutSchedule.swift – Produces a workout schedule with dates.
  14. TravelBudgetEstimator.swift – Estimates travel costs for a trip.
  15. TravelItinerary.swift – Plans a travel itinerary for a destination.
  16. PitchDeckOutline.swift – Provides a structured outline for a startup pitch deck.
  17. VegetarianMenu.swift – Suggests a vegetarian dinner menu.

Creative & Entertainment

  1. Haiku.swift – Writes a short haiku about a topic.
  2. ShortStory.swift – Writes a brief fictional story.
  3. NaturePoem.swift – Creates a short poem about nature.
  4. StreamingPoem.swift – Streams the lines of a poem as they're generated.
  5. MovieNightRecommendation.swift – Recommends a movie with a rating and reason.
  6. MusicAlbum.swift – Describes a music album using a generable structure.
  7. MusicRecommendation.swift – Suggests music tracks or albums based on mood.
  8. NovelOutline.swift – Produces a brief outline for a novel idea.
  9. SuperheroProfile.swift – Generates a profile for a fictional superhero.
  10. RiddleMaker.swift – Creates a riddle for entertainment.
  11. TriviaQuestionWriter.swift – Generates a trivia question with its answer.
  12. SpaceMission.swift – Imagines a conversation about a space mission.
  13. TechPanel.swift – Simulates a panel of experts in a tech discussion.
  14. FilmProduction.swift – Provides a short film production outline.
  15. TrendingTopics.swift – Lists currently trending discussion topics.
  16. NewsHeadlineTool.swift – Tool that generates a headline from news text.
  17. NextLeapDay.swift – Shows the date of the next leap day.
  18. MoonLandingDate.swift – Retrieves the date of the first moon landing.
  19. WeatherReport.swift – Generates a brief weather report.
  20. ConstrainedCharacterProfile.swift – Generates a character profile with guides enforcing structure.
  21. RegexCharacterName.swift – Generates a name that matches a regEx pattern.

Education & Learning

  1. InterviewQuestionCoach.swift – Produces sample interview questions with brief answers.

Safety & Guardrails

  1. GuardrailViolation.swift – Shows how guardrails handle unsafe requests.
  2. DenyListCheck.swift – Checks prompts against a deny list before sending.
  3. SafetyGuidedGeneration.swift – Uses guardrails to filter unsafe output.
  4. SafetyInputBoundaries.swift – Adjusts prompts to keep them wholesome.
  5. SafetyInstructions.swift – Provides strict safety instructions for the model.
  6. DataExtractor.swift – Extracts structured data from unstructured text.
  7. SentimentAnalyzer.swift – Determines the sentiment of provided text.

Miscellaneous Tool Demos

  1. CityInfoTools.swift – Multi-tool sample for city population, area, and timezone.
  2. AnimalInfoTools.swift – Multi-tool sample for animal facts, habitats, and diet.
  3. PlanetInfoTools.swift – Multi-tool sample for planetary distances, gravity, and atmosphere.
  4. MovieInfoTools.swift – Multi-tool sample for movie rating, director, and cast.
  5. PlantCareTools.swift – Multi-tool sample for watering, sunlight, and soil needs.
  6. RecipeInfoTools.swift – Multi-tool sample for ingredients, steps, and cook time.
  7. CarInfoTools.swift – Multi-tool sample for price, fuel economy, and dealers.
  8. ProgrammingLanguageTools.swift – Multi-tool sample for creation year, creator, and paradigm.

About

Playground examples to demonstrate Foundation Models Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Swift 100.0%