updated questions generator
This commit is contained in:
+49
-3
@@ -66,7 +66,49 @@ class Chatbot:
|
||||
print(f"An error occurred: {e}")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def suggest_more_areas(self, position, existing_areas) -> VisionMissionResponse:
|
||||
"""
|
||||
This method is responsible for suggesting more areas based on the worker's position and existing areas.
|
||||
The system generates a prompt, and then uses the GPT-4 model to return more areas based on the query.
|
||||
|
||||
:param position: The worker's position.
|
||||
:param existing areas: The existing areas.
|
||||
:return: VisionMissionResponse containing the suggested areas or None if an error occurs.
|
||||
"""
|
||||
try:
|
||||
|
||||
prompt = suggest_more_areas_prompt()
|
||||
response = self.client.beta.chat.completions.parse(
|
||||
model=self.model,
|
||||
messages=[
|
||||
{
|
||||
"role": "system",
|
||||
"content": f'''{prompt} '''
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"position :{position}",
|
||||
},
|
||||
{
|
||||
"role": "user",
|
||||
"content": f"existing areas :{existing_areas}",
|
||||
}
|
||||
],
|
||||
response_format=Areas,
|
||||
max_tokens=1024,
|
||||
temperature=0.1
|
||||
)
|
||||
|
||||
# Parse the response from the LLM
|
||||
extracted_text = json.loads(response.choices[0].message.content)
|
||||
|
||||
return extracted_text
|
||||
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
def predict_based_on_past_assessment(self, query, company_info, companyid) -> Result:
|
||||
@@ -185,7 +227,7 @@ class Chatbot:
|
||||
return None
|
||||
|
||||
|
||||
def recommend_assessment_frequencies(self,sops) -> AssessmentSuggestion:
|
||||
def recommend_assessment_frequencies(self,sops,options) -> AssessmentSuggestion:
|
||||
"""
|
||||
|
||||
Process the SOPs data and return assessment frequencies.
|
||||
@@ -211,7 +253,8 @@ class Chatbot:
|
||||
model=self.model,
|
||||
messages=[
|
||||
{"role": "system", "content": prompt},
|
||||
{"role": "user", "content": docs}
|
||||
{"role": "user", "content": f'provided sops {docs}'},
|
||||
{"role": "user", "content": f'options: {options}'}
|
||||
],
|
||||
response_format=AssessmentSuggestion, # Use the updated response schema
|
||||
max_tokens=4096,
|
||||
@@ -274,3 +317,6 @@ class Chatbot:
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
return None
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user