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
from hamilton.async_driver import Builder | |
from hamilton_sdk import adapters | |
tracker = adapters.AsyncHamiltonTracker( | |
project_id=8, | |
username="elijah@dagworks.io", | |
dag_name="joke_dag", | |
) | |
dr = ( |
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
from hamilton.async_driver import Builder | |
dr = await ( | |
Builder() | |
.with_modules(async_functions) | |
.build() | |
) | |
await dr.execute(["joke_response"], inputs={"topic" : "federal reserve"}) |
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
from hamilton.async_driver import AsyncBuilder | |
dr = ( | |
AsyncBuilder() | |
.with_modules(module_from_above) | |
.build() | |
) | |
await dr.execute( | |
joke_response, | |
inputs={"topic" : "the federal reserve"} |
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
def llm_client() -> openai.AsyncOpenAI: | |
return openai.AsyncOpenAI() | |
def joke_prompt(topic: str) -> str: | |
return ( | |
f"Tell me a short joke about {topic}" | |
) | |
def joke_messages( | |
joke_prompt: str) -> List[dict]: |
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
async def dont_block_control_flow(): | |
result_1 = await complex_http_call() | |
result_2 = await complex_system_call(result_1) | |
return result_2 | |
data_loaded = await dont_block_control_flow() |
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
# python 3.12 | |
""" | |
Hamilton demo. | |
""" | |
import sys | |
import pprint |
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
mine | state | commodity | wikipedia page | colloquial association | |
---|---|---|---|---|---|
Red Dog | Alaska | zinc | https://en.wikipedia.org/wiki/Red_Dog_mine | Teck | |
Goldstrike | Nevada | gold | https://en.wikipedia.org/wiki/Goldstrike_mine | Nevada Gold Mines | |
Bingham Canyon | Utah | copper | https://en.wikipedia.org/wiki/Bingham_Canyon_Mine | Kennecott |
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
<div className="flex-1 overflow-y-auto p-4 hide-scrollbar" id={VIEW_END_ID}> | |
{displayedChatHistory.map((message, i) => ( | |
<ChatMessage | |
message={message} | |
key={i} | |
/> | |
))} | |
{isChatWaiting && ( | |
<ChatMessage | |
message={{ |
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
type Event = { | |
type: 'delta' | 'chat_history'; | |
}; | |
type ChatMessageEvent = Event & { | |
value: string; | |
}; | |
type ChatHistoryEvent = Event & { | |
value: ChatItem[]; |
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
while (true) { | |
const result = await reader.read(); | |
if (result.done) { | |
break; | |
} | |
const message = decoder.decode(result.value, { stream: true }); | |
message | |
.split('data: ') | |
.slice(1) | |
.forEach((item) => { |
NewerOlder