diff --git a/api.go b/api.go index 0c9619e..c339afe 100644 --- a/api.go +++ b/api.go @@ -4,15 +4,12 @@ import ( "encoding/json" "fmt" "net/http" - "time" ) const apiURLv1 = "https://api.openai.com/v1" func newTransport() *http.Client { - return &http.Client{ - Timeout: time.Minute, - } + return &http.Client{} } // Client is OpenAI GPT-3 API client. diff --git a/api_test.go b/api_test.go index 30933b3..1e1c5d0 100644 --- a/api_test.go +++ b/api_test.go @@ -53,15 +53,6 @@ func TestAPI(t *testing.T) { } } // else skip - searchReq := SearchRequest{ - Documents: []string{"White House", "hospital", "school"}, - Query: "the president", - } - _, err = c.Search(ctx, "ada", searchReq) - if err != nil { - t.Fatalf("Search error: %v", err) - } - embeddingReq := EmbeddingRequest{ Input: []string{ "The food was delicious and the waiter", diff --git a/search.go b/search.go deleted file mode 100644 index 894d127..0000000 --- a/search.go +++ /dev/null @@ -1,62 +0,0 @@ -package gogpt - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "net/http" -) - -/* -- 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 { - Query string `json:"query"` - Documents []string `json:"documents"` // 1* - FileID string `json:"file,omitempty"` // 1* - MaxRerank int `json:"max_rerank,omitempty"` // 2* - ReturnMetadata bool `json:"return_metadata,omitempty"` - User string `json:"user,omitempty"` -} - -// SearchResult represents single result from search API. -type SearchResult struct { - Document int `json:"document"` - Object string `json:"object"` - Score float32 `json:"score"` - Metadata string `json:"metadata"` // 2* -} - -// SearchResponse represents a response structure for search API. -type SearchResponse struct { - SearchResults []SearchResult `json:"data"` - Object string `json:"object"` -} - -// Search — perform a semantic search api call over a list of documents. -func (c *Client) Search( - ctx context.Context, - engineID string, - request SearchRequest, -) (response SearchResponse, err error) { - var reqBytes []byte - reqBytes, err = json.Marshal(request) - if err != nil { - return - } - - urlSuffix := fmt.Sprintf("/engines/%s/search", engineID) - req, err := http.NewRequest("POST", c.fullURL(urlSuffix), bytes.NewBuffer(reqBytes)) - if err != nil { - return - } - - req = req.WithContext(ctx) - err = c.sendRequest(req, &response) - return -}