Compare commits

..

2 Commits

Author SHA1 Message Date
adamoutler
751affef70 annotate when using async 2023-02-15 05:04:09 +00:00
adamoutler
2503b8ecaa Update async url 2023-02-15 05:03:53 +00:00
2 changed files with 23 additions and 23 deletions

5
Jenkinsfile vendored
View File

@ -45,13 +45,12 @@ pipeline {
string(credentialsId: 'OpenAI-API-Token', variable: 'OPEN_AI_TOKEN'),
string(credentialsId: 'PapaHashingSecret', variable: 'PAPA_HASH'),
string(credentialsId: 'PapaAsyncUrl', variable: 'ASYNC_URL'),
sshUserPrivateKey(credentialsId: 'dockeruserOn192.168.1.115', keyFileVariable: 'sshkey')
]) {
sshUserPrivateKey(credentialsId: 'dockeruserOn192.168.1.115', keyFileVariable: 'sshkey')]) {
sh '#!/bin/sh \n' +
'mkdir -p ~/.ssh; cp "$sshkey" ~/.ssh/id_rsa'
sh '#!/bin/sh \n' +
/* groovylint-disable-next-line GStringExpressionWithinString */
'docker run --name=aidgaf-server -eSERVERPORT=8087 -eHOSTNAME=0.0.0.0 -eHASHKEY="${PAPA_HASH}" -eAPIKEY="${OPEN_AI_TOKEN}" -eASYNC_METHOD="PATCH" -eASYNC_URL="${PapaAsyncUrl}" -p8087:8087 -d --restart=always aidgaf'
'docker run --name=aidgaf-server -eSERVERPORT=8087 -eHOSTNAME=0.0.0.0 -eHASHKEY="${PAPA_HASH}" -eAPIKEY="${OPEN_AI_TOKEN}" -eASYNC_METHOD="PATCH" -eASYNC_URL="${ASYNC_URL}" -p8087:8087 -d --restart=always aidgaf'
}
}
}

View File

@ -14,6 +14,7 @@ from const import UTF8, REPORTING_TIMEOUT
default_request_body = b'{"message":{"command":"aidgaf","data":{"username":"AdamOutler"}}}'
request_headers = {}
class IDGAFServer(BaseHTTPRequestHandler):
""" This class handles the requests from the client. """
@ -56,7 +57,8 @@ class IDGAFServer(BaseHTTPRequestHandler):
self.handle_response(code, body)
return
thread = threading.Thread(target=self.send_async_request, args=(command,))
thread = threading.Thread(
target=self.send_async_request, args=(command,))
thread.start()
self.handle_response(200, json.dumps(command))
@ -67,6 +69,7 @@ class IDGAFServer(BaseHTTPRequestHandler):
Parameters:
command: The command object received from the client. """
print("using async for response")
[code, body] = self.getGPTResponse(command)
merged = merge.merge_dict_no_overwrite(json.loads(body), command)
merged['hash'] = security.get_message_hash(json.dumps(merged))
@ -87,8 +90,6 @@ class IDGAFServer(BaseHTTPRequestHandler):
timeout=REPORTING_TIMEOUT)
print(str(resp)+resp.text)
# gpt_response = requests.post(URL, json=data, headers=request_headers)
def getGPTResponse(self, command) -> [int, str]: