Skip to content

Commit

Permalink
feat: stub overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
grutt committed Feb 6, 2024
1 parent 1a1b460 commit 95ae6d8
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions python-examples/fast-api-react/backend/src/workflows/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,14 @@ def reason_docs(self, ctx: Context):
message = ctx.workflow_input()['request']["messages"][-1]
docs = ctx.step_output("load_docs")['docs']

prompt = f"The user is asking the following question:\
{message['content']}\
What are the most relevant sentences in the following document?\
{docs}"
prompt = ctx.overrides(
'reason:prompt',
"The user is asking the following question:\
{{message}}\
What are the most relevant sentences in the following document?\
{{docs}}")

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

model = "gpt-3.5-turbo" # ctx.override("gpt-3.5-turbo", options=[''])

Expand All @@ -132,17 +136,23 @@ def reason_docs(self, ctx: Context):
def generate_response(self, ctx: Context):
messages = ctx.workflow_input()['request']["messages"]
research = ctx.step_output("reason_docs")['research']
prompt = f"You are a sales engineer for a company called Hatchet.\

prompt = ctx.overrides(
'answer:prompt',
"You are a sales engineer for a company called Hatchet.\
Help address the user's question. \
Use the following context:\
{research}"
model = "gpt-3.5-turbo"
{{research}}")

prompt = prompt.format(research=research)

model = ctx.overrides('answer:model', "gpt-3.5-turbo")

completion = openai.chat.completions.create(
model=model,
messages=[
{"role": "system", "content": prompt},
]+messages
] + messages
)

return {
Expand Down

0 comments on commit 95ae6d8

Please sign in to comment.