Skip to content

Commit

Permalink
fix: URL Encode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sniij committed Jan 5, 2025
1 parent 193763f commit edcc55b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions convert-to-markdown/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"io"
"log"
"net/http"
netURL "net/url"
"os"
"sync"

Expand Down Expand Up @@ -40,7 +41,10 @@ func init() {

// FetchGPT processes text using the custom GPT server.
func FetchGPT(gptRequest GPTRequest) (string, error) {
serverURL := os.Getenv("GPT_SERVER")
serverURL, err := netURL.QueryUnescape(os.Getenv("GPT_SERVER"))
if err != nil {
return "", fmt.Errorf("failed to get server url: %v", err)
}

body, err := json.Marshal(gptRequest)
if err != nil {
Expand Down Expand Up @@ -104,19 +108,19 @@ func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events
log.Printf("Error processing article with GPT that content: %v", err)
return
}
cleanedContent, err = FetchGPT(GPTRequest{Content: article.Content, Prompt: os.Getenv("PROMPT_CONTENT_2")})
cleanedContent2, err := FetchGPT(GPTRequest{Content: cleanedContent, Prompt: os.Getenv("PROMPT_CONTENT_2")})
if err != nil {
log.Printf("Error processing article with GPT that content: %v", err)
return
}

cleanedContent, err = FetchGPT(GPTRequest{Content: article.Content, Prompt: os.Getenv("PROMPT_CONTENT_3")})
cleanedContent3, err := FetchGPT(GPTRequest{Content: cleanedContent2, Prompt: os.Getenv("PROMPT_CONTENT_3")})
if err != nil {
log.Printf("Error processing article with GPT that content: %v", err)
return
}

article.Content = cleanedContent
article.Content = cleanedContent3
}()
go func() {
defer wg.Done()
Expand Down

0 comments on commit edcc55b

Please sign in to comment.