@@ -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+ }
0 commit comments