| | |
| | | async def chat_completions(self, url, data, headers): |
| | | complete_response = "" |
| | | async for line in self.http_stream(url, data, headers): |
| | | print(line) |
| | | # print(line) |
| | | if line.startswith("data:"): |
| | | complete_response = line.strip("data:").strip() |
| | | else: |
| | |
| | | yield json_data |
| | | |
| | | except json.JSONDecodeError as e: |
| | | # print(e) |
| | | # print(complete_response) |
| | | logger.info("Invalid JSON data------------------") |
| | | # print(e) |
| | | |
| | |
| | | "session_id": session_id |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @staticmethod |
| | | async def complex_request_data(question, dataset_ids, session_id=""): |
| | | return { |
| | | "question": question, |
| | | "stream": True, |
| | | "session_id": session_id, |
| | | "kb_ids": dataset_ids |
| | | } |
| | | |
| | | |
| | | if __name__ == "__main__": |