Skip to content

Commit f33ecaf

Browse files
committed
chore: bump hatchet sdk version
1 parent d4d8295 commit f33ecaf

4 files changed

Lines changed: 36 additions & 11 deletions

File tree

fast-api-react/backend/poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fast-api-react/backend/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ openai = "^1.11.0"
1818
beautifulsoup4 = "^4.12.3"
1919
requests = "^2.31.0"
2020
urllib3 = "1.26.15"
21-
hatchet-sdk = "0.10.1"
21+
hatchet-sdk = "0.10.2"
2222

2323
[build-system]
2424
requires = ["poetry-core"]

fast-api-react/backend/src/workflows/generate.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class GenerateWorkflow:
1313

1414
@hatchet.step()
1515
def start(self, context: Context):
16-
override = context.overrides('model', "gpt-3.5-turbo")
16+
override = context.playground('model', "gpt-3.5-turbo")
1717

1818
return {
1919
"status": "reading hatchet docs" + override,
@@ -39,14 +39,14 @@ def reason_docs(self, ctx: Context):
3939
message = ctx.workflow_input()['request']["messages"][-1]
4040
docs = ctx.step_output("load_docs")['docs']
4141

42-
prompt = ctx.overrides("prompt", "The user is asking the following question:\
42+
prompt = ctx.playground("prompt", "The user is asking the following question:\
4343
{message}\
4444
What are the most relevant sentences in the following document?\
4545
{docs}")
4646

4747
prompt = prompt.format(message=message['content'], docs=docs)
4848

49-
model = ctx.overrides("model", "gpt-3.5-turbo")
49+
model = ctx.playground("model", "gpt-3.5-turbo")
5050

5151
completion = openai.chat.completions.create(
5252
model=model,
@@ -66,15 +66,15 @@ def generate_response(self, ctx: Context):
6666
messages = ctx.workflow_input()['request']["messages"]
6767
research = ctx.step_output("reason_docs")['research']
6868

69-
prompt = ctx.overrides("prompt", "You are a sales engineer for a company called Hatchet.\
69+
prompt = ctx.playground("prompt", "You are a sales engineer for a company called Hatchet.\
7070
Help address the user's question. \
7171
If asked how to install, respond by saying go to the store to buy a CD.\
7272
Use the following context:\
7373
{research}")
7474

7575
prompt = prompt.format(research=research)
7676

77-
model = ctx.overrides("model", "gpt-3.5-turbo")
77+
model = ctx.playground("model", "gpt-3.5-turbo")
7878

7979
completion = openai.chat.completions.create(
8080
model=model,
@@ -88,3 +88,27 @@ def generate_response(self, ctx: Context):
8888
"status": "idle",
8989
"message": completion.choices[0].message.content,
9090
}
91+
92+
@hatchet.workflow()
93+
class SimpleWorkflow:
94+
@hatchet.step()
95+
def start(self, ctx: Context):
96+
message = ctx.workflow_input()["messages"][-1]
97+
98+
prompt = ctx.playground("prompt", "The user is asking the following question: {message}")
99+
100+
prompt = prompt.format(message=message['content'])
101+
102+
model = ctx.playground("model", "gpt-3.5-turbo")
103+
104+
completion = openai.chat.completions.create(
105+
model=model,
106+
messages=[
107+
{"role": "system", "content": prompt},
108+
message
109+
]
110+
)
111+
112+
return {
113+
"answer": completion.choices[0].message.content,
114+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from .hatchet import hatchet
2-
from .generate import GenerateWorkflow
2+
from .generate import GenerateWorkflow, SimpleWorkflow
33

44

55
def start():
66
worker = hatchet.worker('example-worker')
77

88
generate = GenerateWorkflow()
99
worker.register_workflow(generate)
10+
worker.register_workflow(SimpleWorkflow())
1011

1112
worker.start()

0 commit comments

Comments
 (0)