Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do you consider building a doc for this SDK? #235

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# hooks


# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
1 change: 1 addition & 0 deletions Sources/OpenAI/Public/Models/ChatQuery.swift
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import Foundation

/// Creates a model response for the given chat conversation
/// https://platform.openai.com/docs/guides/text-generation
/// https://platform.openai.com/docs/api-reference/chat/create
public struct ChatQuery: Equatable, Codable, Streamable {

/// A list of messages comprising the conversation so far
36 changes: 35 additions & 1 deletion Sources/OpenAI/Public/Models/ChatResult.swift
Original file line number Diff line number Diff line change
@@ -6,9 +6,43 @@
//

import Foundation

/// https://platform.openai.com/docs/api-reference/chat/object
/// Example Completion object print
/// ```
/// {
/// "id": "chatcmpl-123456",
/// "object": "chat.completion",
/// "created": 1728933352,
/// "model": "gpt-4o-2024-08-06",
/// "choices": [
/// {
/// "index": 0,
/// "message": {
/// "role": "assistant",
/// "content": "Hi there! How can I assist you today?",
/// "refusal": null
/// },
/// "logprobs": null,
/// "finish_reason": "stop"
/// }
/// ],
/// "usage": {
/// "prompt_tokens": 19,
/// "completion_tokens": 10,
/// "total_tokens": 29,
/// "prompt_tokens_details": {
/// "cached_tokens": 0
/// },
/// "completion_tokens_details": {
/// "reasoning_tokens": 0
/// }
/// },
/// "system_fingerprint": "fp_6b68a8204b"
/// }
/// ```
public struct ChatResult: Codable, Equatable {

/// mimic the choices array in the chat completion object
public struct Choice: Codable, Equatable {
public typealias ChatCompletionMessage = ChatQuery.ChatCompletionMessageParam

325 changes: 325 additions & 0 deletions docs/Classes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Classes Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset='utf-8'>
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>

<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a name="//apple_ref/swift/Section/Classes" class="dashAnchor"></a>
<a title="Classes Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html"> Docs</a> (100% documented)</p>
<div class="header-right">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</div>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="index.html">Index</a>
<img id="carat" src="img/carat.png" alt=""/>
Classes Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="Classes.html">Classes</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Classes/OpenAI.html">OpenAI</a>
</li>
<li class="nav-group-task">
<a href="Classes/OpenAI/Configuration.html">– Configuration</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Enums/OpenAIError.html">OpenAIError</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Extensions.html">Extensions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Extensions/Model.html">Model</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Protocols/OpenAIProtocol.html">OpenAIProtocol</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Structs.html">Structures</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Structs/APIError.html">APIError</a>
</li>
<li class="nav-group-task">
<a href="Structs/APIErrorResponse.html">APIErrorResponse</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioSpeechQuery.html">AudioSpeechQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioSpeechQuery/AudioSpeechVoice.html">– AudioSpeechVoice</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioSpeechQuery/AudioSpeechResponseFormat.html">– AudioSpeechResponseFormat</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioSpeechQuery/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioSpeechQuery/Speed.html">– Speed</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioSpeechResult.html">AudioSpeechResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioTranscriptionQuery.html">AudioTranscriptionQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioTranscriptionQuery/ResponseFormat.html">– ResponseFormat</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioTranscriptionQuery/FileType.html">– FileType</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioTranscriptionResult.html">AudioTranscriptionResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioTranslationQuery.html">AudioTranslationQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/AudioTranslationResult.html">AudioTranslationResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatQuery.html">ChatQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatQuery/ChatCompletionMessageParam.html">– ChatCompletionMessageParam</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatQuery/Stop.html">– Stop</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatQuery/ResponseFormat.html">– ResponseFormat</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatQuery/ChatCompletionFunctionCallOptionParam.html">– ChatCompletionFunctionCallOptionParam</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatQuery/ChatCompletionToolParam.html">– ChatCompletionToolParam</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatQuery/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatResult.html">ChatResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatResult/Choice.html">– Choice</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatResult/CompletionUsage.html">– CompletionUsage</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatResult/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatStreamResult.html">ChatStreamResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatStreamResult/Choice.html">– Choice</a>
</li>
<li class="nav-group-task">
<a href="Structs/ChatStreamResult/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/CompletionsQuery.html">CompletionsQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/CompletionsResult.html">CompletionsResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/CompletionsResult/Usage.html">– Usage</a>
</li>
<li class="nav-group-task">
<a href="Structs/CompletionsResult/Choice.html">– Choice</a>
</li>
<li class="nav-group-task">
<a href="Structs/EditsQuery.html">EditsQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/EditsResult.html">EditsResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/EditsResult/Choice.html">– Choice</a>
</li>
<li class="nav-group-task">
<a href="Structs/EditsResult/Usage.html">– Usage</a>
</li>
<li class="nav-group-task">
<a href="Structs/EmbeddingsQuery.html">EmbeddingsQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/EmbeddingsQuery/Input.html">– Input</a>
</li>
<li class="nav-group-task">
<a href="Structs/EmbeddingsQuery/EncodingFormat.html">– EncodingFormat</a>
</li>
<li class="nav-group-task">
<a href="Structs/EmbeddingsQuery/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/EmbeddingsResult.html">EmbeddingsResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/EmbeddingsResult/Embedding.html">– Embedding</a>
</li>
<li class="nav-group-task">
<a href="Structs/EmbeddingsResult/Usage.html">– Usage</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImageEditsQuery.html">ImageEditsQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImageEditsQuery/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImageVariationsQuery.html">ImageVariationsQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImageVariationsQuery/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImagesQuery.html">ImagesQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImagesQuery/ResponseFormat.html">– ResponseFormat</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImagesQuery/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImagesQuery/Style.html">– Style</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImagesQuery/Quality.html">– Quality</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImagesQuery/Size.html">– Size</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImagesResult.html">ImagesResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/ImagesResult/Image.html">– Image</a>
</li>
<li class="nav-group-task">
<a href="Structs/ModelQuery.html">ModelQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/ModelResult.html">ModelResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/ModelResult/CodingKeys.html">– CodingKeys</a>
</li>
<li class="nav-group-task">
<a href="Structs/ModelsResult.html">ModelsResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/ModerationsQuery.html">ModerationsQuery</a>
</li>
<li class="nav-group-task">
<a href="Structs/ModerationsResult.html">ModerationsResult</a>
</li>
<li class="nav-group-task">
<a href="Structs/ModerationsResult/Moderation.html">– Moderation</a>
</li>
<li class="nav-group-task">
<a href="Structs/Vector.html">Vector</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Typealiases.html">Type Aliases</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Typealiases.html#/s:6OpenAI5Modela">Model</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<h1>Classes</h1>
<p>The following classes are available globally.</p>

</section>
<section class="section task-group-section">
<div class="task-group">
<ul>
<li class="item">
<div>
<code>
<a name="/s:6OpenAIAAC"></a>
<a name="//apple_ref/swift/Class/OpenAI" class="dashAnchor"></a>
<a class="token" href="#/s:6OpenAIAAC">OpenAI</a>
</code>
</div>
<div class="height-container">
<div class="pointer-container"></div>
<section class="section">
<div class="pointer"></div>
<div class="abstract">

<a href="Classes/OpenAI.html" class="slightly-smaller">See more</a>
</div>
<div class="declaration">
<h4>Declaration</h4>
<div class="language">
<p class="aside-title">Swift</p>
<pre class="highlight swift"><code><span class="kd">final</span> <span class="kd">public</span> <span class="kd">class</span> <span class="kt">OpenAI</span> <span class="p">:</span> <span class="kt"><a href="Protocols/OpenAIProtocol.html">OpenAIProtocol</a></span></code></pre>

</div>
</div>
</section>
</div>
</li>
</ul>
</div>
</section>
</section>
<section id="footer">
<p>&copy; 2024 <a class="link" href="" target="_blank" rel="external noopener"></a>. All rights reserved. (Last updated: 2024-10-17)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external noopener">jazzy ♪♫ v0.15.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external noopener">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</html>
Loading