pref: 新建线程初始化LLM接口
This commit is contained in:
4
utils.py
4
utils.py
@@ -4,6 +4,7 @@ import numpy as np
|
||||
import erniebot
|
||||
from simple_pid import PID
|
||||
from loguru import logger
|
||||
import threading
|
||||
|
||||
# 巡线误差
|
||||
lane_error = 0
|
||||
@@ -243,6 +244,7 @@ class label_filter:
|
||||
|
||||
class LLM:
|
||||
def __init__(self):
|
||||
self.init_done_flag = False
|
||||
erniebot.api_type = "qianfan"
|
||||
erniebot.ak = "jReawMtWhPu0wrxN9Rp1MzZX"
|
||||
erniebot.sk = "eowS1BqsNgD2i0C9xNnHUVOSNuAzVTh6"
|
||||
@@ -273,6 +275,8 @@ class LLM:
|
||||
def make_message(self,content):
|
||||
return {'role': 'user', 'content': content}
|
||||
def get_command_json(self,chat):
|
||||
while self.init_done_flag == False: # 等待初始化 (要是等到调用还没初始化,那就是真寄了)
|
||||
pass
|
||||
self.messages.append(self.make_message(chat))
|
||||
self.resp = erniebot.ChatCompletion.create(
|
||||
model=self.model,
|
||||
|
||||
Reference in New Issue
Block a user