Skip to content

Commit 9c69612

Browse files
committed
feat(history): add history to completion
1 parent bc323f1 commit 9c69612

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

cookbook/parea_llm_proxy/deployments/fetching_and_using_parea_deployments.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
from dotenv import load_dotenv
44

5-
from parea import Parea, trace
5+
from parea import Parea
66
from parea.schemas.models import Completion, CompletionResponse, UseDeployedPrompt, UseDeployedPromptResponse
77

88
load_dotenv()
99

1010
p = Parea(api_key=os.getenv("PAREA_API_KEY"))
1111

1212

13-
@trace
1413
def main() -> CompletionResponse:
1514
return p.completion(Completion(deployment_id="p-4cbYJ0LIy0gaWb6Z819k7", llm_inputs={"x": "python", "y": "fastapi"}))
1615

@@ -20,8 +19,7 @@ def get_critic_prompt(val: str) -> UseDeployedPromptResponse:
2019

2120

2221
if __name__ == "__main__":
23-
print(main())
24-
# print(get_critic_prompt("Python"))
22+
print(get_critic_prompt("Python"))
2523
# a = UseDeployedPromptResponse(
2624
# deployment_id="p-87NFVeQg30Hk2Hatw1h72",
2725
# name="deploy-test",

cookbook/parea_llm_proxy/tracing_without_deployed_prompt.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dotenv import load_dotenv
77

88
from parea import Parea, get_current_trace_id, trace
9-
from parea.schemas import Completion, CompletionResponse, LLMInputs, Message, ModelParams, Role
9+
from parea.schemas import Completion, CompletionResponse, FeedbackRequest, LLMInputs, Message, ModelParams, Role
1010

1111
load_dotenv()
1212

@@ -135,31 +135,31 @@ def json_call():
135135
additional_description="Provide a concise, few sentence argument on why coffee is good for you.",
136136
)
137137
print(result1)
138-
#
139-
# result2, trace_id2 = argument_chain2(
140-
# "Whether wine is good for you.",
141-
# additional_description="Provide a concise, few sentence argument on why wine is good for you.",
142-
# )
143-
# print(trace_id2, result2)
144-
# p.record_feedback(
145-
# FeedbackRequest(
146-
# trace_id=trace_id2,
147-
# score=0.7, # 0.0 (bad) to 1.0 (good)
148-
# target="Wine is wonderful.",
149-
# )
150-
# )
151-
#
152-
# result3 = argument_chain3(
153-
# "Whether moonshine is good for you.",
154-
# additional_description="Provide a concise, few sentence argument on why moonshine is good for you.",
155-
# )
156-
# print(result3.content)
157-
# p.record_feedback(
158-
# FeedbackRequest(
159-
# trace_id=result3.inference_id,
160-
# score=0.5, # 0.0 (bad) to 1.0 (good)
161-
# target="Moonshine is wonderful. End of story.",
162-
# )
163-
# )
164-
#
165-
# print(json_call())
138+
139+
result2, trace_id2 = argument_chain2(
140+
"Whether wine is good for you.",
141+
additional_description="Provide a concise, few sentence argument on why wine is good for you.",
142+
)
143+
print(trace_id2, result2)
144+
p.record_feedback(
145+
FeedbackRequest(
146+
trace_id=trace_id2,
147+
score=0.7, # 0.0 (bad) to 1.0 (good)
148+
target="Wine is wonderful.",
149+
)
150+
)
151+
152+
result3 = argument_chain3(
153+
"Whether moonshine is good for you.",
154+
additional_description="Provide a concise, few sentence argument on why moonshine is good for you.",
155+
)
156+
print(result3.content)
157+
p.record_feedback(
158+
FeedbackRequest(
159+
trace_id=result3.inference_id,
160+
score=0.5, # 0.0 (bad) to 1.0 (good)
161+
target="Moonshine is wonderful. End of story.",
162+
)
163+
)
164+
165+
print(json_call())

0 commit comments

Comments
 (0)