@@ -100,14 +100,16 @@ def setup(self) -> None:
100100 self .pipeline = pipeline
101101
102102 # Called for the `generate-referrals/run` endpoint
103- def run_api (self , query : str , user_email : str , prompt_version_id : str = "" ) -> dict :
103+ def run_api (
104+ self , query : str , user_email : str , prompt_version_id : str = "" , suffix : str = ""
105+ ) -> dict :
104106 with using_attributes (user_id = user_email ), using_metadata ({"user_id" : user_email }):
105107 # Must set using_metadata context before calling tracer.start_as_current_span()
106108 assert isinstance (tracer , _tracers .OITracer ), f"Got unexpected { type (tracer )} "
107109 with tracer .start_as_current_span ( # pylint: disable=not-context-manager,unexpected-keyword-arg
108110 self .name , openinference_span_kind = "chain"
109111 ) as span :
110- result = self ._run (query , user_email , prompt_version_id )
112+ result = self ._run (query , user_email , prompt_version_id , suffix )
111113 span .set_input (query )
112114 try :
113115 resp_obj = json .loads (result ["llm" ]["replies" ][- 1 ].text )
@@ -117,16 +119,18 @@ def run_api(self, query: str, user_email: str, prompt_version_id: str = "") -> d
117119 span .set_status (Status (StatusCode .OK ))
118120 return result
119121
120- def _run (self , query : str , user_email : str , prompt_version_id : str = "" ) -> dict :
121- # Retrieve the requested prompt_version_id and error if requested prompt version is not found
122+ def _run (
123+ self , query : str , user_email : str , prompt_version_id : str = "" , suffix : str = ""
124+ ) -> dict :
125+ # Retrieve the requested prompt (with optional prompt_version_id and/or suffix)
122126 try :
123127 prompt_template = haystack_utils .get_phoenix_prompt (
124- "generate_referrals" , prompt_version_id
128+ "generate_referrals" , prompt_version_id = prompt_version_id , suffix = suffix
125129 )
126130 except httpx .HTTPStatusError as he :
127131 raise HTTPException (
128132 status_code = 422 ,
129- detail = f"The requested prompt version '{ prompt_version_id } ' could not be retrieved due to HTTP status { he .response .status_code } " ,
133+ detail = f"The requested prompt version '{ prompt_version_id } ' with suffix ' { suffix } ' could not be retrieved due to HTTP status { he .response .status_code } " ,
130134 ) from he
131135
132136 try :
0 commit comments