Skip to content

Commit

Permalink
Merge pull request #885 from parea-ai/PAI-1151-auto-trace-marvin
Browse files Browse the repository at this point in the history
feat: auto trace marvin
  • Loading branch information
joschkabraun committed May 18, 2024
2 parents 05a6197 + f93d53b commit 7f4caf0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions parea/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ def auto_trace_openai_clients(self, integration: Optional[str]) -> None:
if integration:
self._client.add_integration(integration)

if integration == "marvin":
import marvin

marvin.utilities.openai.Client = patch_openai_client_classes(marvin.utilities.openai.Client, self)
marvin.utilities.openai.AsyncClient = patch_openai_client_classes(marvin.utilities.openai.AsyncClient, self)
marvin.utilities.openai.AzureOpenAI = patch_openai_client_classes(marvin.utilities.openai.AzureOpenAI, self)
marvin.utilities.openai.AsyncAzureOpenAI = patch_openai_client_classes(marvin.utilities.openai.AsyncAzureOpenAI, self)

def trace_dspy(self):
from parea.utils.trace_integrations.dspy import DSPyInstrumentor

Expand Down
21 changes: 21 additions & 0 deletions parea/cookbook/trace_marvin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os

import marvin
from dotenv import load_dotenv
from pydantic import BaseModel, Field

from parea import Parea

load_dotenv()

p = Parea(api_key=os.getenv("PAREA_API_KEY"))
p.auto_trace_openai_clients("marvin")


class Location(BaseModel):
city: str
state: str = Field(description="2-letter abbreviation")


result = marvin.cast("the big apple", Location)
print(result)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "parea-ai"
packages = [{ include = "parea" }]
version = "0.2.155"
version = "0.2.156"
description = "Parea python sdk"
readme = "README.md"
authors = ["joel-parea-ai <[email protected]>"]
Expand Down

0 comments on commit 7f4caf0

Please sign in to comment.