akiko19191 commited on
Commit
78686fe
·
verified ·
1 Parent(s): a0bae9e

Update utils/functions.py

Browse files
Files changed (1) hide show
  1. utils/functions.py +10 -47
utils/functions.py CHANGED
@@ -17,31 +17,22 @@ def extract_links(text):
17
 
18
  def allocate(messages,api_keys,model,functs):
19
  helper.models=model
20
- try:
21
- del helper.data["imageURL"]
22
- except:
23
- pass
24
-
25
- try:
26
- del helper.data["context"]
27
- except:
28
- pass
29
-
30
  for msg in messages:
31
  if isinstance(msg["content"],list):
32
- for msgs in msg["content"]:
33
- if msgs["type"]=="image_url":
34
- if "base64," in msgs["image_url"]:
35
- helper.data["imageBase64"]=msgs["image_url"]
36
- print(helper.data["imageBase64"]+"base")
37
 
38
- else:
39
- helper.data["imageURL"]=msgs["image_url"]["url"]
40
- print(helper.data["imageURL"]+"a")
 
 
 
 
 
 
41
 
42
 
43
 
44
- msg["content"]=msg["content"][0]["text"]
45
 
46
 
47
  for msg in messages:
@@ -85,31 +76,3 @@ def allocate(messages,api_keys,model,functs):
85
 
86
 
87
 
88
-
89
- def ask(query,prompt,api_endpoint,output={}):
90
- if output=={}:
91
- python_boolean_to_json = {
92
- "true": True,
93
- }
94
-
95
- data = {
96
- 'jailbreakConversationId': json.dumps(python_boolean_to_json['true']),
97
- "systemMessage":prompt,
98
- "message":query,
99
- "toneStyle":"turbo",
100
- "plugins":{"search":False},
101
- # "persona":"sydney"
102
-
103
- }
104
- try:
105
- data["imageURL"]=helper.data["imageURL"]
106
- except:
107
- pass
108
-
109
- resp=requests.post(api_endpoint, json=data,timeout=80)
110
-
111
- return resp.json()["response"]
112
- else:
113
- resp=requests.post(api_endpoint, json=output)
114
- return resp.json()
115
-
 
17
 
18
  def allocate(messages,api_keys,model,functs):
19
  helper.models=model
 
 
 
 
 
 
 
 
 
 
20
  for msg in messages:
21
  if isinstance(msg["content"],list):
22
+ msg["content"]=msg["content"][0]["text"]
 
 
 
 
23
 
24
+ # for msgs in msg["content"]:
25
+ # if msgs["type"]=="image_url":
26
+ # if "base64," in msgs["image_url"]:
27
+ # helper.data["imageBase64"]=msgs["image_url"]
28
+ # print(helper.data["imageBase64"]+"base")
29
+
30
+ # else:
31
+ # helper.data["imageURL"]=msgs["image_url"]["url"]
32
+ # print(helper.data["imageURL"]+"a")
33
 
34
 
35
 
 
36
 
37
 
38
  for msg in messages:
 
76
 
77
 
78