pixie-examples 0.1.1.dev21__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/PKG-INFO +2 -2
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langchain/basic_agent.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langchain/customer_support.py +5 -5
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langchain/personal_assistant.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langchain/sql_agent.py +5 -5
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langgraph/langgraph_rag.py +10 -10
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langgraph/langgraph_sql_agent.py +6 -6
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/openai_agents_sdk/customer_service.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/openai_agents_sdk/financial_research_agent.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/openai_agents_sdk/llm_as_a_judge.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/openai_agents_sdk/routing.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/pydantic_ai/README.md +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/pydantic_ai/bank_support.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/pydantic_ai/flight_booking.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/pydantic_ai/question_graph.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/pydantic_ai/sql_gen.py +4 -4
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/pydantic_ai/structured_output.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/quickstart/chatbot.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/quickstart/problem_solver.py +4 -4
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/quickstart/sleepy_poet.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/quickstart/weather_agent.py +1 -1
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/pyproject.toml +2 -2
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/LICENSE +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/README.md +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/__init__.py +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langchain/README.md +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langchain/__init__.py +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langgraph/__init__.py +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/openai_agents_sdk/README.md +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/openai_agents_sdk/__init__.py +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/pydantic_ai/.env.example +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/pydantic_ai/__init__.py +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/quickstart/__init__.py +0 -0
- {pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/sql_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pixie-examples
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: examples for using Pixie
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -24,7 +24,7 @@ Requires-Dist: openinference-instrumentation-crewai (>=0.1.17,<0.2.0)
|
|
|
24
24
|
Requires-Dist: openinference-instrumentation-dspy (>=0.1.33,<0.2.0)
|
|
25
25
|
Requires-Dist: openinference-instrumentation-google-adk (>=0.1.8,<0.2.0)
|
|
26
26
|
Requires-Dist: openinference-instrumentation-openai-agents (>=1.4.0,<2.0.0)
|
|
27
|
-
Requires-Dist: pixie-sdk (
|
|
27
|
+
Requires-Dist: pixie-sdk (==0.2.3)
|
|
28
28
|
Requires-Dist: pydantic (>=2.7.4,<3.0.0)
|
|
29
29
|
Requires-Dist: pydantic-ai-slim (>=1.39.0,<2.0.0)
|
|
30
30
|
Requires-Dist: pymarkdownlnt (>=0.9.34,<0.10.0)
|
|
@@ -20,7 +20,7 @@ from langfuse.langchain import CallbackHandler
|
|
|
20
20
|
from langchain_core.messages import (
|
|
21
21
|
SystemMessage,
|
|
22
22
|
)
|
|
23
|
-
import pixie
|
|
23
|
+
import pixie.sdk as pixie
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
langfuse_handler = CallbackHandler()
|
|
@@ -93,11 +93,11 @@ def provide_solution(solution: str) -> str:
|
|
|
93
93
|
return f"Solution provided: {solution}"
|
|
94
94
|
|
|
95
95
|
|
|
96
|
-
class
|
|
96
|
+
class IssueClassifierVariables(pixie.Variables):
|
|
97
97
|
warranty_status: Literal["in_warranty", "out_of_warranty"]
|
|
98
98
|
|
|
99
99
|
|
|
100
|
-
class
|
|
100
|
+
class ResolutionSpecialistVariables(IssueClassifierVariables):
|
|
101
101
|
issue_type: Literal["hardware", "software"]
|
|
102
102
|
|
|
103
103
|
|
|
@@ -107,12 +107,12 @@ warranty_collector_prompt = pixie.create_prompt(
|
|
|
107
107
|
)
|
|
108
108
|
issue_classifier_prompt = pixie.create_prompt(
|
|
109
109
|
"issue_classifier_agent",
|
|
110
|
-
|
|
110
|
+
IssueClassifierVariables,
|
|
111
111
|
description="Customer support agent that classifies technical issues as hardware or software",
|
|
112
112
|
)
|
|
113
113
|
resolution_specialist_prompt = pixie.create_prompt(
|
|
114
114
|
"resolution_specialist_agent",
|
|
115
|
-
|
|
115
|
+
ResolutionSpecialistVariables,
|
|
116
116
|
description="Customer support agent that provides resolutions based on issue type and warranty status",
|
|
117
117
|
)
|
|
118
118
|
# Step configuration
|
|
@@ -22,18 +22,18 @@ from langchain.chat_models import init_chat_model
|
|
|
22
22
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
23
23
|
|
|
24
24
|
from langfuse.langchain import CallbackHandler
|
|
25
|
-
import pixie
|
|
25
|
+
import pixie.sdk as pixie
|
|
26
26
|
from ..sql_utils import SQLDatabase, SQLDatabaseToolkit
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
class
|
|
29
|
+
class SqlAgentVariables(pixie.Variables):
|
|
30
30
|
dialect: str
|
|
31
31
|
top_k: int
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
sql_agent_prompt = pixie.create_prompt(
|
|
35
35
|
"langchain_sql_agent",
|
|
36
|
-
|
|
36
|
+
SqlAgentVariables,
|
|
37
37
|
description="SQL agent that interacts with databases and creates queries based on natural language",
|
|
38
38
|
)
|
|
39
39
|
|
|
@@ -86,7 +86,7 @@ async def langchain_sql_query_agent(question: str) -> str:
|
|
|
86
86
|
|
|
87
87
|
# Format system prompt with database info
|
|
88
88
|
system_prompt = sql_agent_prompt.compile(
|
|
89
|
-
|
|
89
|
+
SqlAgentVariables(dialect=db.dialect, top_k=5)
|
|
90
90
|
)
|
|
91
91
|
|
|
92
92
|
# Create agent
|
|
@@ -123,7 +123,7 @@ async def langchain_interactive_sql_agent() -> pixie.PixieGenerator[str, str]:
|
|
|
123
123
|
|
|
124
124
|
# Format system prompt
|
|
125
125
|
system_prompt = sql_agent_prompt.compile(
|
|
126
|
-
|
|
126
|
+
SqlAgentVariables(dialect=db.dialect, top_k=5)
|
|
127
127
|
)
|
|
128
128
|
|
|
129
129
|
# Create agent with checkpointer for conversation memory
|
|
@@ -23,38 +23,38 @@ from langgraph.graph import END, START, MessagesState, StateGraph
|
|
|
23
23
|
from langgraph.prebuilt import ToolNode, tools_condition
|
|
24
24
|
|
|
25
25
|
from langfuse.langchain import CallbackHandler
|
|
26
|
-
import pixie
|
|
26
|
+
import pixie.sdk as pixie
|
|
27
27
|
import requests
|
|
28
28
|
from bs4 import BeautifulSoup
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
class
|
|
31
|
+
class GradeVariables(pixie.Variables):
|
|
32
32
|
context: str
|
|
33
33
|
question: str
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
class
|
|
36
|
+
class RewriteVariables(pixie.Variables):
|
|
37
37
|
question: str
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
class
|
|
40
|
+
class GenerateVariables(pixie.Variables):
|
|
41
41
|
question: str
|
|
42
42
|
context: str
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
rag_grade_prompt = pixie.create_prompt(
|
|
46
46
|
"rag_grade_documents",
|
|
47
|
-
|
|
47
|
+
GradeVariables,
|
|
48
48
|
description="Grades relevance of retrieved documents to user questions",
|
|
49
49
|
)
|
|
50
50
|
rag_rewrite_prompt = pixie.create_prompt(
|
|
51
51
|
"rag_rewrite_question",
|
|
52
|
-
|
|
52
|
+
RewriteVariables,
|
|
53
53
|
description="Rewrites questions to improve semantic understanding",
|
|
54
54
|
)
|
|
55
55
|
rag_generate_prompt = pixie.create_prompt(
|
|
56
56
|
"rag_generate_answer",
|
|
57
|
-
|
|
57
|
+
GenerateVariables,
|
|
58
58
|
description="Generates concise answers from retrieved context",
|
|
59
59
|
)
|
|
60
60
|
|
|
@@ -143,7 +143,7 @@ def create_rag_graph(retriever, model):
|
|
|
143
143
|
context = cast(str, state["messages"][-1].content)
|
|
144
144
|
|
|
145
145
|
prompt = rag_grade_prompt.compile(
|
|
146
|
-
|
|
146
|
+
GradeVariables(question=question, context=context)
|
|
147
147
|
)
|
|
148
148
|
response = grader_model.with_structured_output(GradeDocuments).invoke(
|
|
149
149
|
[{"role": "user", "content": prompt}],
|
|
@@ -161,7 +161,7 @@ def create_rag_graph(retriever, model):
|
|
|
161
161
|
"""Rewrite the original user question."""
|
|
162
162
|
messages = state["messages"]
|
|
163
163
|
question = cast(str, messages[0].content)
|
|
164
|
-
prompt = rag_rewrite_prompt.compile(
|
|
164
|
+
prompt = rag_rewrite_prompt.compile(RewriteVariables(question=question))
|
|
165
165
|
response = model.invoke(
|
|
166
166
|
[{"role": "user", "content": prompt}],
|
|
167
167
|
config={"callbacks": [langfuse_handler]},
|
|
@@ -174,7 +174,7 @@ def create_rag_graph(retriever, model):
|
|
|
174
174
|
question = cast(str, state["messages"][0].content)
|
|
175
175
|
context = cast(str, state["messages"][-1].content)
|
|
176
176
|
prompt = rag_generate_prompt.compile(
|
|
177
|
-
|
|
177
|
+
GenerateVariables(question=question, context=context)
|
|
178
178
|
)
|
|
179
179
|
response = model.invoke(
|
|
180
180
|
[{"role": "user", "content": prompt}],
|
{pixie_examples-0.1.1.dev21 → pixie_examples-0.2.3}/examples/langgraph/langgraph_sql_agent.py
RENAMED
|
@@ -19,21 +19,21 @@ from langgraph.prebuilt import ToolNode
|
|
|
19
19
|
from langgraph.checkpoint.memory import InMemorySaver
|
|
20
20
|
|
|
21
21
|
from langfuse.langchain import CallbackHandler
|
|
22
|
-
import pixie
|
|
22
|
+
import pixie.sdk as pixie
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
class
|
|
25
|
+
class LanggraphSqlVariables(pixie.Variables):
|
|
26
26
|
dialect: str
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
langgraph_sql_generate_prompt = pixie.create_prompt(
|
|
30
30
|
"langgraph_sql_generate_query",
|
|
31
|
-
|
|
31
|
+
LanggraphSqlVariables,
|
|
32
32
|
description="Generates SQL queries from natural language questions",
|
|
33
33
|
)
|
|
34
34
|
langgraph_sql_check_prompt = pixie.create_prompt(
|
|
35
35
|
"langgraph_sql_check_query",
|
|
36
|
-
|
|
36
|
+
LanggraphSqlVariables,
|
|
37
37
|
description="Reviews and validates SQL queries for common mistakes",
|
|
38
38
|
)
|
|
39
39
|
|
|
@@ -101,7 +101,7 @@ def create_sql_graph(db: SQLDatabase, model):
|
|
|
101
101
|
# Node: Generate query
|
|
102
102
|
def generate_query(state: MessagesState):
|
|
103
103
|
generate_query_prompt_text = langgraph_sql_generate_prompt.compile(
|
|
104
|
-
|
|
104
|
+
LanggraphSqlVariables(dialect=db.dialect)
|
|
105
105
|
)
|
|
106
106
|
system_message = {"role": "system", "content": generate_query_prompt_text}
|
|
107
107
|
llm_with_tools = model.bind_tools([run_query_tool])
|
|
@@ -116,7 +116,7 @@ def create_sql_graph(db: SQLDatabase, model):
|
|
|
116
116
|
from langchain.messages import AIMessage as AI
|
|
117
117
|
|
|
118
118
|
check_query_prompt_text = langgraph_sql_check_prompt.compile(
|
|
119
|
-
|
|
119
|
+
LanggraphSqlVariables(dialect=db.dialect)
|
|
120
120
|
)
|
|
121
121
|
system_message = {"role": "system", "content": check_query_prompt_text}
|
|
122
122
|
last_message = state["messages"][-1]
|
|
@@ -13,7 +13,7 @@ from __future__ import annotations
|
|
|
13
13
|
|
|
14
14
|
from openai.types.responses import ResponseContentPartDoneEvent, ResponseTextDeltaEvent
|
|
15
15
|
from agents import Agent, RawResponsesStreamEvent, Runner, TResponseInputItem
|
|
16
|
-
import pixie
|
|
16
|
+
import pixie.sdk as pixie
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
french_agent_prompt = pixie.create_prompt(
|
|
@@ -231,7 +231,7 @@ subscription {
|
|
|
231
231
|
All examples use:
|
|
232
232
|
|
|
233
233
|
```python
|
|
234
|
-
from pixie import app, PixieGenerator, UserInputRequirement
|
|
234
|
+
from pixie.sdk import app, PixieGenerator, UserInputRequirement
|
|
235
235
|
|
|
236
236
|
@app
|
|
237
237
|
async def my_handler(input: InputType) -> OutputType:
|
|
@@ -10,10 +10,10 @@ from typing import Annotated, TypeAlias
|
|
|
10
10
|
from annotated_types import MinLen
|
|
11
11
|
from pydantic import BaseModel, Field
|
|
12
12
|
from pydantic_ai import Agent, ModelRetry, RunContext, format_as_xml
|
|
13
|
-
import pixie
|
|
13
|
+
import pixie.sdk as pixie
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
class
|
|
16
|
+
class SqlGenVariables(pixie.Variables):
|
|
17
17
|
db_schema: str
|
|
18
18
|
today_date: str
|
|
19
19
|
sql_examples: str
|
|
@@ -21,7 +21,7 @@ class SqlGenPromptVariables(pixie.PromptVariables):
|
|
|
21
21
|
|
|
22
22
|
sql_gen_agent_prompt = pixie.create_prompt(
|
|
23
23
|
"sql_gen_agent",
|
|
24
|
-
|
|
24
|
+
SqlGenVariables,
|
|
25
25
|
description="Generates SQL queries from natural language for PostgreSQL databases",
|
|
26
26
|
)
|
|
27
27
|
|
|
@@ -102,7 +102,7 @@ agent = Agent[Deps, Response](
|
|
|
102
102
|
@agent.system_prompt
|
|
103
103
|
async def system_prompt() -> str:
|
|
104
104
|
return sql_gen_agent_prompt.compile(
|
|
105
|
-
|
|
105
|
+
SqlGenVariables(
|
|
106
106
|
db_schema=DB_SCHEMA,
|
|
107
107
|
today_date=str(date.today()),
|
|
108
108
|
sql_examples=format_as_xml(SQL_EXAMPLES),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from pydantic import Field
|
|
2
2
|
from pydantic_ai import Agent
|
|
3
3
|
|
|
4
|
-
import pixie
|
|
4
|
+
import pixie.sdk as pixie
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
class
|
|
7
|
+
class Variables(pixie.Variables):
|
|
8
8
|
problem_description: str = Field(
|
|
9
9
|
..., description="A description of the problem to be solved."
|
|
10
10
|
)
|
|
@@ -12,7 +12,7 @@ class PromptVariables(pixie.PromptVariables):
|
|
|
12
12
|
|
|
13
13
|
agent_prompt = pixie.create_prompt(
|
|
14
14
|
"problem_solver",
|
|
15
|
-
|
|
15
|
+
Variables,
|
|
16
16
|
description="Problem solving agent that thinks step by step",
|
|
17
17
|
)
|
|
18
18
|
|
|
@@ -30,7 +30,7 @@ async def example_problem_solver(problem_description: str):
|
|
|
30
30
|
agent = Agent(
|
|
31
31
|
name=agent_prompt.id,
|
|
32
32
|
instructions=agent_prompt.compile(
|
|
33
|
-
|
|
33
|
+
Variables(problem_description=problem_description)
|
|
34
34
|
),
|
|
35
35
|
model="gpt-4o-mini",
|
|
36
36
|
)
|
|
@@ -4,7 +4,7 @@ packages = [
|
|
|
4
4
|
{ include = "examples" }
|
|
5
5
|
]
|
|
6
6
|
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.2.3" # Managed by setuptools-scm
|
|
8
8
|
description = "examples for using Pixie"
|
|
9
9
|
authors = ["Yiou Li <yol@gopixie.ai>"]
|
|
10
10
|
license = "MIT"
|
|
@@ -21,7 +21,7 @@ Changelog = "https://github.com/yiouli/pixie-examples/commits/main/"
|
|
|
21
21
|
python = ">=3.11,<3.14"
|
|
22
22
|
pydantic-ai-slim = "^1.39.0"
|
|
23
23
|
pydantic = {version = "^2.7.4", extras = []}
|
|
24
|
-
pixie-sdk = "
|
|
24
|
+
pixie-sdk = "0.2.3"
|
|
25
25
|
openai-agents = "^0.6.5"
|
|
26
26
|
pymarkdownlnt = "^0.9.34"
|
|
27
27
|
langchain = "^1.2.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|