Spaces:
Running
Running
update
Browse files
idreamers/api/calculation/openai_request.py
CHANGED
@@ -15,6 +15,10 @@ async def calculate_scores(data: PilotRequest, type_: Literal["business", "compe
|
|
15 |
prompt = CalculationPrompts.business
|
16 |
else:
|
17 |
prompt = CalculationPrompts.critical
|
|
|
|
|
|
|
|
|
18 |
messages = [
|
19 |
{
|
20 |
"role": "system",
|
@@ -22,6 +26,7 @@ async def calculate_scores(data: PilotRequest, type_: Literal["business", "compe
|
|
22 |
.replace("{supplier}", data.supplier)
|
23 |
.replace("{category}", data.category)
|
24 |
.replace("{buying_company}", data.buyingCompany)
|
|
|
25 |
}
|
26 |
]
|
27 |
return messages
|
|
|
15 |
prompt = CalculationPrompts.business
|
16 |
else:
|
17 |
prompt = CalculationPrompts.critical
|
18 |
+
|
19 |
+
if data.context:
|
20 |
+
data.context = f'\n\n**Context**:\n```\n{data.context}\n```'
|
21 |
+
|
22 |
messages = [
|
23 |
{
|
24 |
"role": "system",
|
|
|
26 |
.replace("{supplier}", data.supplier)
|
27 |
.replace("{category}", data.category)
|
28 |
.replace("{buying_company}", data.buyingCompany)
|
29 |
+
.replace("{context}", data.context)
|
30 |
}
|
31 |
]
|
32 |
return messages
|
idreamers/api/calculation/prompts.py
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
class CalculationPrompts:
|
2 |
competitive = """## Task
|
3 |
-
|
|
|
4 |
|
5 |
Question:
|
6 |
```
|
7 |
How dependent is your business on this supplier for critical operations?
|
8 |
-
```
|
9 |
-
|
10 |
-
Think about whether this supplier is essential for your day-to-day operations.
|
11 |
|
12 |
## Data
|
13 |
|
@@ -24,7 +23,7 @@ Think about whether this supplier is essential for your day-to-day operations.
|
|
24 |
**Buying Company**:
|
25 |
```
|
26 |
{buying_company}
|
27 |
-
```
|
28 |
|
29 |
## JSON Response format
|
30 |
|
@@ -35,14 +34,13 @@ Think about whether this supplier is essential for your day-to-day operations.
|
|
35 |
|
36 |
- [score]: Numerical score between 1 and 4. 1 = Many, 4 = Very few."""
|
37 |
supplier = """## Task
|
38 |
-
|
|
|
39 |
|
40 |
Question:
|
41 |
```
|
42 |
How competitive is the market where this supplier operates?
|
43 |
-
```
|
44 |
-
|
45 |
-
Evaluate whether this supplier faces competition or has significant market control.
|
46 |
|
47 |
## Data
|
48 |
|
@@ -59,7 +57,7 @@ Evaluate whether this supplier faces competition or has significant market contr
|
|
59 |
**Buying Company**:
|
60 |
```
|
61 |
{buying_company}
|
62 |
-
```
|
63 |
|
64 |
## JSON Response format
|
65 |
|
@@ -70,14 +68,13 @@ Evaluate whether this supplier faces competition or has significant market contr
|
|
70 |
|
71 |
- [score]: Numerical score between 1 and 4. 1 = Highly competitive, 4 = Monopoly/Oligopoly."""
|
72 |
business = """## Task
|
73 |
-
|
|
|
74 |
|
75 |
Question:
|
76 |
```
|
77 |
How dependent is the supplier on your organization for their revenue?
|
78 |
```
|
79 |
-
|
80 |
-
Reflect on how important your business is to this supplier’s overall revenue.
|
81 |
|
82 |
## Data
|
83 |
|
@@ -94,7 +91,7 @@ Reflect on how important your business is to this supplier’s overall revenue.
|
|
94 |
**Buying Company**:
|
95 |
```
|
96 |
{buying_company}
|
97 |
-
```
|
98 |
|
99 |
## JSON Response format
|
100 |
|
@@ -105,14 +102,13 @@ Reflect on how important your business is to this supplier’s overall revenue.
|
|
105 |
|
106 |
- [score]: Numerical score between 1 and 4. 1 = Not dependent, 4 = Highly dependent."""
|
107 |
critical = """## Task
|
108 |
-
|
|
|
109 |
|
110 |
Question:
|
111 |
```
|
112 |
How critical is this supplier for delivering unique or differentiated products/services?
|
113 |
-
```
|
114 |
-
|
115 |
-
Think about whether this supplier provides something that others cannot easily replicate.
|
116 |
|
117 |
## Data
|
118 |
|
@@ -129,7 +125,7 @@ Think about whether this supplier provides something that others cannot easily r
|
|
129 |
**Buying Company**:
|
130 |
```
|
131 |
{buying_company}
|
132 |
-
```
|
133 |
|
134 |
## JSON Response format
|
135 |
|
|
|
1 |
class CalculationPrompts:
|
2 |
competitive = """## Task
|
3 |
+
|
4 |
+
Think about whether this supplier is essential for your day-to-day operations, answer on the question below and set a score.
|
5 |
|
6 |
Question:
|
7 |
```
|
8 |
How dependent is your business on this supplier for critical operations?
|
9 |
+
```
|
|
|
|
|
10 |
|
11 |
## Data
|
12 |
|
|
|
23 |
**Buying Company**:
|
24 |
```
|
25 |
{buying_company}
|
26 |
+
```{context}
|
27 |
|
28 |
## JSON Response format
|
29 |
|
|
|
34 |
|
35 |
- [score]: Numerical score between 1 and 4. 1 = Many, 4 = Very few."""
|
36 |
supplier = """## Task
|
37 |
+
|
38 |
+
Evaluate whether this supplier faces competition or has significant market control, answer on the question below and set a score.
|
39 |
|
40 |
Question:
|
41 |
```
|
42 |
How competitive is the market where this supplier operates?
|
43 |
+
```
|
|
|
|
|
44 |
|
45 |
## Data
|
46 |
|
|
|
57 |
**Buying Company**:
|
58 |
```
|
59 |
{buying_company}
|
60 |
+
```{context}
|
61 |
|
62 |
## JSON Response format
|
63 |
|
|
|
68 |
|
69 |
- [score]: Numerical score between 1 and 4. 1 = Highly competitive, 4 = Monopoly/Oligopoly."""
|
70 |
business = """## Task
|
71 |
+
|
72 |
+
Reflect on how important your business is to this supplier’s overall revenue, answer on the question below and set a score.
|
73 |
|
74 |
Question:
|
75 |
```
|
76 |
How dependent is the supplier on your organization for their revenue?
|
77 |
```
|
|
|
|
|
78 |
|
79 |
## Data
|
80 |
|
|
|
91 |
**Buying Company**:
|
92 |
```
|
93 |
{buying_company}
|
94 |
+
```{context}
|
95 |
|
96 |
## JSON Response format
|
97 |
|
|
|
102 |
|
103 |
- [score]: Numerical score between 1 and 4. 1 = Not dependent, 4 = Highly dependent."""
|
104 |
critical = """## Task
|
105 |
+
|
106 |
+
Think about whether this supplier provides something that others cannot easily replicate, answer on the question below and set a score.
|
107 |
|
108 |
Question:
|
109 |
```
|
110 |
How critical is this supplier for delivering unique or differentiated products/services?
|
111 |
+
```
|
|
|
|
|
112 |
|
113 |
## Data
|
114 |
|
|
|
125 |
**Buying Company**:
|
126 |
```
|
127 |
{buying_company}
|
128 |
+
```{context}
|
129 |
|
130 |
## JSON Response format
|
131 |
|
idreamers/api/calculation/schemas.py
CHANGED
@@ -5,7 +5,7 @@ class PilotRequest(BaseModel):
|
|
5 |
category: str
|
6 |
buyingCompany: str
|
7 |
supplier: str
|
8 |
-
context: str
|
9 |
|
10 |
class PilotResponse(BaseModel):
|
11 |
x: float
|
|
|
5 |
category: str
|
6 |
buyingCompany: str
|
7 |
supplier: str
|
8 |
+
context: str = ''
|
9 |
|
10 |
class PilotResponse(BaseModel):
|
11 |
x: float
|