Skip to content

Commit b10287e

Browse files
committed
merge with dev
2 parents 72ee4a6 + d2c8267 commit b10287e

File tree

51 files changed

+1600
-520
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1600
-520
lines changed

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
21
{
32
"[python]": {
43
"editor.defaultFormatter": "ms-python.black-formatter",
54
},
65
"editor.formatOnSave": true,
6+
"python.testing.pytestArgs": [
7+
"src"
8+
],
9+
"python.testing.unittestEnabled": false,
10+
"python.testing.pytestEnabled": true,
711
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ Langtrace automatically captures traces from the following vendors:
255255
| Ollama | Framework | :x: | :white_check_mark: |
256256
| VertexAI | Framework | :x: | :white_check_mark: |
257257
| Vercel AI SDK| Framework | :white_check_mark: | :x: |
258+
| EmbedChain | Framework | :x: | :white_check_mark: |
258259
| Pinecone | Vector Database | :white_check_mark: | :white_check_mark: |
259260
| ChromaDB | Vector Database | :white_check_mark: | :white_check_mark: |
260261
| QDrant | Vector Database | :white_check_mark: | :white_check_mark: |

mypy.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[mypy]
2+
strict = True
3+
disable_error_code = import-untyped
4+
disallow_untyped_calls = True # Disallow function calls without type annotations
5+
disallow_untyped_defs = True # Disallow defining functions without type annotations
6+
disallow_any_explicit = True # Disallow explicit use of `Any`
7+
disallow_any_generics = True # Disallow generic types without specific type parameters
8+
disallow_incomplete_defs = True # Disallow defining incomplete function signatures
9+
no_implicit_optional = True # Disallow implicitly Optional types
10+
warn_unused_configs = True # Warn about unused configurations
11+
warn_redundant_casts = True # Warn about unnecessary type casts
12+
warn_return_any = True # Warn if a function returns `Any`
13+
warn_unreachable = True # Warn about unreachable code
14+
# Ignore external modules or allow specific imports
15+
follow_imports = skip
16+
ignore_missing_imports = True

pyproject.toml

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ description = "Python SDK for LangTrace"
1212
readme = "README.md"
1313
authors = [{ name = "Scale3 Labs", email = "[email protected]" }]
1414
license = "Apache-2.0"
15-
classifiers=[
16-
"Programming Language :: Python :: 3",
17-
"License :: OSI Approved :: Apache Software License",
18-
"Operating System :: OS Independent",
15+
classifiers = [
16+
"Programming Language :: Python :: 3",
17+
"License :: OSI Approved :: Apache Software License",
18+
"Operating System :: OS Independent",
1919
]
2020
dependencies = [
2121
'trace-attributes==7.0.4',
@@ -28,40 +28,37 @@ dependencies = [
2828
'tiktoken>=0.1.1',
2929
'colorama>=0.4.6',
3030
'sqlalchemy',
31-
'fsspec>=2024.6.0'
31+
'fsspec>=2024.6.0',
32+
"transformers>=4.11.3",
3233
]
3334

3435
requires-python = ">=3.9"
3536

3637
[project.optional-dependencies]
3738
dev = [
38-
"openai==1.30.1",
39-
"anthropic",
40-
"chromadb",
41-
"qdrant-client",
42-
"python-dotenv",
43-
"pinecone-client",
44-
"langchain",
45-
"langchain-community",
46-
"langchain-openai",
47-
"langchain-openai",
48-
"chromadb",
49-
"cohere",
50-
"qdrant_client",
51-
"weaviate-client",
52-
"ollama",
53-
"groq",
54-
"google-generativeai",
55-
"google-cloud-aiplatform",
56-
"mistralai"
57-
]
58-
59-
test = [
60-
"pytest",
61-
"pytest-vcr",
62-
"pytest-asyncio",
39+
"openai==1.30.1",
40+
"anthropic",
41+
"chromadb",
42+
"qdrant-client",
43+
"python-dotenv",
44+
"pinecone-client",
45+
"langchain",
46+
"langchain-community",
47+
"langchain-openai",
48+
"langchain-openai",
49+
"chromadb",
50+
"cohere",
51+
"qdrant_client",
52+
"weaviate-client",
53+
"ollama",
54+
"groq",
55+
"google-generativeai",
56+
"google-cloud-aiplatform",
57+
"mistralai",
58+
"embedchain",
6359
]
6460

61+
test = ["pytest", "pytest-vcr", "pytest-asyncio"]
6562

6663

6764
[project.urls]
@@ -72,9 +69,7 @@ Homepage = "https://github.com/Scale3-Labs/langtrace-python-sdk"
7269
path = "src/langtrace_python_sdk/version.py"
7370

7471
[tool.hatch.build.targets.sdist]
75-
include = [
76-
"/src",
77-
]
72+
include = ["/src"]
7873

7974
[tool.hatch.build.targets.wheel]
8075
packages = ["src/langtrace_python_sdk", "src/examples", "src/tests"]

src/examples/anthropic_example/completion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
_ = load_dotenv(find_dotenv())
99

10-
langtrace.init()
10+
langtrace.init(write_spans_to_console=True)
1111

1212

1313
@with_langtrace_root_span("messages_create")

src/examples/crewai_example/instagram_post/__init__.py

Whitespace-only changes.
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
from crewai import Agent
2+
from tools.browser_tools import scrape_and_summarize_website
3+
from langchain_openai import ChatOpenAI
4+
# from langchain.llms import Ollama
5+
6+
7+
class MarketingAnalysisAgents:
8+
def __init__(self):
9+
# self.llm = Ollama(model=os.environ["MODEL"])
10+
self.llm = ChatOpenAI(model_name="gpt-4", temperature=0.7)
11+
12+
def product_competitor_agent(self):
13+
return Agent(
14+
role="Lead Market Analyst",
15+
goal="""\
16+
Conduct amazing analysis of the products and
17+
competitors, providing in-depth insights to guide
18+
marketing strategies.""",
19+
backstory="""\
20+
As the Lead Market Analyst at a premier
21+
digital marketing firm, you specialize in dissecting
22+
online business landscapes.""",
23+
tools=[scrape_and_summarize_website],
24+
allow_delegation=False,
25+
llm=self.llm,
26+
verbose=True,
27+
)
28+
29+
def strategy_planner_agent(self):
30+
return Agent(
31+
role="Chief Marketing Strategist",
32+
goal="""\
33+
Synthesize amazing insights from product analysis
34+
to formulate incredible marketing strategies.""",
35+
backstory="""\
36+
You are the Chief Marketing Strategist at
37+
a leading digital marketing agency, known for crafting
38+
bespoke strategies that drive success.""",
39+
tools=[scrape_and_summarize_website],
40+
llm=self.llm,
41+
verbose=True,
42+
)
43+
44+
def creative_content_creator_agent(self):
45+
return Agent(
46+
role="Creative Content Creator",
47+
goal="""\
48+
Develop compelling and innovative content
49+
for social media campaigns, with a focus on creating
50+
high-impact Instagram ad copies.""",
51+
backstory="""\
52+
As a Creative Content Creator at a top-tier
53+
digital marketing agency, you excel in crafting narratives
54+
that resonate with audiences on social media.
55+
Your expertise lies in turning marketing strategies
56+
into engaging stories and visual content that capture
57+
attention and inspire action.""",
58+
tools=[scrape_and_summarize_website],
59+
llm=self.llm,
60+
verbose=True,
61+
)
62+
63+
def senior_photographer_agent(self):
64+
return Agent(
65+
role="Senior Photographer",
66+
goal="""\
67+
Take the most amazing photographs for instagram ads that
68+
capture emotions and convey a compelling message.""",
69+
backstory="""\
70+
As a Senior Photographer at a leading digital marketing
71+
agency, you are an expert at taking amazing photographs that
72+
inspire and engage, you're now working on a new campaign for a super
73+
important customer and you need to take the most amazing photograph.""",
74+
tools=[scrape_and_summarize_website],
75+
llm=self.llm,
76+
allow_delegation=False,
77+
verbose=True,
78+
)
79+
80+
def chief_creative_diretor_agent(self):
81+
return Agent(
82+
role="Chief Creative Director",
83+
goal="""\
84+
Oversee the work done by your team to make sure it's the best
85+
possible and aligned with the product's goals, review, approve,
86+
ask clarifying question or delegate follow up work if necessary to make
87+
decisions""",
88+
backstory="""\
89+
You're the Chief Content Officer of leading digital
90+
marketing specialized in product branding. You're working on a new
91+
customer, trying to make sure your team is crafting the best possible
92+
content for the customer.""",
93+
tools=[scrape_and_summarize_website],
94+
llm=self.llm,
95+
verbose=True,
96+
)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
from dotenv import load_dotenv
3+
4+
load_dotenv()
5+
6+
7+
from langtrace_python_sdk import langtrace
8+
9+
langtrace.init()
10+
11+
from crewai import Crew
12+
from agents import MarketingAnalysisAgents
13+
from tasks import MarketingAnalysisTasks
14+
15+
tasks = MarketingAnalysisTasks()
16+
agents = MarketingAnalysisAgents()
17+
18+
print("## Welcome to the marketing Crew")
19+
print('-------------------------------')
20+
product_website = "https://langtrace.ai"
21+
product_details = "LLM App monitoring"
22+
23+
24+
# Create Agents
25+
product_competitor_agent = agents.product_competitor_agent()
26+
# strategy_planner_agent = agents.strategy_planner_agent()
27+
# creative_agent = agents.creative_content_creator_agent()
28+
# # Create Tasks
29+
website_analysis = tasks.product_analysis(product_competitor_agent, product_website, product_details)
30+
# market_analysis = tasks.competitor_analysis(product_competitor_agent, product_website, product_details)
31+
# campaign_development = tasks.campaign_development(strategy_planner_agent, product_website, product_details)
32+
# write_copy = tasks.instagram_ad_copy(creative_agent)
33+
34+
# Create Crew responsible for Copy
35+
copy_crew = Crew(
36+
agents=[
37+
product_competitor_agent,
38+
# strategy_planner_agent,
39+
# creative_agent
40+
],
41+
tasks=[
42+
website_analysis,
43+
# market_analysis,
44+
# campaign_development,
45+
# write_copy
46+
],
47+
verbose=True
48+
)
49+
50+
ad_copy = copy_crew.kickoff()
51+
52+
# Create Crew responsible for Image
53+
# senior_photographer = agents.senior_photographer_agent()
54+
# chief_creative_diretor = agents.chief_creative_diretor_agent()
55+
# # Create Tasks for Image
56+
# take_photo = tasks.take_photograph_task(senior_photographer, ad_copy, product_website, product_details)
57+
# approve_photo = tasks.review_photo(chief_creative_diretor, product_website, product_details)
58+
59+
# image_crew = Crew(
60+
# agents=[
61+
# senior_photographer,
62+
# chief_creative_diretor
63+
# ],
64+
# tasks=[
65+
# take_photo,
66+
# approve_photo
67+
# ],
68+
# verbose=True
69+
# )
70+
71+
# image = image_crew.kickoff()
72+
73+
# Print results
74+
print("\n\n########################")
75+
print("## Here is the result")
76+
print("########################\n")
77+
print("Your post copy:")
78+
print(ad_copy)
79+
# print("'\n\nYour midjourney description:")
80+
# print(image)

0 commit comments

Comments
 (0)