This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Build with AI: Create Agents with the OpenAI Agents SDK | |
| All examples use Python and the OpenAI client. | |
| Prereqs: | |
| pip install -r requirements.txt | |
| export API_KEY = os.environ[...] or set the api_key to the client | |
| """ | |
| import os |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| import WebKit | |
| import Combine | |
| import Observation | |
| @Observable class MyWebViewModel { | |
| var webPage = WebPage() | |
| func load(url: URL) async { | |
| webPage.load(URLRequest(url: url)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ContentView.swift | |
| // WebBrowser2025-iPhone | |
| // | |
| // Created by Xcode Developer on 11/3/25. | |
| // | |
| import SwiftUI | |
| import WebKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // TempSwiftUIView.swift | |
| // PlanetaryHours2025-Claude | |
| // | |
| // Created by Xcode Developer on 10/30/25. | |
| // | |
| import SwiftUI | |
| import WeatherKit | |
| import CoreLocation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ContentView.swift | |
| // DesiderataReader | |
| // | |
| // Created by Xcode Developer on 10/11/25. | |
| // | |
| import SwiftUI | |
| import AVFoundation | |
| import Combine |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import FoundationModels // Docs: https://developer.apple.com/documentation/foundationmodels | |
| import Playgrounds // #Playground macro: https://developer.apple.com/documentation/xcode/running-code-snippets-using-the-playground-macro | |
| #Playground { | |
| do { | |
| let instructions = """ | |
| You are an interactive thesaurus. Task: Given a word and a starting letter, return a synonym of the word that starts with the letter. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Save in "payload.json" | |
| { | |
| "model": "chatgpt-5", | |
| "messages": [ | |
| { | |
| "role": "system", | |
| "content": "Your instructions:\n When prompted with a specific psalm (e.g., \"Psalm 23\" or \"23\"), you will write a six-paragraph abstract of psalm \\(abstract.psalmNumber) by following the $ | |
| }, | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Prompt | |
| curl http://localhost:1234/v1/chat/completions \ | |
| -H "Content-Type: application/json" \ | |
| -d '{ | |
| "model": "deepseek-coder-v2-lite-instruct-mlx", | |
| "messages": [ | |
| { "role": "system", "content": "Answer all English questions in Spanish" }, | |
| { "role": "user", "content": "How are you?" } | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from openai import OpenAI | |
| client = OpenAI() | |
| response = client.chat.completions.create( | |
| model="gpt-4-1106-preview", | |
| messages=[ | |
| {"role": "system", "content": "You are a helpful AI assistant."}, | |
| {"role": "user", "content": "List 3 countries and their capitals."} | |
| ], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from openai import OpenAI | |
| client = OpenAI() | |
| stream = client.chat.completions.create( | |
| model="gpt-4-1106-preview", # or "gpt-4.1" if that's valid in your setup | |
| messages=[ | |
| { | |
| "role": "user", | |
| "content": "Say 'double bubble bath' ten times fast.", |
NewerOlder