some fixes
This commit is contained in:
@@ -6,6 +6,6 @@ import (
|
||||
|
||||
const PawanBaseURL = "https://api.pawan.krd"
|
||||
const GPTBaseUrl = "https://chat.gpt-chatbot.ru/api/openai"
|
||||
const CompressPrompt = "Сделай выжимку нашего диалога. Сохрани все ключевые моменты(например одежду, расположение и тд.)"
|
||||
const CompressPrompt = "Сделай выжимку нашего диалога. Сохрани все ключевые моменты(например одежду, расположение, основные действия и фразы и тд.) из каждого сообщения. Для моих сообщений используй обращение во втором лице(ты, вы), для своих в первом лице(я)."
|
||||
|
||||
var CosmoRPUrl = fmt.Sprintf("%s/cosmosrp-2.5", PawanBaseURL)
|
||||
|
||||
@@ -89,12 +89,12 @@ func NewOpenAIAPI(baseURL, token, model string) *OpenAIAPI {
|
||||
type CreateCompletionReq struct {
|
||||
Model string `json:"model"`
|
||||
Messages []Message `json:"messages"`
|
||||
Verbosity string `json:"verbosity"`
|
||||
Temperature float32 `json:"temperature"`
|
||||
PresencePenalty int `json:"presence_penalty"`
|
||||
FrequencyPenalty int `json:"frequency_penalty"`
|
||||
TopP int `json:"top_p"`
|
||||
MaxCompletionTokens int `json:"max_completition_tokens"`
|
||||
Verbosity string `json:"verbosity,omitempty"`
|
||||
Temperature float32 `json:"temperature,omitempty"`
|
||||
PresencePenalty int `json:"presence_penalty,omitempty"`
|
||||
FrequencyPenalty int `json:"frequency_penalty,omitempty"`
|
||||
TopP int `json:"top_p,omitempty"`
|
||||
MaxCompletionTokens int `json:"max_completition_tokens,omitempty"`
|
||||
}
|
||||
|
||||
func (o *OpenAIAPI) CreateCompletion(request CreateCompletionReq) (*OpenAIResponse, error) {
|
||||
@@ -164,6 +164,13 @@ func (o *OpenAIAPI) CompressChat(history []Message) (*OpenAIResponse, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode == 504 || resp.StatusCode == 400 {
|
||||
time.Sleep(5 * time.Second)
|
||||
resp, err = http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user