{"id":22021912,"url":"https://github.com/functioncalling/functioncalling-aiproxyswift","last_synced_at":"2025-05-07T06:42:48.580Z","repository":{"id":262567396,"uuid":"875614889","full_name":"FunctionCalling/FunctionCalling-AIProxySwift","owner":"FunctionCalling","description":"Easy to use your Swift native functions for function calling with AIProxySwift.","archived":false,"fork":false,"pushed_at":"2025-04-30T14:45:37.000Z","size":83,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-30T15:55:57.990Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FunctionCalling.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-20T13:04:07.000Z","updated_at":"2025-04-30T14:45:39.000Z","dependencies_parsed_at":"2024-12-06T02:29:24.169Z","dependency_job_id":"19ca90ad-2e54-4941-9139-704cfe030c82","html_url":"https://github.com/FunctionCalling/FunctionCalling-AIProxySwift","commit_stats":null,"previous_names":["functioncalling/functioncalling-aiproxyswift"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FunctionCalling%2FFunctionCalling-AIProxySwift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FunctionCalling%2FFunctionCalling-AIProxySwift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FunctionCalling%2FFunctionCalling-AIProxySwift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FunctionCalling%2FFunctionCalling-AIProxySwift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FunctionCalling","download_url":"https://codeload.github.com/FunctionCalling/FunctionCalling-AIProxySwift/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831098,"owners_count":21810777,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T06:16:17.446Z","updated_at":"2025-05-07T06:42:48.575Z","avatar_url":"https://github.com/FunctionCalling.png","language":"Swift","readme":"# FunctionCalling-AIProxySwift\n\nThis library simplifies the integration of the [FunctionCalling](https://github.com/fumito-ito/FunctionCalling) macro into [AIProxySwift](https://github.com/lzell/AIProxySwift). By using this library, you can directly generate `Tool` objects from Swift native functions, which can then be specified as FunctionCalling when invoking AIProxy.\n\n## Usage\n\n```swift\n\nimport FunctionCalling\nimport FunctionCalling_AIProxySwift\nimport AIProxy\n\n// MARK: Declare the container and functions for the tools to be called from FunctionCalling.\n\n@FunctionCalling(service: .chatGPT)\nstruct MyFunctionTools {\n    @CallableFunction\n    /// Get the current stock price for a given ticker symbol\n    ///\n    /// - Parameter: The stock ticker symbol, e.g. GOOG for Google Inc.\n    func getStockPrice(ticker: String) async throws -\u003e String {\n        // code to return stock price of passed ticker\n    }\n}\n\n// MARK: You can directly pass the tools generated from objects to the model in AIProxy.\n\nlet openAIService = AIProxy.openAIService(\n    partialKey: \"partial-key-from-your-developer-dashboard\",\n    serviceURL: \"service-url-from-your-developer-dashboard\"\n)\n\ndo {\n    let requestBody = OpenAIChatCompletionRequestBody(\n        model: \"gpt-4o-2024-08-06\",\n        messages: [\n            .user(content: .text(\"How cold is it today in SF?\"))\n        ],\n        tools: MyFunctionTools().toOpenAITools()\n    )\n\n    let response = try await openAIService.chatCompletionRequest(body: requestBody)\n    if let toolCall = response.choices.first?.message.toolCalls?.first {\n        let functionName = toolCall.function.name\n        let arguments = toolCall.function.arguments ?? [:]\n        print(\"ChatGPT wants us to call function \\(functionName) with arguments: \\(arguments)\")\n    } else {\n        print(\"Could not get function arguments\")\n    }\n\n} catch AIProxyError.unsuccessfulRequest(let statusCode, let responseBody) {\n    print(\"Received \\(statusCode) status code with response body: \\(responseBody)\")\n} catch {\n    print(\"Could not make an OpenAI structured output tool call: \\(error.localizedDescription)\")\n}\n```\n\n## Installation\n\n### Swift Package Manager\n\n```\nlet package = Package(\n    name: \"MyPackage\",\n    products: [...],\n    targets: [\n        .target(\n            \"YouAppModule\",\n            dependencies: [\n                .product(name: \"FunctionCalling-AIProxySwift\", package: \"FunctionCalling-AIProxySwift\")\n            ]\n        )\n    ],\n    dependencies: [\n        .package(url: \"https://github.com/FunctionCalling/FunctionCalling-AIProxySwift\", from: \"0.1.0\")\n    ]\n)\n```\n\n## Contributing\n\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\nApache v2 License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunctioncalling%2Ffunctioncalling-aiproxyswift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunctioncalling%2Ffunctioncalling-aiproxyswift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunctioncalling%2Ffunctioncalling-aiproxyswift/lists"}