Skip to content

Commit

Permalink
🐞 fix:
Browse files Browse the repository at this point in the history
  • Loading branch information
DrinkLessMilkTea committed Jul 18, 2024
1 parent 9483712 commit c8afbf6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions WorkerNodePython/WorkerNode/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ FROM python:3.8-slim

COPY WorkerNode.py Event.py ApiMessageProcessor.py requirement.txt local.sh ai.sh start.sh/
RUN pip install -r requirement.txt

CMD ["python3","WorkerNode.py"]
9 changes: 5 additions & 4 deletions WorkerNodePython/WorkerNode/WorkerNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@
def init():
global nodeType,pulsarURL,serviceTopicName,pulsarToken,topicName
global maxProcessNum,apiURL,apiKey,queue,map,model,debug,AIModelName,AIModelNamespace
nodeType = os.getenv('NODE_TYPE','local');
nodeType = os.getenv('NODE_TYPE','api');
pulsarURL = os.getenv('PULSAR_URL',"pulsar://localhost:6650");
maxProcessNum = int(os.getenv('MAX_PROCESS_NUM','5'));
maxProcessNum = int(os.getenv('MAX_PROCESS_NUM','2'));
if nodeType == 'local':
apiURL = 'http://localhost:8080/v1/chat/completions'
apiKey = 'sk-no-key-required'
else:
apiURL = os.getenv('API_URL',"https://api.openai-hk.com/v1/chat/completions");
apiKey = os.getenv('API_KEY',"");
apiKey = os.getenv('API_KEY',"hk-j9e9al1000037138f0cd6a31058a83dbb7a63f56fd48788c");
model = os.getenv('MODEL_NAME','gpt-3.5-turbo')
serviceTopicName = os.getenv('RES_TOPIC_NAME','res-topic')
debug = bool(os.getenv('DEBUG','false'))
Expand Down Expand Up @@ -119,6 +119,7 @@ def run():
while activeThreads >= maxProcessNum:
condition.wait()
msg = consumer.receive()
time.sleep(5)
#consumer.acknowledge(msg)
print('received message: {}'.format(msg.data())) # debug
queue.put(msg,True)
Expand Down Expand Up @@ -231,6 +232,6 @@ def kubenetesInit():
apiInstance = client.CoreV1Api()

if __name__ == '__main__':
#kubenetesInit()
kubenetesInit()
init()
run()
2 changes: 1 addition & 1 deletion WorkerNodePython/WorkerNode/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ cleanup() {
# 设置 trap 捕捉退出信号 (例如,Ctrl+C, exit 等)
trap cleanup EXIT

# 检查目录是否存在并运行 Pulsar
检查目录是否存在并运行 Pulsar
if [[ -d ~/apache-pulsar-3.3.0/bin ]]; then
cd ~/apache-pulsar-3.3.0/bin
./pulsar standalone
Expand Down

0 comments on commit c8afbf6

Please sign in to comment.