Skip to content

Commit

Permalink
Rename some of the new functions, for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Aug 6, 2024
1 parent f614010 commit 28c7f41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 36 deletions.
22 changes: 11 additions & 11 deletions v2/ollamaclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func (oc *Config) SetTool(tool Tool) {
oc.Tools = append(oc.Tools, tool)
}

// GetOutputChat sends a request to the Ollama API and returns the generated response
func (oc *Config) GetOutputChat(promptAndOptionalImages ...string) (OutputResponse, error) {
// GetChatResponse sends a request to the Ollama API and returns the generated response
func (oc *Config) GetChatResponse(promptAndOptionalImages ...string) (OutputResponse, error) {
var (
temperature float64
seed = oc.SeedOrNegative
Expand Down Expand Up @@ -249,8 +249,8 @@ func (oc *Config) GetOutputChat(promptAndOptionalImages ...string) (OutputRespon
return res, nil
}

// GetOutputResponse sends a request to the Ollama API and returns the generated response
func (oc *Config) GetOutputResponse(promptAndOptionalImages ...string) (OutputResponse, error) {
// GetResponse sends a request to the Ollama API and returns the generated response
func (oc *Config) GetResponse(promptAndOptionalImages ...string) (OutputResponse, error) {
var (
temperature float64
cacheKey string
Expand Down Expand Up @@ -351,7 +351,7 @@ func (oc *Config) GetOutputResponse(promptAndOptionalImages ...string) (OutputRe

// GetOutput sends a request to the Ollama API and returns the generated output string
func (oc *Config) GetOutput(promptAndOptionalImages ...string) (string, error) {
resp, err := oc.GetOutputResponse(promptAndOptionalImages...)
resp, err := oc.GetResponse(promptAndOptionalImages...)
if err != nil {
return "", err
}
Expand All @@ -367,18 +367,18 @@ func (oc *Config) MustOutput(promptAndOptionalImages ...string) string {
return output
}

// MustOutputResponse returns the response from Ollama, or an error if not
func (oc *Config) MustOutputResponse(promptAndOptionalImages ...string) OutputResponse {
resp, err := oc.GetOutputResponse(promptAndOptionalImages...)
// MustGetResponse returns the response from Ollama, or an error if not
func (oc *Config) MustGetResponse(promptAndOptionalImages ...string) OutputResponse {
resp, err := oc.GetResponse(promptAndOptionalImages...)
if err != nil {
return OutputResponse{Error: err.Error()}
}
return resp
}

// MustOutputChat returns the response from Ollama, or a response with an error if not
func (oc *Config) MustOutputChat(promptAndOptionalImages ...string) OutputResponse {
output, err := oc.GetOutputChat(promptAndOptionalImages...)
// MustGetChatResponse returns the response from Ollama, or a response with an error if not
func (oc *Config) MustGetChatResponse(promptAndOptionalImages ...string) OutputResponse {
output, err := oc.GetChatResponse(promptAndOptionalImages...)
if err != nil {
return OutputResponse{Error: err.Error()}
}
Expand Down
28 changes: 3 additions & 25 deletions v2/tools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,11 @@ func TestTools(t *testing.T) {
}
}`), &toolGetCurrentWeather)

// toolGetCurrentWeather := Tool{
// Type: "function",
// Function: ToolFunction{
// Name: "get_current_weather",
// Description: "Get the current weather for a location",
// Parameters: ToolParameters{
// Type: "object",
// Properties: map[string]ToolProperty{
// "location": {
// Type: "string",
// Description: "The location to get the weather for, e.g. San Francisco, CA",
// },
// "format": {
// Type: "string",
// Description: "The format to return the weather in, e.g. 'celsius' or 'fahrenheit'",
// Enum: []string{"celsius", "fahrenheit"},
// },
// },
// Required: []string{"location", "format"},
// },
// },
// }

oc.SetTool(toolGetCurrentWeather)

prompt := "What is the weather in Toronto?"
generatedOutput := oc.MustOutputChat(prompt)
const prompt = "What is the weather in Toronto?"

generatedOutput := oc.MustGetChatResponse(prompt)
if generatedOutput.Error != "" {
t.Error(generatedOutput.Error)
}
Expand Down

0 comments on commit 28c7f41

Please sign in to comment.