| 71 | |
| 72 | |
| 73 | class QwenModel(BaseModel): |
| 74 | def __init__(self, api_key: str, model: str): |
| 75 | super().__init__() |
| 76 | self.model = model |
| 77 | dashscope.api_key = api_key |
| 78 | |
| 79 | def get_model_response(self, prompt: str, images: List[str]) -> (bool, str): |
| 80 | content = [{ |
| 81 | "text": prompt |
| 82 | }] |
| 83 | for img in images: |
| 84 | img_path = f"file://{img}" |
| 85 | content.append({ |
| 86 | "image": img_path |
| 87 | }) |
| 88 | messages = [ |
| 89 | { |
| 90 | "role": "user", |
| 91 | "content": content |
| 92 | } |
| 93 | ] |
| 94 | response = dashscope.MultiModalConversation.call(model=self.model, messages=messages) |
| 95 | if response.status_code == HTTPStatus.OK: |
| 96 | return True, response.output.choices[0].message.content[0]["text"] |
| 97 | else: |
| 98 | return False, response.message |
| 99 | |
| 100 | |
| 101 | def parse_explore_rsp(rsp): |
no outgoing calls
no test coverage detected