feat: using parsing on response
This commit is contained in:
@ -7,7 +7,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -235,42 +234,6 @@ func getCompletionsForImage(model string, temperature float64, prompt string, im
|
||||
return request, nil
|
||||
}
|
||||
|
||||
// {
|
||||
// "id": "chatcmpl-B4XgiHcd7A2nyK7eyARdggSvfFuWQ",
|
||||
// "object": "chat.completion",
|
||||
// "created": 1740422508,
|
||||
// "model": "gpt-4o-mini-2024-07-18",
|
||||
// "choices": [
|
||||
// {
|
||||
// "index": 0,
|
||||
// "message": {
|
||||
// "role": "assistant",
|
||||
// "content": "{\"links\":[],\"tags\":[\"Git\",\"Programming\",\"Humor\",\"Meme\"],\"text\":[\"GIT FLOW\",\"JUST USE MAIN\",\"JUST USE MAIN\"]}",
|
||||
// "refusal": null
|
||||
// },
|
||||
// "logprobs": null,
|
||||
// "finish_reason": "stop"
|
||||
// }
|
||||
// ],
|
||||
// "usage": {
|
||||
// "prompt_tokens": 775,
|
||||
// "completion_tokens": 33,
|
||||
// "total_tokens": 808,
|
||||
// "prompt_tokens_details": {
|
||||
// "cached_tokens": 0,
|
||||
// "audio_tokens": 0
|
||||
// },
|
||||
// "completion_tokens_details": {
|
||||
// "reasoning_tokens": 0,
|
||||
// "audio_tokens": 0,
|
||||
// "accepted_prediction_tokens": 0,
|
||||
// "rejected_prediction_tokens": 0
|
||||
// }
|
||||
// },
|
||||
// "service_tier": "default",
|
||||
// "system_fingerprint": "fp_7fcd609668"
|
||||
// }
|
||||
|
||||
type ResponseChoiceMessage struct {
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
@ -348,13 +311,5 @@ func (client OpenAiClient) GetImageInfo(imageName string, imageData []byte) (Ima
|
||||
return ImageInfo{}, err
|
||||
}
|
||||
|
||||
info := ImageInfo{}
|
||||
err = json.Unmarshal(response, &info)
|
||||
if err != nil {
|
||||
return ImageInfo{}, err
|
||||
}
|
||||
|
||||
log.Println(string(response))
|
||||
|
||||
return info, nil
|
||||
return parseOpenAiResponse(response)
|
||||
}
|
||||
|
Reference in New Issue
Block a user