-
Notifications
You must be signed in to change notification settings - Fork 6
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 #453 from parea-ai/PAI-666-global-swallow-all-erro…
…rs-on-trace-v2 feat(error): global error handling and logging kill switch
- Loading branch information
Showing
10 changed files
with
240 additions
and
168 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import asyncio | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
|
||
from parea import Parea, trace | ||
from parea.schemas import Completion, LLMInputs, Message, ModelParams, Role | ||
|
||
load_dotenv() | ||
|
||
p = Parea(api_key=os.getenv("PAREA_API_KEY")) | ||
|
||
completion = Completion( | ||
llm_configuration=LLMInputs( | ||
model="gpt-3.5-turbo-1106", | ||
model_params=ModelParams(temp=0.1), | ||
messages=[Message(role=Role.user, content="Write a short haiku about the moon.")], | ||
) | ||
) | ||
|
||
|
||
@trace | ||
def call_llm_stream(): | ||
stream = p.stream(completion) | ||
for chunk in stream: | ||
print(chunk) | ||
|
||
|
||
@trace | ||
async def acall_llm_stream(): | ||
stream = p.astream(completion) | ||
async for chunk in stream: | ||
print(chunk) | ||
|
||
|
||
if __name__ == "__main__": | ||
# call_llm_stream() | ||
asyncio.run(acall_llm_stream()) |
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
Oops, something went wrong.