-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix multi session tags and add an example (#112)
* fix multi session tags issue and add an example * update example with a no tag in between * bump version 0.6.6
- Loading branch information
1 parent
016c45d
commit 3d3f957
Showing
6 changed files
with
47 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import asyncio | ||
|
||
import openai | ||
from magentic import AsyncStreamedStr, OpenaiChatModel, prompt | ||
|
||
from log10.load import log10, log10_session | ||
|
||
|
||
log10(openai) | ||
|
||
|
||
@prompt("What is {a} * {b}?", model=OpenaiChatModel(model="gpt-4-turbo-preview")) | ||
async def do_math_with_llm_async(a: int, b: int) -> AsyncStreamedStr: | ||
... | ||
|
||
|
||
async def main(): | ||
with log10_session(tags=["test_tag_a"]): | ||
result = await do_math_with_llm_async(2, 2) | ||
async for chunk in result: | ||
print(chunk, end="", flush=True) | ||
|
||
result = await do_math_with_llm_async(2.5, 2.5) | ||
async for chunk in result: | ||
print(chunk, end="", flush=True) | ||
|
||
with log10_session(tags=["test_tag_b"]): | ||
result = await do_math_with_llm_async(3, 3) | ||
async for chunk in result: | ||
print(chunk, end="", flush=True) | ||
|
||
|
||
asyncio.run(main()) |
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 @@ | ||
magentic |
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