-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquery.py
68 lines (57 loc) · 2.63 KB
/
query.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import requests
url = "http://hddevp.no-ip.org:7002/v1/completions"
conversacional = [
"Hello, I am worried about my memory. I have noticed that sometimes I forget important things and have a hard time remembering details. Is there any exercise or technique that can help me?",
"What's your go-to spot for a cup of joe?",
"Sorry to hear that. Maybe try doing something that makes you happy, like hanging out with friends or doing a fun activity.",
"I'm feeling kinda bummed out lately. Any advice?",
"How are you today?",
"Would you like to go out to dinner tonight?",
"Do you want to watch a movie together tomorrow afternoon?",
"How about we go to the park to exercise?",
]
consulta = [
"How long does it take for this system to work?",
"What is the cost of shipping this product?",
"How can I solve this problem?",
"What are the advantages of using this product?",
"Are there any known problems with this product?",
"How long does it take for this system to work?",
"How can I solve this problem?",
]
generacional = [
"I want create a text or a sentence?",
"Please help me to create a campaign that'll make my products stand out?",
"I need to generate a marketing campaign that showcases my unique selling proposition?",
"I been looking for creating a marketing campaign, can you assist me?",
"Assist me in creating a marketing campaign that targets customers based on their browser history?",
"Are you guide me in creating a marketing campaign that analyzes customer personalities?"
]
sentencia = input("Please enter the sentence: ")
data = {
"temperature": 0.1,
"max_tokens": 1024,
"top_p": 0.9,
"prompt": f"[INST]<<SYS>>Your are an chatbot assistant and given the following instructions: \n \n {conversacional} \n \n, \n \n {consulta} , \n \n {generacional} \n \n <</SYS>>: \
tell me about this new sentence \n \n {sentencia} \n \n what category of sentence does it correspond to (Conversation, Query, Generation) in a single word.[/INST]",
}
response = requests.post(url, json=data)
# print(response.text)
def get_data():
if response.status_code != 200:
print("Error al realizar la solicitud:", response.status_code)
print(response.text)
elif response.status_code == 200:
data = response.json()
return data
def get_query_of_data(data):
content = data.get("choices")[0].get("text")
print(content)
result = content.split('"')
if len(result) > 2:
return result[len(result) - 2]
return content
if __name__ == "__main__":
data = get_data()
intention = get_query_of_data(data)
print(intention)