You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from crewai import Agent,Crew,Task,LLM,Process
from mem0 import MemoryClient
import os
import opik
from opik.integrations.crewai import track_crewai
from opik import track
import os, litellm
from litellm.integrations.opik.opik import OpikLogger
#
opik.configure(use_local=False)
track_crewai(project_name="Book-recommendation")
litellm.callbacks = [OpikLogger()]
os.environ["OPIK_API_KEY"] = "ciUaT........."
os.environ["OPIK_WORKSPACE"] = "......"
llm = LLM(
model="groq/llama-3.3-70b-versatile",
temperature=0.7
)
@opik.track
def get_recommendation(user_id: str, user_preferences: str) -> str:
recommendation_agent = Agent(
role="Book Recommendation",
backstory="Ai-powered book advisor who suggests books based on user preferences",
goal="Provide personalised book recommendations.",
llm=llm,
verbose=True,
)
suggest_book_task = Task(
description=f"Suggest three personalised book recommendations based on user preferences: {user_preferences}.",
expected_output="A list of three book titles with brief description",
agent=recommendation_agent
)
crew = Crew(
agents=[recommendation_agent],
tasks=[suggest_book_task],
verbose=True,
process=Process.sequential,
memory=True,
memory_config={
"provider": "mem0",
"config": {"user_id": user_id,
"api_key": os.getenv("MEM0_API_KEY"),
"llm": {
"provider": "groq",
"config": {
"model": "mixtral-8x7b-32768",
"temperature": 0.1,
"max_tokens": 2000,
}
}
},
}
)
result = crew.kickoff()
print("Final Recommendation:")
print(result.raw)
return result.raw
@opik.track
def store_user_recommendation(client: MemoryClient, user_id: str, conversation: list):
client.add(conversation, user_id=user_id)
user_id = "Ram"
user_preferences = "Science Fiction"
#1948 result = get_recommendation(user_id, user_preferences)
execution log
OPIK: You are attempting to log data into a nested span under the project name "Book-recommendation". However, the project name "Default Project" from parent span will be used instead.
╭──────────────────────────────────────────── Crew Execution Started ─────────────────────────────────────────────╮
│ │
│ Crew Execution Started │
│ Name: crew │
│ ID: 0885b3d8-adee-4e96-a3c0-704db9badadf │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
OPIK: You are attempting to log data into a nested span under the project name "Book-recommendation". However, the project name "Default Project" from parent span will be used instead.
🚀 Crew: crew
└── 📋 Task: b7b9170d-5962-4376-b76f-0aea6b6f1c90
Status: Executing Task...
OPIK: You are attempting to log data into a nested span under the project name "Book-recommendation". However, the project name "Default Project" from parent span will be used instead.
🚀 Crew: crew
└── 📋 Task: b7b9170d-5962-4376-b76f-0aea6b6f1c90
Status: Executing Task...
└── 🤖 Agent: Book Recommendation
Status: In Progress
OPIK: You are attempting to log data into a nested span under the project name "Book-recommendation". However, the project name "Default Project" from parent span will be used instead.
# Agent: Book Recommendation
## Task: Suggest three personalised book recommendations based on user preferences: Science Fiction.
# Agent: Book Recommendation
## Final Answer:
1. **Dune** by Frank Herbert: This classic science fiction novel is set in a distant future where humans have colonized other planets. The story follows Paul Atreides, a young man with unique abilities, as he becomes the leader of a rebellion in a desert planet called Arrakis, which is the only source of a rare and valuable substance called melange. With its complex characters, intricate plot, and detailed world-building, Dune is a must-read for any science fiction fan.
2. **The Three-Body Problem** by Liu Cixin: This award-winning novel explores the first contact between humans and an alien civilization. The story begins during China's Cultural Revolution and follows a scientist who makes contact with an alien civilization from a planetary system with three suns, which creates chaotic and unpredictable environmental conditions. The novel explores the complexities of communication and cooperation between humans and aliens, and it offers a unique perspective on science fiction from a non-Western culture.
3. **Ancillary Justice** by Ann Leckie: This thought-provoking novel follows an AI who was once a ship's AI and has now taken over a human body. The AI, who calls herself Breq, seeks revenge against the ruler who destroyed her ship and crew. As Breq navigates the complexities of human society, the novel explores themes of identity, power, and justice. With its unique protagonist and thought-provoking themes, Ancillary Justice is a great choice for readers who enjoy character-driven science fiction.
OPIK: You are attempting to log data into a nested span under the project name "Book-recommendation". However, the project name "Default Project" from parent span will be used instead.
[c:\Users\PLNAYAK\Documents\agentic_setup_crewai\.venv\Lib\site-packages\httpx\_content.py:204](file:///C:/Users/PLNAYAK/Documents/agentic_setup_crewai/.venv/Lib/site-packages/httpx/_content.py:204): DeprecationWarning: Use 'content=<...>' to upload raw bytes/text content.
warnings.warn(message, DeprecationWarning)
OPIK: Failed to process CreateSpansBatchMessage. Error: status_code: 401, body: {'code': 401, 'message': 'API key should be provided'}
OPIK: Failed to process CreateSpansBatchMessage. Error: status_code: 401, body: {'code': 401, 'message': 'API key should be provided'}
🚀 Crew: crew
└── 📋 Task: b7b9170d-5962-4376-b76f-0aea6b6f1c90
Status: Executing Task...
└── 🤖 Agent: Book Recommendation
Status: ✅ Completed
🚀 Crew: crew
└── 📋 Task: b7b9170d-5962-4376-b76f-0aea6b6f1c90
Assigned to: Book Recommendation
Status: ✅ Completed
└── 🤖 Agent: Book Recommendation
Status: ✅ Completed
╭──────────────────────────────────────────────── Task Completion ────────────────────────────────────────────────╮
│ │
│ Task Completed │
│ Name: b7b9170d-5962-4376-b76f-0aea6b6f1c90 │
│ Agent: Book Recommendation │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭──────────────────────────────────────────────── Crew Completion ────────────────────────────────────────────────╮
│ │
│ Crew Execution Completed │
│ Name: crew │
│ ID: 0885b3d8-adee-4e96-a3c0-704db9badadf │
│ │
│ │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Final Recommendation:
1. **Dune** by Frank Herbert: This classic science fiction novel is set in a distant future where humans have colonized other planets. The story follows Paul Atreides, a young man with unique abilities, as he becomes the leader of a rebellion in a desert planet called Arrakis, which is the only source of a rare and valuable substance called melange. With its complex characters, intricate plot, and detailed world-building, Dune is a must-read for any science fiction fan.
2. **The Three-Body Problem** by Liu Cixin: This award-winning novel explores the first contact between humans and an alien civilization. The story begins during China's Cultural Revolution and follows a scientist who makes contact with an alien civilization from a planetary system with three suns, which creates chaotic and unpredictable environmental conditions. The novel explores the complexities of communication and cooperation between humans and aliens, and it offers a unique perspective on science fiction from a non-Western culture.
3. **Ancillary Justice** by Ann Leckie: This thought-provoking novel follows an AI who was once a ship's AI and has now taken over a human body. The AI, who calls herself Breq, seeks revenge against the ruler who destroyed her ship and crew. As Breq navigates the complexities of human society, the novel explores themes of identity, power, and justice. With its unique protagonist and thought-provoking themes, Ancillary Justice is a great choice for readers who enjoy character-driven science fiction.
OPIK: Failed to process CreateSpansBatchMessage. Error: status_code: 401, body: {'code': 401, 'message': 'API key should be provided'}
OPIK: Failed to process CreateTraceBatchMessage. Error: status_code: 401, body: {'code': 401, 'message': 'API key should be provided'}
PIK: Failed to process CreateSpansBatchMessage. Error: status_code: 401, body: {'code': 401, 'message': 'API key should be provided'}
CAN YOU PLEASE ADVISE HOW to RESOLEV THE ISSUE .
The text was updated successfully, but these errors were encountered:
Hi @plaban1981, could you run comet healthcheck and paste the output? This will allows us to diagnose your configuration. In addition, can you confirm that you are trying to log data to www.comet.com?
Code
execution log
PIK: Failed to process CreateSpansBatchMessage. Error: status_code: 401, body: {'code': 401, 'message': 'API key should be provided'}
CAN YOU PLEASE ADVISE HOW to RESOLEV THE ISSUE .
The text was updated successfully, but these errors were encountered: