Spaces:
Sleeping
Sleeping
Commit
·
f18440e
1
Parent(s):
0370b8f
Update bot.py
Browse files
bot.py
CHANGED
|
@@ -12,25 +12,29 @@ class supertec_bot:
|
|
| 12 |
|
| 13 |
payload = {'company_token': 'II@tNfQ70O'}
|
| 14 |
|
| 15 |
-
response = requests.post("https://superteclabs.com/apis2/retrieveallusers.php", data=payload,
|
| 16 |
-
headers=headers)
|
| 17 |
|
| 18 |
data = response.json()
|
| 19 |
return response.text
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
self.get_data = get_data
|
| 22 |
|
|
|
|
|
|
|
| 23 |
function_balance = {
|
| 24 |
"type": "function",
|
| 25 |
"function": {
|
| 26 |
"name": "get_data",
|
| 27 |
-
"description": "
|
| 28 |
"parameters": {
|
| 29 |
"type": "object",
|
| 30 |
"properties": {
|
| 31 |
"query": {
|
| 32 |
"type": "string",
|
| 33 |
-
"description": "
|
| 34 |
},
|
| 35 |
},
|
| 36 |
"required": ["query"]
|
|
@@ -38,6 +42,8 @@ class supertec_bot:
|
|
| 38 |
}
|
| 39 |
}
|
| 40 |
|
|
|
|
|
|
|
| 41 |
import os
|
| 42 |
from dotenv import load_dotenv
|
| 43 |
|
|
@@ -46,13 +52,13 @@ class supertec_bot:
|
|
| 46 |
|
| 47 |
self.client = openai.OpenAI(api_key=os.environ['openai_api_key'])
|
| 48 |
print(self.client)
|
| 49 |
-
Step 1: Create an Assistant
|
| 50 |
-
self.assistant = self.client.beta.assistants.create(
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
)
|
| 56 |
|
| 57 |
|
| 58 |
|
|
@@ -72,7 +78,7 @@ class supertec_bot:
|
|
| 72 |
# Step 4: Run the Assistant
|
| 73 |
run = self.client.beta.threads.runs.create(
|
| 74 |
thread_id=thread.id,
|
| 75 |
-
assistant_id="
|
| 76 |
instructions=""
|
| 77 |
)
|
| 78 |
answer = None
|
|
|
|
| 12 |
|
| 13 |
payload = {'company_token': 'II@tNfQ70O'}
|
| 14 |
|
| 15 |
+
response = requests.post("https://superteclabs.com/apis2/retrieveallusers.php", data=payload,headers=headers)
|
|
|
|
| 16 |
|
| 17 |
data = response.json()
|
| 18 |
return response.text
|
| 19 |
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
|
| 23 |
self.get_data = get_data
|
| 24 |
|
| 25 |
+
|
| 26 |
+
|
| 27 |
function_balance = {
|
| 28 |
"type": "function",
|
| 29 |
"function": {
|
| 30 |
"name": "get_data",
|
| 31 |
+
"description": "get all data from database",
|
| 32 |
"parameters": {
|
| 33 |
"type": "object",
|
| 34 |
"properties": {
|
| 35 |
"query": {
|
| 36 |
"type": "string",
|
| 37 |
+
"description": "The query to run when getting data"
|
| 38 |
},
|
| 39 |
},
|
| 40 |
"required": ["query"]
|
|
|
|
| 42 |
}
|
| 43 |
}
|
| 44 |
|
| 45 |
+
|
| 46 |
+
|
| 47 |
import os
|
| 48 |
from dotenv import load_dotenv
|
| 49 |
|
|
|
|
| 52 |
|
| 53 |
self.client = openai.OpenAI(api_key=os.environ['openai_api_key'])
|
| 54 |
print(self.client)
|
| 55 |
+
#Step 1: Create an Assistant
|
| 56 |
+
# self.assistant = self.client.beta.assistants.create(
|
| 57 |
+
# name="SuperTech Support Chatbot",
|
| 58 |
+
# instructions="You are a a personal supertec chatbot that's highly tech-oriented and a part of the Rehan Foundation. Your primary job is to respond to user queries.",
|
| 59 |
+
# tools=[function_balance],
|
| 60 |
+
# model="gpt-3.5-turbo",
|
| 61 |
+
# )
|
| 62 |
|
| 63 |
|
| 64 |
|
|
|
|
| 78 |
# Step 4: Run the Assistant
|
| 79 |
run = self.client.beta.threads.runs.create(
|
| 80 |
thread_id=thread.id,
|
| 81 |
+
assistant_id="asst_IBlxaXvYi7O0mUYvhxZMzw3I",
|
| 82 |
instructions=""
|
| 83 |
)
|
| 84 |
answer = None
|