Spaces:
Sleeping
Sleeping
Commit
·
e2cfaa1
1
Parent(s):
c47663e
validated initial interaction
Browse files
my_agent/utils/initial_interaction.py
CHANGED
|
@@ -7,15 +7,8 @@ from pydantic import BaseModel, ConfigDict, Field
|
|
| 7 |
from typing import Optional, List
|
| 8 |
from .models_loader import llm
|
| 9 |
from .prompts import introduction_prompt , details_extract_prompt
|
|
|
|
| 10 |
|
| 11 |
-
# Pydantic model for extracted business info
|
| 12 |
-
class DetailsFormatter(BaseModel):
|
| 13 |
-
business_type: str = Field(description="The type of the business")
|
| 14 |
-
platform: str = Field(description="The platform used for the business")
|
| 15 |
-
target_audience: str = Field(description="The target audience of the business")
|
| 16 |
-
business_goals: str = Field(description="The business goals of the business")
|
| 17 |
-
offerings: str = Field(description="The offerings of the business")
|
| 18 |
-
Challenges_faced: str = Field(description="The challenges faced by the business")
|
| 19 |
|
| 20 |
# State model
|
| 21 |
class State(BaseModel):
|
|
@@ -62,11 +55,7 @@ class IntroductionChatbot:
|
|
| 62 |
template = details_extract_prompt(business_state.interactions)
|
| 63 |
|
| 64 |
messages = [SystemMessage(content=template)]
|
| 65 |
-
response = self.llm.
|
|
|
|
|
|
|
| 66 |
|
| 67 |
-
if hasattr(response, 'tool_calls') and response.tool_calls:
|
| 68 |
-
return response.tool_calls[0]['args']
|
| 69 |
-
elif hasattr(response, 'content'):
|
| 70 |
-
return response.content
|
| 71 |
-
else:
|
| 72 |
-
return "No response"
|
|
|
|
| 7 |
from typing import Optional, List
|
| 8 |
from .models_loader import llm
|
| 9 |
from .prompts import introduction_prompt , details_extract_prompt
|
| 10 |
+
from .validators import DetailsFormatter
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
# State model
|
| 14 |
class State(BaseModel):
|
|
|
|
| 55 |
template = details_extract_prompt(business_state.interactions)
|
| 56 |
|
| 57 |
messages = [SystemMessage(content=template)]
|
| 58 |
+
response = self.llm.with_structured_output(DetailsFormatter).invoke(messages)
|
| 59 |
+
print('Extracetd details:',response)
|
| 60 |
+
return response
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|