Go client libraries for OpenAI APIs. Supported APIs:
✅ completions
✅ chat
✅ edits
🚧 images
✅ moderations
✅ audio
✅ embeddings
Set your API key
as the OPENAI_API_KEY
environmental variable before running the examples.
Go client libraries for OpenAI
License: Apache License 2.0
Go client libraries for OpenAI APIs. Supported APIs:
✅ completions
✅ chat
✅ edits
🚧 images
✅ moderations
✅ audio
✅ embeddings
Set your API key
as the OPENAI_API_KEY
environmental variable before running the examples.
Line 40 in 3c4e9fb
Can we increase the timeout period or set the environmental variable? Sometimes there will be a timeout when encountering extensive data.
Failed to complete: context deadline exceeded (Client.Timeout or context cancellation while reading body)
Having issue:
error making request: Post "https://api.openai.com/v1/chat/completions": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
any reason why? we may need to increase the default context timeout for longer delayed responses
Hey there,
I'm trying to use CreateTranscription
ctx = context.Background()
client = audio.NewClient(openai.NewSession(conf.openAiToken), "")
resp, err := client.CreateTranscription(ctx, &audio.CreateTranscriptionParams{
Language: "en",
Audio: aFile,
AudioFormat: "mp3",
})
and I got the following error:
Failed to complete: error making a request: Post "https://api.openai.com/v1/audio/transcriptions": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Looks like it is because the uploading of the audio file happens, and it takes some time. When the file is 1-3MB, then it works, but when I try 7+MB then, I get the timeout error.
Please advise how to fix that moment. I tried to find a solution, but the only one that I found was to change the timeout
httpClient := &http.Client{
Timeout: time.Minute * 5, // Set a timeout of 5 minutes
}
But I couldn't figure out how then use httpClient
and how to pass it to further.
Thanks in advance 🙏
I added Stream: true
to the request parameters and returned some "Server-Sent Events" data that could not be parsed.
client := chat.NewClient(s, "gpt-3.5-turbo")
resp, err := client.CreateCompletion(ctx, &chat.CreateCompletionParams{
Messages: []*chat.Message{
{Role: "user", Content: "hello"},
},
Stream: true,
})
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"role":"assistant"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"\n\n"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"Hello"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"!"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" How"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" can"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" I"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" assist"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" you"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":" today"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{"content":"?"},"index":0,"finish_reason":null}]}
data: {"id":"chatcmpl-6s9Fmuz4z...jxmcQKQeiGr","object":"chat.completion.chunk","created":1678363302,"model":"gpt-3.5-turbo-0301","choices":[{"delta":{},"index":0,"finish_reason":"stop"}]}
data: [DONE]
Failed to complete: EOF
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x631bb6]
Line 46 in 0c89b58
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.