How to Create a Julep Session and Chat with an Agent
This guide will walk you through the process of creating an agent, setting up a session, and engaging in a conversation using the Julep SDKs.
This guide is minimalistic and designed to quickly set you up to chat with the agent. It does not cover all the features that Julep agents and sessions provide. For more advanced usage, please check out the Agents and Sessions concepts.
Create an agent with specific instructions and a model. This agent will be used in the session.
# Create an agentagent = julep.agents.create( name="Chat Buddy", about="A friendly and helpful chatbot", instructions=["Be friendly and engaging.","Be helpful and provide useful information.","Be concise and to the point.","Do not format your responses. Keep them as plain text.",], model="gpt-4o-mini",)
Send a message with a user role to the session to trigger the agent to send a response.
# Chat with the agentresponse = julep.sessions.chat( session_id=session.id, messages=[{"role":"user","content":"Hi there! What are some fun hobbies to try out?"}])print("Agent's Response:")print(response.choices[0].message.content)
from julep import Julep# Initialize the Julep clientjulep = Julep(api_key="your_api_key")# Create an agentagent = julep.agents.create( name="Chat Buddy", about="A friendly and helpful chatbot", instructions=["Be friendly and engaging.","Be helpful and provide useful information.","Be concise and to the point.","Do not format your responses. Keep them as plain text.",], model="gpt-4o-mini",)# Create a sessionsession = julep.sessions.create( agent=agent.id, situation="User wants to have a casual chat about hobbies.",)# Chat with the agentresponse = julep.sessions.chat( session_id=session.id, messages=[{"role":"user","content":"Hi there! What are some fun hobbies to try out?"}])
By following these steps, you can create an agent, set up a session, and quickly engage in a conversation using the Julep SDKs. This setup allows for personalized and context-aware interactions with the agent. For more advanced usage, donβt forget to check out the Agents and Sessions concepts.