Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: split provider and register #743

Merged
merged 9 commits into from
Mar 11, 2024
Merged

refactor: split provider and register #743

merged 9 commits into from
Mar 11, 2024

Conversation

woorui
Copy link
Collaborator

@woorui woorui commented Mar 6, 2024

Description

  1. splitting the original LLMProvider into two interfaces, one for storing registered funcs and another for LLM requesting.
// The storage interface
type Register interface {
	ListToolCalls(md metadata.M) (map[uint32]ai.ToolCall, error)
	RegisterFunction(tag uint32, functionDefinition *ai.FunctionDefinition, connID uint64, md metadata.M) error
	UnregisterFunction(name string, connID uint64)
}

Additionally, provide the register.SetRegister() method to allow modification of the default Register.

// The request interface
type LLMProvider interface {
	// Name returns the name of the llm provider
	Name() string
	GetChatCompletions(prompt string, md metaddata.M) (*ai.InvokeResponse, error)
}
  1. Add the md attribute to the service and inject the md using the ExchangeMetadataFunc method. The signature of the ExchangeMetadataFunc function is as follows:
// ExchangeMetadataFunc is used to exchange metadata
type ExchangeMetadataFunc func(credential string) (metadata.M, error)

// DefaultExchangeMetadataFunc is the default ExchangeMetadataFunc, It returns an empty metadata.
func DefaultExchangeMetadataFunc(credential string) (metadata.M, error) {
	return metadata.M{}, nil
}
  1. Declare the HandleOverview and HandleInvoke methods and mount the service to req.Context().

  2. fix ConnMiddleware function bug in the ai.go file.

Copy link

vercel bot commented Mar 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
yomo ⬜️ Ignored (Inspect) Visit Preview Mar 10, 2024 7:10pm

Copy link

codecov bot commented Mar 6, 2024

Codecov Report

Attention: Patch coverage is 45.00000% with 55 lines in your changes are missing coverage. Please review.

Project coverage is 58.21%. Comparing base (b5317dc) to head (93714e5).
Report is 1 commits behind head on master.

Files Patch % Lines
pkg/bridge/ai/provider/gemini/provider.go 32.35% 23 Missing ⚠️
pkg/bridge/ai/provider/azopenai/provider.go 0.00% 16 Missing ⚠️
pkg/bridge/ai/provider/openai/provider.go 0.00% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #743      +/-   ##
==========================================
- Coverage   59.20%   58.21%   -1.00%     
==========================================
  Files          42       45       +3     
  Lines        3226     3379     +153     
==========================================
+ Hits         1910     1967      +57     
- Misses       1202     1298      +96     
  Partials      114      114              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@woorui woorui self-assigned this Mar 6, 2024
@woorui woorui marked this pull request as ready for review March 10, 2024 19:09
@woorui woorui merged commit 9177893 into master Mar 11, 2024
5 of 7 checks passed
@woorui woorui deleted the refactor/register branch March 11, 2024 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants