-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2aa5ff8
commit a994f63
Showing
8 changed files
with
67 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/go-deepseek/deepseek" | ||
"github.com/go-deepseek/deepseek/request" | ||
) | ||
|
||
func main() { | ||
// create deepseek api client | ||
cli, _ := deepseek.NewClient(os.Getenv("DEEPSEEK_API_KEY")) | ||
|
||
inputMessage := "Hello Deepseek!" // set your input message | ||
chatReq := &request.ChatCompletionsRequest{ | ||
Model: deepseek.DEEPSEEK_CHAT_MODEL, | ||
Stream: false, | ||
Messages: []*request.Message{ | ||
{ | ||
Role: "user", | ||
Content: inputMessage, | ||
}, | ||
}, | ||
} | ||
fmt.Printf("input message => %s\n", chatReq.Messages[0].Content) | ||
|
||
// call deepseek api | ||
ctx, _ := context.WithTimeout(context.Background(), time.Second*2) // wait for 2 seconds to get response | ||
chatResp, err := cli.CallChatCompletionsChat(ctx, chatReq) | ||
if err != nil { | ||
fmt.Println("error => ", err) | ||
return | ||
} | ||
fmt.Printf("output message => %s\n", chatResp.Choices[0].Message.Content) | ||
} |
This file contains 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 characters