Created
November 7, 2025 22:18
-
-
Save yakkomajuri/845d9d82c40a94574c911c469df9b980 to your computer and use it in GitHub Desktop.
Example snippet showing Skald chat working over a PDF upload
This file contains hidden or 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
| import asyncio | |
| from skald_sdk import Skald | |
| import time | |
| import os | |
| max_wait_time = 120 | |
| async def main(): | |
| async with Skald(os.getenv("SKALD_API_KEY")) as skald: | |
| res = await skald.create_memo_from_file(file_path="localcurrency-snippet.pdf") | |
| memo_uuid = res["memo_uuid"] | |
| print(f"Memo created: {memo_uuid}") | |
| start_time = time.time() | |
| while time.time() - start_time < max_wait_time: | |
| print(f"Checking memo status...") | |
| res = await skald.check_memo_status(memo_uuid) | |
| if res["status"] == "processed": | |
| print('Memo finished processing') | |
| break | |
| await asyncio.sleep(1) | |
| async for event in skald.streamed_chat({ | |
| "query": "what were the consequences of the banco palmas project?" | |
| }): | |
| if event["type"] == "token": | |
| print(event["content"], end="", flush=True) | |
| elif event["type"] == "done": | |
| print("\n[Stream completed]") | |
| asyncio.run(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment