is it possible to get agent_name from inside agent...
# ask-ai
t
is it possible to get agent_name from inside agent itself?
t
Thanks for reaching out, sergey. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Yes, it is possible to get the agent name from inside the agent itself. You can access it using the
agentName
accessor property of a
JobRequest
object. This property returns the agent's name as a string, which was set in the
WorkerOptions
when configuring the agent. Here is an example:
Copy code
// Example of accessing the agent name
const agentName = jobRequest.agentName;
Sources: JobRequest | LiveKit Agents
t
how to get jobrequest in python?
t
Hey there! Let me walk you through the
JobRequest
class in the LiveKit Agents Python library. Think of it like a friendly job dispatcher that helps workers manage their assignments. It's pretty neat - you'll use this class to handle incoming jobs and decide whether to jump in or pass. Here's a peek at how it gets set up:
Copy code
def __init__(
    self,
    *,
    job: agent.Job,
    on_reject: Callable[[], Coroutine[None, None, None]],
    on_accept: Callable[[JobAcceptArguments], Coroutine[None, None, None]],
) -> None:
    self._job = job
    self._lock = asyncio.Lock()
    self._on_reject = on_reject
    self._on_accept = on_accept
Most of the time, you'll be working with this inside your worker setup. Curious about how it all comes together? I'm totally happy to chat more and break it down for you! Just ask, and I'll help you make sense of it. Sources: GitHub:: LiveKit Composite Repo | livekit/agents/livekit-agents/livekit/age... | GitHub::LiveKit Agents | livekit-agents/livekit/agents/worker.py
t
Is it available from JobContext?
t
Hey there! I totally understand your confusion about
JobRequest
and
JobContext
in the LiveKit Python library. While I couldn't find a definitive answer right away, I'm here to help. If you can share a bit more about what you're working on, I'll do my best to guide you or connect you with someone who can provide more specific insights. We'll figure this out together!
t
is it possible to get JobRequest from Agent class instance?
t
Hey there! Getting a
JobRequest
from an
Agent
in LiveKit Python is totally doable. Let me break it down for you in a friendly way. It usually happens when you're handling incoming job messages - super straightforward! When a job message comes in, you'll create a
JobRequest
object like this:
Copy code
job_req = JobRequest(job=msg.job, on_reject=_on_reject, on_accept=_on_accept)
Here's what each part means: • `job`: The details of the job from the message • `on_reject`: What happens if the job gets turned down • `on_accept`: What happens when the job is accepted Need me to explain anything else? I'm here to help, so just ask! Sources: GitHub:: LiveKit Composite Repo | livekit/livekit/pkg/agent/client.go | GitHub::LiveKit Agents | livekit-agents/livekit/agents/worker.py