Skip to content

Commit 478b792

Browse files
committed
docs: improve code documentation for structs and methods
- Add detailed comments for `Usage` struct explaining token usage details - Add detailed comments for `Response` struct explaining the structure of an OpenAI API response - Add detailed comments for `Generative` interface explaining its methods - Update comments for `Completion` method to clarify its functionality - Update comments for `GetSummaryPrefix` method to clarify its functionality Signed-off-by: appleboy <[email protected]>
1 parent 6743633 commit 478b792

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

core/openai.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,32 @@ import (
66
"github.com/sashabaranov/go-openai"
77
)
88

9+
// Usage represents the token usage details for an OpenAI API request.
10+
// It includes the number of tokens used for the prompt, the completion,
11+
// and the total tokens used. Additionally, it may include detailed
12+
// information about the completion tokens.
913
type Usage struct {
1014
PromptTokens int
1115
CompletionTokens int
1216
TotalTokens int
1317
CompletionTokensDetails *openai.CompletionTokensDetails
1418
}
1519

20+
// Response represents the structure of a response from the OpenAI API.
21+
// It contains the content of the response and the usage information.
1622
type Response struct {
1723
Content string
1824
Usage Usage
1925
}
2026

27+
// Generative defines an interface for generative AI operations.
28+
// It includes methods for creating completions and obtaining summary prefixes.
2129
type Generative interface {
22-
// CreateCompletion is an API call to create a completion.
30+
// Completion generates a completion based on the provided content.
31+
// It takes a context and a string as input and returns a Response pointer and an error.
2332
Completion(ctx context.Context, content string) (resp *Response, err error)
24-
// GetSummaryPrefix is an API call to get a summary prefix using function call.
33+
34+
// GetSummaryPrefix generates a summary prefix based on the provided content.
35+
// It takes a context and a string as input and returns a Response pointer and an error.
2536
GetSummaryPrefix(ctx context.Context, content string) (resp *Response, err error)
2637
}

0 commit comments

Comments
 (0)