session: expose Agent() accessor, add methods to Agent struct
- Session.Agent() returns the active *Agent - Agent.Name(), Agent.BackendName(), Agent.ModelName() — first-class - Session proxy methods delegate to Agent Consumers can now access the agent directly: sess.Agent().Name() sess.Agent().BackendName()
This commit is contained in:
parent
d9920b42c7
commit
1b35862f1a
|
|
@ -28,9 +28,28 @@ type Agent struct {
|
|||
}
|
||||
|
||||
// Backend returns the active backend from the runtime.
|
||||
func (r *Agent) Backend() backend.Backend {
|
||||
if r.runtime == nil {
|
||||
func (ag *Agent) Backend() backend.Backend {
|
||||
if ag.runtime == nil {
|
||||
return nil
|
||||
}
|
||||
return r.runtime.Backend
|
||||
return ag.runtime.Backend
|
||||
}
|
||||
|
||||
// Name returns the agent's name.
|
||||
func (ag *Agent) Name() string { return ag.agentName }
|
||||
|
||||
// BackendName returns the name of the active backend.
|
||||
func (ag *Agent) BackendName() string {
|
||||
if ag.runtime == nil || ag.runtime.Backend == nil {
|
||||
return ""
|
||||
}
|
||||
return ag.runtime.Backend.Name()
|
||||
}
|
||||
|
||||
// ModelName returns the name of the active model.
|
||||
func (ag *Agent) ModelName() string {
|
||||
if ag.runtime == nil || ag.runtime.Backend == nil {
|
||||
return ""
|
||||
}
|
||||
return ag.runtime.Backend.Model()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -703,21 +703,24 @@ func (a *Session) ReactTo(responseID, emoji string) error {
|
|||
}
|
||||
|
||||
func (a *Session) AgentName() string {
|
||||
v := a.r.agentName
|
||||
v := a.r.Name()
|
||||
a.log.Debug("AgentName() = %q", v)
|
||||
return v
|
||||
}
|
||||
func (a *Session) BackendName() string {
|
||||
v := a.r.runtime.Backend.Name()
|
||||
v := a.r.BackendName()
|
||||
a.log.Debug("BackendName() = %q", v)
|
||||
return v
|
||||
}
|
||||
func (a *Session) ModelName() string {
|
||||
v := a.r.runtime.Backend.Model()
|
||||
v := a.r.ModelName()
|
||||
a.log.Debug("ModelName() = %q", v)
|
||||
return v
|
||||
}
|
||||
|
||||
// Agent returns the active agent.
|
||||
func (a *Session) Agent() *Agent { return a.r }
|
||||
|
||||
func (a *Session) State() string {
|
||||
return a.state
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue