Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- Classifier.py +39 -0
- agents.py +0 -0
Classifier.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import cohere
|
2 |
+
from cohere.responses.classify import Example
|
3 |
+
|
4 |
+
class IntentClassifier:
|
5 |
+
|
6 |
+
def _init__(self):
|
7 |
+
|
8 |
+
self.kazik = "franek"
|
9 |
+
|
10 |
+
async def intent(self, input):
|
11 |
+
|
12 |
+
co = cohere.Client("Ev0v9wwQPa90xDucdHTyFsllXGVHXouakUMObkNb")
|
13 |
+
|
14 |
+
examples = [
|
15 |
+
Example("How are you?", "conversation"),
|
16 |
+
Example("Hello!", "conversation"),
|
17 |
+
Example("Can you explain me how it works?", "conversation"),
|
18 |
+
Example("Tell me a joke", "conversation"),
|
19 |
+
Example("Can you start a websocket server?", "websockets"),
|
20 |
+
Example("Connect client to a websocket server", "websockets"),
|
21 |
+
Example("Disconnect a client from server", "websockets"),
|
22 |
+
Example("Establish a connection", "websockets"),
|
23 |
+
Example("At what port connect the client?", "port"),
|
24 |
+
Example("Start server at port 2001", "port"),
|
25 |
+
Example("Connect a client at port 3012", "port"),
|
26 |
+
Example("Which ports are busy?", "port"),
|
27 |
+
Example("To which port can client connect", "port"),
|
28 |
+
Example("What do you know?", "internet search"),
|
29 |
+
Example("What are the most recent news?", "internet search"),
|
30 |
+
Example("I need to know more", "internet search")
|
31 |
+
]
|
32 |
+
|
33 |
+
response = co.classify(
|
34 |
+
model='embed-english-v3.0',
|
35 |
+
inputs=input,
|
36 |
+
examples=examples)
|
37 |
+
|
38 |
+
classifications = response.classifications
|
39 |
+
return str(classifications)
|
agents.py
ADDED
The diff for this file is too large to render.
See raw diff
|
|