test_utils

package
v0.0.0-...-e06565c Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearTestingPath

func ClearTestingPath(cwd string)

func GetRuntime

func GetRuntime(pluginZip []byte, cwd string) (*local_runtime.LocalPluginRuntime, error)

GetRuntime returns a runtime for a plugin Please ensure cwd is a valid directory without any file in it

func RunOnce

func RunOnce[T RunOnceRequest, R any](
	runtime *local_runtime.LocalPluginRuntime,
	accessType access_types.PluginAccessType,
	action access_types.PluginAccessAction,
	request T,
) (*stream.Stream[R], error)

RunOnce sends a request to plugin and returns a stream of responses It automatically generates a session for the request

func RunOnceWithSession

func RunOnceWithSession[T RunOnceRequest, R any](
	runtime *local_runtime.LocalPluginRuntime,
	session *session_manager.Session,
	request T,
) (*stream.Stream[R], error)

RunOnceWithSession sends a request to plugin and returns a stream of responses It requires a session to be provided

func StartFakeOpenAIServer

func StartFakeOpenAIServer() (int, func())

StartFakeOpenAIServer starts a fake OpenAI server that streams responses Returns the port number and a cancel function to stop the server

Types

type Delta

type Delta struct {
	Content string `json:"content"`
}

type FakeOpenAIResponse

type FakeOpenAIResponse struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Created int64  `json:"created"`
	Model   string `json:"model"`
	Choices []struct {
		Index        int     `json:"index"`
		Delta        Delta   `json:"delta"`
		FinishReason *string `json:"finish_reason"`
	} `json:"choices"`
}

FakeOpenAIResponse represents the structure of an OpenAI chat completion response

Jump to

Keyboard shortcuts

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