rev-1: Added some fixes & improvements (#26)
* Added support for Moderations API * gofmt moderation.go * support for edits endpoint & other improvements * fix: Choice redeclared in this block * Added more parameters for the Search endpoint. (#3)
This commit is contained in:
@@ -27,8 +27,8 @@ type CompletionRequest struct {
|
|||||||
User string `json:"user,omitempty"`
|
User string `json:"user,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choice represents one of possible completions
|
// CompletionChoice represents one of possible completions
|
||||||
type Choice struct {
|
type CompletionChoice struct {
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
Index int `json:"index"`
|
Index int `json:"index"`
|
||||||
FinishReason string `json:"finish_reason"`
|
FinishReason string `json:"finish_reason"`
|
||||||
@@ -56,7 +56,7 @@ type CompletionResponse struct {
|
|||||||
Object string `json:"object"`
|
Object string `json:"object"`
|
||||||
Created uint64 `json:"created"`
|
Created uint64 `json:"created"`
|
||||||
Model string `json:"model"`
|
Model string `json:"model"`
|
||||||
Choices []Choice `json:"choices"`
|
Choices []CompletionChoice `json:"choices"`
|
||||||
Usage CompletionUsage `json:"usage"`
|
Usage CompletionUsage `json:"usage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
edits.go
6
edits.go
@@ -24,8 +24,8 @@ type EditsUsage struct {
|
|||||||
TotalTokens int `json:"total_tokens"`
|
TotalTokens int `json:"total_tokens"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choice represents one of possible edits
|
// EditsChoice represents one of possible edits
|
||||||
type Choice struct {
|
type EditsChoice struct {
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
Index int `json:"index"`
|
Index int `json:"index"`
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,7 @@ type EditsResponse struct {
|
|||||||
Object string `json:"object"`
|
Object string `json:"object"`
|
||||||
Created uint64 `json:"created"`
|
Created uint64 `json:"created"`
|
||||||
Usage EditsUsage `json:"usage"`
|
Usage EditsUsage `json:"usage"`
|
||||||
Choices []Choice `json:"choices"`
|
Choices []EditsChoice `json:"choices"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform an API call to the Edits endpoint.
|
// Perform an API call to the Edits endpoint.
|
||||||
|
|||||||
17
search.go
17
search.go
@@ -8,21 +8,34 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SearchRequest represents a request structure for search API
|
/*
|
||||||
|
- SearchRequest represents a request structure for search API.
|
||||||
|
|
||||||
|
- Info (*):
|
||||||
|
- 1*) You should specify either 'documents' or a 'file', but not both.
|
||||||
|
- 2*) This flag only takes effect when file is set.
|
||||||
|
*/
|
||||||
type SearchRequest struct {
|
type SearchRequest struct {
|
||||||
Documents []string `json:"documents"`
|
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
|
Documents []string `json:"documents"` // 1*
|
||||||
|
FileID string `json:"file"` // 1*
|
||||||
|
MaxRerank int `json:"max_rerank"` // 2*
|
||||||
|
ReturnMetadata bool `json:"return_metadata"`
|
||||||
|
User string `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchResult represents single result from search API
|
// SearchResult represents single result from search API
|
||||||
type SearchResult struct {
|
type SearchResult struct {
|
||||||
Document int `json:"document"`
|
Document int `json:"document"`
|
||||||
|
Object string `json:"object"`
|
||||||
Score float32 `json:"score"`
|
Score float32 `json:"score"`
|
||||||
|
Metadata string `json:"metadata"` // 2*
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchResponse represents a response structure for search API
|
// SearchResponse represents a response structure for search API
|
||||||
type SearchResponse struct {
|
type SearchResponse struct {
|
||||||
SearchResults []SearchResult `json:"data"`
|
SearchResults []SearchResult `json:"data"`
|
||||||
|
Object string `json:"object"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search — perform a semantic search api call over a list of documents.
|
// Search — perform a semantic search api call over a list of documents.
|
||||||
|
|||||||
Reference in New Issue
Block a user