mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-13 16:53:24 +00:00
Merge branch 'main' of github.com:BoardWare-Genius/jarvis-models
This commit is contained in:
@ -93,12 +93,7 @@ class VLMS(Blackbox):
|
||||
response: a string
|
||||
history: a list
|
||||
"""
|
||||
# if model_name == "Qwen-VL-Chat":
|
||||
# model_name = "infer-qwen-vl"
|
||||
# elif model_name == "llava-llama-3-8b-v1_1-transformers":
|
||||
# model_name = "infer-lav-lam-v1-1"
|
||||
# else:
|
||||
# model_name = "infer-qwen-vl"
|
||||
|
||||
if settings:
|
||||
for k in settings:
|
||||
if k not in self.settings:
|
||||
@ -154,8 +149,8 @@ class VLMS(Blackbox):
|
||||
# }
|
||||
# ]
|
||||
api_client = APIClient(self.url)
|
||||
# api_client = APIClient("http://10.6.80.91:23333")
|
||||
model_name = api_client.available_models[0]
|
||||
|
||||
# Reformat input into openai format to request.
|
||||
if images_data:
|
||||
messages = user_context + [{
|
||||
@ -207,7 +202,7 @@ class VLMS(Blackbox):
|
||||
user_context = messages + [{'role': 'assistant', 'content': responses}]
|
||||
return responses, user_context
|
||||
|
||||
def _into_openai_format(self, context:List[list]):
|
||||
def _into_openai_format(self, context:List[list]) -> List[dict]:
|
||||
"""
|
||||
Convert the data into openai format.
|
||||
context: a list of list, each element have the form [user_input, response],
|
||||
@ -278,12 +273,16 @@ class VLMS(Blackbox):
|
||||
prompt = data.get("prompt")
|
||||
settings: dict = data.get('settings')
|
||||
context = data.get("context")
|
||||
print(context)
|
||||
print(type(context))
|
||||
|
||||
user_context = self._into_openai_format(context) if context else []
|
||||
if not context:
|
||||
user_context = []
|
||||
elif isinstance(context[0], list):
|
||||
user_context = self._into_openai_format(context)
|
||||
elif isinstance(context[0], dict):
|
||||
user_context = context
|
||||
else:
|
||||
return JSONResponse(content={"error": "context format error, should be in format of list or Openai_format"}, status_code=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
print(user_context)
|
||||
if json_request:
|
||||
img_data = data.get("img_data")
|
||||
else:
|
||||
@ -299,4 +298,4 @@ class VLMS(Blackbox):
|
||||
response, history = self.processing(prompt, img_data,settings, model_name,user_context=user_context)
|
||||
# jsonresp = str(JSONResponse(content={"response": self.processing(prompt, img_data, model_name)}).body, "utf-8")
|
||||
|
||||
return JSONResponse(content={"response": response, "history": history}, status_code=status.HTTP_200_OK)
|
||||
return JSONResponse(content={"response": response}, status_code=status.HTTP_200_OK)
|
||||
Reference in New Issue
Block a user