Documentation
¶
Index ¶
- func Migrate(db *gorm.DB) error
- type Author
- type FCMMessage
- type FCMService
- type GeminiService
- func (s *GeminiService) AddHistory(history models.GeminiHistoryModel) error
- func (s *GeminiService) CreateAgent(agent *models.GeminiAgent) error
- func (s *GeminiService) DeleteAgent(id string) error
- func (s *GeminiService) DeleteHistory(id string) error
- func (service *GeminiService) GenerateContent(ctx context.Context, input string, userHistories []map[string]any, ...) (string, error)
- func (s *GeminiService) GetAgent(id string) (*models.GeminiAgent, error)
- func (s *GeminiService) GetAgents(request http.Request) (paginate.Page, error)
- func (s *GeminiService) GetHistories(agentID *string, companyID *string, sessionCode *string) []models.GeminiHistoryModel
- func (s *GeminiService) RefreshHistories()
- func (s *GeminiService) SetResponseMIMEType(mimetype string)
- func (service *GeminiService) SetUpSystemInstruction(systemInstruction string)
- func (s *GeminiService) SetupAPIKey(apiKey string, skipHistory bool)
- func (s *GeminiService) SetupAgentID(agentID string)
- func (service *GeminiService) SetupModel(setTemperature float32, setTopK int32, setTopP float32, ...)
- func (service *GeminiService) SetupModelOnly(model string)
- func (s *GeminiService) SetupSessionCode(sessionCode string)
- func (s *GeminiService) UpdateAgent(id string, agent *models.GeminiAgent) error
- func (s *GeminiService) UpdateHistory(id string, history models.GeminiHistoryModel) error
- func (s *GeminiService) UploadToGemini(path, mimeType string) (string, error)
- type GoogleAPIService
- type Location
- type Photo
- type Place
- type PlacesResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FCMMessage ¶
type FCMService ¶
type FCMService struct {
// contains filtered or unexported fields
}
func NewFCMService ¶
func NewFCMService(ctx *context.ERPContext, serverKey, credentialPath *string) *FCMService
NewFCMService creates a new FCMService instance using the provided ERP context, server key, and credential path. It initializes an FCM client if a credential path is provided.
func NewFCMServiceV2 ¶
func NewFCMServiceV2(ctx *golangCtx.Context, credentialPath *string) *FCMService
NewFCMServiceV2 creates a new FCMService instance using a Go context and credential path. It initializes an FCM client if a credential path is provided.
func (*FCMService) SendFCMMessage ¶
func (s *FCMService) SendFCMMessage(token, title, body string) error
SendFCMMessage sends an FCM message using HTTP POST to the specified token with the given title and body.
func (*FCMService) SendFCMV2Message ¶
func (s *FCMService) SendFCMV2Message(token, title, body string, data map[string]string) error
SendFCMV2Message sends an FCM message using the FCM client to the specified token with the given title, body, and data.
func (*FCMService) SendFCMV2MessageByUserID ¶
func (s *FCMService) SendFCMV2MessageByUserID(userID, title, body string, data map[string]string) error
SendFCMV2MessageByUserID sends an FCM message to a user identified by userID. It retrieves the user's push tokens and sends a message to each token.
type GeminiService ¶
type GeminiService struct {
// contains filtered or unexported fields
}
func NewGeminiService ¶
func NewGeminiService(ctx *erpContext.ERPContext, apiKey string) *GeminiService
NewGeminiService creates a new instance of GeminiService with the given ERP context and API key.
It fetches the histories from the database and sets up the Gemini client. If the SkipMigration flag in the ERPContext is false, it runs the migration first. It then returns the newly created GeminiService.
func (*GeminiService) AddHistory ¶
func (s *GeminiService) AddHistory(history models.GeminiHistoryModel) error
AddHistory adds a new history to the database.
It takes a history as an argument. It adds the history to the database. If there is an error, it will return an error.
func (*GeminiService) CreateAgent ¶
func (s *GeminiService) CreateAgent(agent *models.GeminiAgent) error
CreateAgent creates a new agent in the database.
It takes an agent as an argument. It creates a new agent in the database. If there is an error, it will return an error.
func (*GeminiService) DeleteAgent ¶
func (s *GeminiService) DeleteAgent(id string) error
DeleteAgent deletes the agent from the database.
It takes the ID of the agent as an argument. It deletes the agent from the database with the given ID. If there is an error, it will return an error.
func (*GeminiService) DeleteHistory ¶
func (s *GeminiService) DeleteHistory(id string) error
DeleteHistory deletes the history from the database.
It takes the ID of the history as an argument. It deletes the history from the database with the given ID. If there is an error, it will return an error.
func (*GeminiService) GenerateContent ¶
func (service *GeminiService) GenerateContent(ctx context.Context, input string, userHistories []map[string]any, fileURL, mimeType string) (string, error)
GenerateContent generates content based on the input and user histories.
It takes the input as a string, user histories as a slice of maps, and a file URL and MIME type as arguments. It sets the given parameters as the parameters of the Gemini service. It then generates content based on the input and user histories and returns the generated content as a string. If there is an error, it will return an empty string and an error.
func (*GeminiService) GetAgent ¶
func (s *GeminiService) GetAgent(id string) (*models.GeminiAgent, error)
GetAgent fetches the agent from the database.
It takes the ID of the agent as an argument. It fetches the agent from the database with the given ID. It returns the fetched agent and an error.
func (*GeminiService) GetAgents ¶
GetAgents fetches the agents from the database.
It takes an HTTP request as an argument. It fetches the agents from the database and paginates them. It returns a paginate.Page and an error.
func (*GeminiService) GetHistories ¶
func (s *GeminiService) GetHistories(agentID *string, companyID *string, sessionCode *string) []models.GeminiHistoryModel
GetHistories fetches the histories from the database.
It takes an agent ID and company ID as arguments. It fetches the histories from the database, and if the agent ID or company ID is set, it will filter the histories by the given agent ID or company ID. It returns a slice of models.GeminiHistoryModel.
func (*GeminiService) RefreshHistories ¶
func (s *GeminiService) RefreshHistories()
RefreshHistories refreshes the histories from the database.
It will call getHistories to fetch the histories from the database and set them as the histories of the Gemini service.
func (*GeminiService) SetResponseMIMEType ¶
func (s *GeminiService) SetResponseMIMEType(mimetype string)
SetResponseMIMEType sets the MIME type for the response.
It takes the MIME type as an argument. It sets the response MIME type of the Gemini service.
func (*GeminiService) SetUpSystemInstruction ¶
func (service *GeminiService) SetUpSystemInstruction(systemInstruction string)
SetUpSystemInstruction sets the system instruction for the Gemini service.
It takes a string as argument and sets it as the system instruction of the Gemini service.
func (*GeminiService) SetupAPIKey ¶
func (s *GeminiService) SetupAPIKey(apiKey string, skipHistory bool)
SetupAPIKey sets the API key for the Gemini service.
It will create a new Gemini client with the given API key and refresh the histories. If skipHistory is true, it won't refresh the histories.
func (*GeminiService) SetupAgentID ¶
func (s *GeminiService) SetupAgentID(agentID string)
SetupAgentID sets the agent ID for the Gemini service.
It will filter the histories by the given agent ID when calling RefreshHistories.
func (*GeminiService) SetupModel ¶
func (service *GeminiService) SetupModel( setTemperature float32, setTopK int32, setTopP float32, setMaxOutputTokens int32, responseMimetype string, model string, )
SetupModel sets the model and its parameters for the Gemini service.
It takes the set temperature, top K, top P, maximum output tokens, response MIME type, and model name as arguments. It sets the given parameters as the parameters of the Gemini service. The parameters are used to generate content with the Gemini service.
func (*GeminiService) SetupModelOnly ¶ added in v1.0.58
func (service *GeminiService) SetupModelOnly(model string)
func (*GeminiService) SetupSessionCode ¶
func (s *GeminiService) SetupSessionCode(sessionCode string)
SetupSessionCode sets the session code for the Gemini service.
It will filter the histories by the given session code when calling RefreshHistories.
func (*GeminiService) UpdateAgent ¶
func (s *GeminiService) UpdateAgent(id string, agent *models.GeminiAgent) error
UpdateAgent updates the agent in the database.
It takes the ID of the agent and the agent as arguments. It updates the agent in the database with the given ID. If there is an error, it will return an error.
func (*GeminiService) UpdateHistory ¶
func (s *GeminiService) UpdateHistory(id string, history models.GeminiHistoryModel) error
UpdateHistory updates the history in the database.
It takes a history and its ID as arguments. It updates the history in the database with the given ID. If there is an error, it will return an error.
func (*GeminiService) UploadToGemini ¶
func (s *GeminiService) UploadToGemini(path, mimeType string) (string, error)
UploadToGemini uploads a file to Gemini.
It takes a path to a local file and a MIME type as arguments. It will upload the file to Gemini and return a string with the URI of the uploaded file. If there is an error, it will return an empty string and an error.
type GoogleAPIService ¶
type GoogleAPIService struct {
// contains filtered or unexported fields
}
func NewGoogleAPIService ¶
func NewGoogleAPIService(ctx *context.ERPContext, apiKey string) *GoogleAPIService
NewGoogleAPIService creates a new GoogleAPIService with the given ERP context and API key. The context is used to get the logger for logging. The API key is used to make requests to Google Places API.
func (*GoogleAPIService) SearchPlace ¶
func (s *GoogleAPIService) SearchPlace(keyword string) (*PlacesResponse, error)
SearchPlace retrieves a list of places matching the given keyword.
The method takes a keyword as input and returns a slice of Place objects that match the keyword. The results are sorted by relevance, with the most relevant places first.
If the retrieval fails, the method returns an error.
The method uses the Places API to search for places. If the PlacePhoto field is set to true, the method also retrieves the photo of the place. The photo is stored in the PhotoURL field of the Place object.
func (*GoogleAPIService) SearchPlaceByCoordinate ¶
func (s *GoogleAPIService) SearchPlaceByCoordinate(latitude float64, longitude float64, maxResult int, radius float64) (*PlacesResponse, error)
SearchPlaceByCoordinate retrieves a list of places nearby a given coordinate.
The method takes four parameters as input: the latitude and longitude of the coordinate, the maximum number of results to return, and the radius of the search area in meters. It returns a slice of Place objects that are within the specified radius.
The method uses the Places API to search for places. The results are sorted by distance, with the closest places first.
If the retrieval fails, the method returns an error.
func (*GoogleAPIService) SetPlacePhoto ¶
func (s *GoogleAPIService) SetPlacePhoto(placePhoto bool)
SetPlacePhoto sets whether to include a photo of the place in the response from Google Places API. The default is false.
type Place ¶
type Place struct {
ID string `json:"id"`
FormattedAddress string `json:"formattedAddress"`
InternationalPhoneNumber string `json:"internationalPhoneNumber"`
Location Location `json:"location"`
DisplayName struct {
Text string `json:"text"`
} `json:"displayName"`
Photos []Photo `json:"photos"`
PhotoURL string `json:"photoUrl"`
}
type PlacesResponse ¶
type PlacesResponse struct {
Places []Place `json:"places"`
}