Spaces:
Runtime error
Runtime error
| import json | |
| import logging | |
| from fastapi.encoders import jsonable_encoder | |
| from edu_assistant.learning_tasks import QaTask | |
| from edu_assistant.utils.common_utils import init_local_logging | |
| init_local_logging(logging.DEBUG) | |
| instruction = """ | |
| Act as a c++ professional to answer student aged 5-10 questions. Answer properly and politely. | |
| """ | |
| task = QaTask(instruction=instruction) | |
| def qa_once(): | |
| result = task.ask("请问什么是指针?", session=False) | |
| print(json.dumps(jsonable_encoder(result), ensure_ascii=False, indent=4)) | |
| def qa_twice(): | |
| task = QaTask() | |
| result = task.ask("请问如何释放一个数组?") | |
| result = task.ask("那指针呢?", session_id=result["session_id"]) | |
| print(json.dumps(jsonable_encoder(result), ensure_ascii=False, indent=4)) | |
| if __name__ == "__main__": | |
| # qa_once() | |
| qa_twice() | |