duckchat

package module
v0.0.0-...-6ca1276 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2024 License: MIT Imports: 5 Imported by: 0

README

duckchat

Go based client for DuckChat

Example 1:

go run cmd/cli.go

preview

Example 2:

package main

import (
	"fmt"

	"github.com/mohanavel15/duckchat"
)

func main() {
	agent := duckchat.NewAgent(duckchat.GPT3dot5Turbo)

	response, err := agent.Send("What is Sagittarius A-Star?")
	if err != nil {
		fmt.Println("Unexpected Error:", err.Error())
		return
	}

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

Documentation

Index

Constants

View Source
const (
	ENDPOINT        = "https://duckduckgo.com/duckchat/v1"
	ENDPOINT_CHAT   = ENDPOINT + "/chat"
	ENDPOINT_STATUS = ENDPOINT + "/status"
	GPT4o           = "gpt-4o-mini"
	Claude3Haiku    = "claude-3-haiku-20240307"
	Llama3dot170b   = "meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo"
	Mixtral8x7b     = "mistralai/Mixtral-8x7B-Instruct-v0.1"
	USER_AGENT      = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func NewAgent

func NewAgent(model string) Agent

func (*Agent) GetVqd

func (a *Agent) GetVqd() error

func (*Agent) MakeRequest

func (a *Agent) MakeRequest() (string, error)

func (*Agent) Send

func (a *Agent) Send(message string) (string, error)

type Chat

type Chat struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
}

func NewChat

func NewChat(model string) Chat

func (*Chat) AddMessage

func (c *Chat) AddMessage(message Message)

func (*Chat) Json

func (c *Chat) Json() ([]byte, error)

func (*Chat) SetMessages

func (c *Chat) SetMessages(messages []Message)

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

func NewMessage

func NewMessage(role, content string) Message

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL