#FINISHED

52 messages · Page 1 of 1 (latest)

tall jay
#

A lot of thins weird here

tall vault
#

that's just a snippet btw

tall jay
#

make is for making arrays, are you tryin to make an array of length 0.1?

tall vault
#
chunk := make([]byte, 0.1)
#

is what I am trying to set

tall jay
#

What does that mean

tall vault
#

sorry, i'm beginner

tall jay
#

0.1 elements?

tall vault
#

when i switched it to 1 from 16 it made my code go faster

tall jay
#

What are you tryign to do?

tall vault
#

it's to forward requests faster

#

from server -> client

tall jay
#

Again, what are you tryin to do

tall vault
#

it's a fork of another program

tall vault
#

it's to forward requests faster

tall jay
#

I mean with this chunk := make([]byte, 0.1)

tall vault
#

im trying to set that to 0.1

#

when I do my build fails

#

1 works fine

#

sorry if i'm confusing

tall jay
#

make makes arrays, you supply the type and the length

#

An array of length 0.1 doesn't make sense

tall vault
#

huh

#

thanks

#

here

#

i'll just give you the whole thing

#
if !original_request.Stream {
        // Get response body
        fulltext, err := io.ReadAll(response.Body)
        if err != nil {
            c.JSON(500, gin.H{
                "error": "error reading response",
            })
            return
        }
        // Set response type to json
        c.Header("Content-Type", "application/json")
        full_response := responses.NewChatCompletion(string(fulltext))
        if err != nil {
            return
        }
        c.JSON(200, full_response)
        return
    } else {
        // Set response type to text/event-stream
        c.Header("Content-Type", "text/event-stream")
        // Reader
        reader := bufio.NewReader(response.Body)
        // Loop through the response
        for {
            chunk := make([]byte, 0.1)
            n, err := reader.Read(chunk)
            if err != nil {
                if err == io.EOF {
                    break
                }
                c.JSON(500, gin.H{
                    "error": "error reading response",
                })
                return
            }
            // Convert chunk to string
            chunk_string := string(chunk[:n])
            // Convert chunk to json string
            json_string, err := json.Marshal(responses.NewChatCompletionChunk(chunk_string))
            if err != nil {
                c.JSON(500, gin.H{
                    "error": "error converting response",
                })
                return
            }
            c.String(200, "data: "+string(json_string)+"\n\n")
        }
    }
    c.String(200, "data: [DONE]")

}

#

sorry, i'm really beginner as stated by the tag

tall jay
#

What is your question again?

tall vault
#

setting chunk := make([]byte, 0.1) to 0.1

#

but when i try it errors out

tall jay
#

Okay but why?

tall vault
#

it was originally 16

#

when i set it to 1

tall jay
#

You can't make an array with 0.1 elements, it's doesn't make sense

tall vault
#

the code went faster

tall vault
tall jay
#

You know what an array is?

tall vault
#

nope!

tall jay
#

._.

tall vault
#

actually

#

i'm probably just being annoying

#

i'll close the thread and cope

#

chatgpt i go

tall jay
#

Do the go tour

tall vault
#

kk uh

#

idk how to close the thread

#

so ig stop responding