Last active
February 24, 2025 21:08
-
-
Save dlo/dd361e9e22ea5adb2cdf6e8456eda99f to your computer and use it in GitHub Desktop.
Revisions
-
dlo revised this gist
Feb 24, 2025 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ func main() { file, err := client.Files.New(context.TODO(), openai.FileNewParams{ // IMPORTANT File: openai.FileParam(io.Reader(bytes.NewBuffer([]byte(s))), "context.txt", "text/plain"), Purpose: openai.F(openai.FilePurposeAssistants), }) if err != nil { -
dlo created this gist
Feb 24, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ package main import ( "bytes" "context" "io" "github.com/openai/openai-go" ) func main() { client := openai.NewClient() s := "This is just random context" file, err := client.Files.New(context.TODO(), openai.FileNewParams{ // IMPORTANT File: openai.FileParam(io.Reader(bytes.NewBuffer([]byte(s))), "context.txt", "application/pdf"), Purpose: openai.F(openai.FilePurposeAssistants), }) if err != nil { panic(err) } vs, err := client.Beta.VectorStores.New(context.TODO(), openai.BetaVectorStoreNewParams{ Name: openai.F(" Vector Store"), FileIDs: openai.F([]string{file.ID}), }) if err != nil { panic(err) } _, err = client.Beta.Assistants.New(context.TODO(), openai.BetaAssistantNewParams{ Model: openai.F(openai.ChatModelGPT4o), Name: openai.F("Random Assistant"), Instructions: openai.F("You're a helpful assistant."), Tools: openai.F([]openai.AssistantToolUnionParam{openai.FileSearchToolParam{ Type: openai.F(openai.FileSearchToolTypeFileSearch), }}), ToolResources: openai.F(openai.BetaAssistantNewParamsToolResources{ FileSearch: openai.F(openai.BetaAssistantNewParamsToolResourcesFileSearch{ VectorStoreIDs: openai.F([]string{vs.ID}), }), }), }) if err != nil { panic(err) } }