Skip to content

Commit 83a67fe

Browse files
authored
Merge pull request #730 from parea-ai/PAI-991-new-gpt-models-py-sdk
fix(openai): support new model in costs
2 parents fbf500e + cdcfce9 commit 83a67fe

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

parea/constants.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def str2bool(v):
105105
"completion": 60.0,
106106
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
107107
},
108+
"gpt-4-1106-vision-preview": {
109+
"prompt": 30.0,
110+
"completion": 60.0,
111+
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
112+
},
108113
"gpt-4-turbo-preview": {
109114
"prompt": 10.0,
110115
"completion": 30.0,
@@ -120,6 +125,16 @@ def str2bool(v):
120125
"completion": 30.0,
121126
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
122127
},
128+
"gpt-4-turbo": {
129+
"prompt": 10.0,
130+
"completion": 30.0,
131+
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
132+
},
133+
"gpt-4-turbo-2024-04-09": {
134+
"prompt": 10.0,
135+
"completion": 30.0,
136+
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
137+
},
123138
}
124139
AZURE_MODEL_INFO: Dict[str, Dict[str, Union[float, int, Dict[str, int]]]] = {
125140
"gpt-35-turbo": {
@@ -192,11 +207,26 @@ def str2bool(v):
192207
"completion": 30.0,
193208
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
194209
},
210+
"gpt-4-1106-vision-preview": {
211+
"prompt": 30.0,
212+
"completion": 60.0,
213+
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
214+
},
195215
"gpt-35-turbo-instruct": {
196216
"prompt": 10.0,
197217
"completion": 30.0,
198218
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
199219
},
220+
"gpt-4-turbo": {
221+
"prompt": 10.0,
222+
"completion": 30.0,
223+
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
224+
},
225+
"gpt-4-turbo-2024-04-09": {
226+
"prompt": 10.0,
227+
"completion": 30.0,
228+
"token_limit": {"max_completion_tokens": 4096, "max_prompt_tokens": 128000},
229+
},
200230
}
201231

202232
instant_pricing = {"prompt": 1.63, "completion": 5.51}

parea/cookbook/tracing_with_open_ai_endpoint_directly.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
p.wrap_openai_client(client)
1818

1919

20-
def call_llm(data: List[dict], model: str = "gpt-3.5-turbo", temperature: float = 0.0) -> str:
20+
def call_llm(data: List[dict], model: str = "gpt-4-turbo", temperature: float = 0.0) -> str:
2121
return client.chat.completions.create(model=model, temperature=temperature, messages=data).choices[0].message.content
2222

2323

@@ -82,7 +82,7 @@ def argument_chain(query: str, additional_description: str = "") -> Tuple[str, s
8282
@trace
8383
def json_call() -> str:
8484
completion = client.chat.completions.create(
85-
model="gpt-3.5-turbo-0125",
85+
model="gpt-4-turbo-2024-04-09",
8686
messages=[{"role": "system", "content": "You are a helpful assistant talking in JSON."}, {"role": "user", "content": "What are you?"}],
8787
response_format={"type": "json_object"},
8888
)
@@ -95,11 +95,11 @@ def json_call() -> str:
9595
additional_description="Provide a concise, few sentence argument on why sparkling wine is good for you.",
9696
)
9797
print(result)
98-
p.record_feedback(
99-
FeedbackRequest(
100-
trace_id=trace_id,
101-
score=0.7, # 0.0 (bad) to 1.0 (good)
102-
)
103-
)
98+
# p.record_feedback(
99+
# FeedbackRequest(
100+
# trace_id=trace_id,
101+
# score=0.7, # 0.0 (bad) to 1.0 (good)
102+
# )
103+
# )
104104

105105
print(json_call())

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"
66
[tool.poetry]
77
name = "parea-ai"
88
packages = [{ include = "parea" }]
9-
version = "0.2.127"
9+
version = "0.2.128"
1010
description = "Parea python sdk"
1111
readme = "README.md"
1212
authors = ["joel-parea-ai <[email protected]>"]

0 commit comments

Comments
 (0)