-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #974 from parea-ai/PAI-1313-instructor-integration…
…-key-error Pai 1313 instructor integration key error
- Loading branch information
Showing
11 changed files
with
95 additions
and
12 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import os | ||
|
||
import instructor | ||
from dotenv import load_dotenv | ||
from openai import AsyncOpenAI | ||
|
||
from parea import Parea | ||
|
||
load_dotenv() | ||
|
||
client = AsyncOpenAI() | ||
|
||
p = Parea(api_key=os.getenv("PAREA_API_KEY")) | ||
p.wrap_openai_client(client, "instructor") | ||
|
||
client = instructor.from_openai(client) | ||
|
||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class UserDetail(BaseModel): | ||
name: str | ||
age: int | ||
|
||
|
||
async def main(): | ||
user = client.completions.create_partial( | ||
model="gpt-3.5-turbo", | ||
max_tokens=1024, | ||
max_retries=3, | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": "Please crea a user", | ||
} | ||
], | ||
response_model=UserDetail, | ||
) | ||
# print(user) | ||
async for u in user: | ||
print(u) | ||
|
||
user2 = client.completions.create_partial( | ||
model="gpt-3.5-turbo", | ||
max_tokens=1024, | ||
max_retries=3, | ||
messages=[ | ||
{ | ||
"role": "user", | ||
"content": "Please crea a user", | ||
} | ||
], | ||
response_model=UserDetail, | ||
) | ||
async for u in user2: | ||
print(u) | ||
|
||
|
||
if __name__ == "__main__": | ||
import asyncio | ||
|
||
asyncio.run(main()) |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api" | |
[tool.poetry] | ||
name = "parea-ai" | ||
packages = [{ include = "parea" }] | ||
version = "0.2.178" | ||
version = "0.2.179" | ||
description = "Parea python sdk" | ||
readme = "README.md" | ||
authors = ["joel-parea-ai <[email protected]>"] | ||
|