Skip to content

nikit9s/gpt-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPT Client Library

Description

This project is a library for interacting with the GPT API. The library aims to encapsulate the logic of working with the API key and interacting with the server, as well as supporting sessions for fine-tuning models and storing session IDs.

Main functions

  • Generate a response.
  • Start a new session.
  • Generate a response using a session and settings.
go get github.com/nikit9s/gpt-client
go mod tidy

Usage Example

package main

import (
    "fmt"
    "github.com/nikit9s/gpt-client/pkg/gptclient"
)

func main() {
    apiKey := ""
    client := gptclient.NewClient(apiKey)

    // Setting the system prompt
    client.SetSystemPrompt("You are a helpful assistant that provides concise and accurate answers.")

    config := gptclient.Config{
        Model:       "gpt-3.5-turbo",
        MaxTokens:   100,
        Temperature: 0.7,
    }

    // Starting a new session
    sessionID, err := client.StartSession("Hello, world!")
    if err != nil {
        fmt.Println("Error starting session:", err)
        return
    }

    // Generating a response using the session
    response, err := client.GenerateResponseWithSession("Tell me a joke.", sessionID, config)
    if err != nil {
        fmt.Println("Error generating response:", err)
        return
    }

    fmt.Println("Response:", response)
}

Contributing

Feel free to submit issues or pull requests for any improvements or fixes.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages