Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An easy way to use the Mistral platform in Swift.

License

NotificationsYou must be signed in to change notification settings

nathanborror/swift-mistral

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Mistral

An unofficial Swift client library for interacting with theMistral API.

Requirements

  • Swift 5.9+
  • iOS 16+
  • macOS 13+
  • watchOS 9+
  • tvOS 16+

Installation

Add the following to yourPackage.swift file:

Package(    dependencies:[.package(url:"https://github.com/nathanborror/swift-mistral", branch:"main"),],    targets:[.target(            name:"YourApp",            dependencies:[.product(name:"Mistral",package:"swift-mistra"),]),])

Usage

Chat Completion

import Mistralletclient=Client(apiKey: MISTRAL_API_KEY)letrequest=ChatRequest(    model:"mistral-large-latest",    messages:[.init(role:.system, content:[.init(text:"You are a helpful assistant.")]),.init(role:.user, content:[.init(text:"Hello, Mistral!")])])do{letresponse=tryawait client.chatCompletions(request)print(response.completion_message.content.text)}catch{print(error)}

List Models

import Mistralletclient=Client(apiKey: MISTRAL_API_KEY)do{letresponse=tryawait client.models()print(response.data.map{ $0.id}.joined(separator:"\n"))}catch{print(error)}

Command Line Interface

$ make$ ./mistralOVERVIEW: A utility for interacting with the Mistral API.USAGE: mistral <subcommand>OPTIONS:  --version               Show the version.  -h, --help              Show help information.SUBCOMMANDS:  models                  Returns available models.  chat-completion         Completes a chat request.  See 'cli help <subcommand>' for detailed help.

About

An easy way to use the Mistral platform in Swift.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp